How to use test_result method in wpt

Best JavaScript code snippet using wpt

rules_landmarks.js

Source:rules_landmarks.js Github

copy

Full Screen

1/**2 * Copyright 2011-2018 OpenAjax Alliance3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617// import {OpenAjax} from '../openajax_a11y_constants.js';1819/* ---------------------------------------------------------------- */20/* OpenAjax Alliance Heading and Landmark Rules */21/* ---------------------------------------------------------------- */2223OpenAjax.a11y.RuleManager.addRulesFromJSON([2425/**26 * @object LANDMARK_127 *28 * @desc Each page should have at least one main landmark29 *30 */31{ rule_id : 'LANDMARK_1',32 last_updated : '2014-11-28',33 rule_scope : OpenAjax.a11y.RULE_SCOPE.PAGE,34 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,35 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,36 wcag_primary_id : '2.4.1',37 wcag_related_ids : ['1.3.1', '2.4.6'],38 target_resources : ['main', '[role="main"]'],39 primary_property : 'accessible_name',40 resource_properties : ['tag_name', 'role'],41 language_dependency : "",42 validate : function (dom_cache, rule_result) {4344 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;45 var VISIBILITY = OpenAjax.a11y.VISIBILITY;4647 var main_elements = dom_cache.headings_landmarks_cache.main_elements;48 var main_elements_len = main_elements.length;4950 var main_count = 0;5152 for (var i = 0; i < main_elements_len; i++ ) {53 var me = main_elements[i];54 var de = me.dom_element;5556 if (me.dom_element.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {57 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, me, 'ELEMENT_HIDDEN_1', [de.tag_name]);58 else rule_result.addResult(TEST_RESULT.HIDDEN, me, 'ELEMENT_HIDDEN_2', []);59 }60 else {61 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, me, 'ELEMENT_PASS_1', [de.tag_name]);62 else rule_result.addResult(TEST_RESULT.PASS, me, 'ELEMENT_PASS_2', []);63 main_count++;64 }65 }6667 var page_element = dom_cache.headings_landmarks_cache.page_element;6869 if (page_element) {70 // Test if no h1s71 if (main_count === 0) rule_result.addResult(TEST_RESULT.FAIL, page_element, 'PAGE_FAIL_1', []);72 else if (main_count === 1) rule_result.addResult(TEST_RESULT.PASS, page_element, 'PAGE_PASS_1', []);73 else rule_result.addResult(TEST_RESULT.PASS, page_element, 'PAGE_PASS_2', [main_count]);74 }7576 } // end validate function77},7879/**80 * @object LANDMARK_281 *82 * @desc All rendered content should be contained in a landmark83 */84{ rule_id : 'LANDMARK_2',85 last_updated : '2014-11-28',86 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,87 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,88 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,89 wcag_primary_id : '1.3.1',90 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],91 target_resources : ['Page', 'all'],92 primary_property : 'parent_landmark',93 resource_properties : ['tag_name'],94 language_dependency : "",95 validate : function (dom_cache, rule_result) {9697 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;98 var VISIBILITY = OpenAjax.a11y.VISIBILITY;99100 var elements_with_content = dom_cache.headings_landmarks_cache.elements_with_content;101 var elements_with_content_len = elements_with_content.length;102103 var tag_name = "";104105 for (var i = 0; i < elements_with_content_len; i++ ) {106 var de =elements_with_content[i];107108 if (de.tag_name) tag_name = de.tag_name;109 else tag_name = de.parent_element.tag_name;110111// OpenAjax.a11y.logger.debug(" Content: " + de.toString() + " " + de.may_have_renderable_content);112113 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {114 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [tag_name]);115 }116 else {117 if (de.parent_landmark) {118 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [tag_name, de.parent_landmark.landmark]);119 }120 else {121 if (de.may_have_renderable_content) {122 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_1', [tag_name]);123 }124 else {125 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [tag_name]);126 }127 }128 }129 }130131 } // end validate function132},133134/**135 * @object LANDMARK_3136 *137 * @desc Each page within a website should have at least one navigation landmark138 *139 */140{ rule_id : 'LANDMARK_3',141 last_updated : '2014-11-28',142 rule_scope : OpenAjax.a11y.RULE_SCOPE.WEBSITE,143 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,144 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,145 wcag_primary_id : '2.4.1',146 wcag_related_ids : ['1.3.1', '2.4.6'],147 target_resources : ['nav', '[role="navigation"]'],148 primary_property : 'accessible_name',149 resource_properties : ['tag_name', 'role'],150 language_dependency : "",151 validate : function (dom_cache, rule_result) {152153 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;154 var VISIBILITY = OpenAjax.a11y.VISIBILITY;155156 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;157 var landmark_elements_len = landmark_elements.length;158159 var container_elements = dom_cache.lists_cache.container_elements;160 var container_elements_len = container_elements.length;161162 var page_element = dom_cache.headings_landmarks_cache.page_element;163164 var i, ci, le, de, cs;165166167 var navigation_count = 0;168169 for (i = 0; i < landmark_elements_len; i++ ) {170 le = landmark_elements[i];171 de = le.dom_element;172 cs = de.computed_style;173174 var tag_name = le.dom_element.tag_name;175176 if (le.landmark === 'navigation') {177 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {178 navigation_count++;179 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [tag_name]);180 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);181 }182 else {183 rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [tag_name]);184 }185 }186 }187188 if (page_element) {189 // Test if no navigation landmarks190 if (navigation_count === 0) {191192 var list_of_links_count = 0;193194 var MINIMUM_LINKS = 4;195196 for (i = 0; i < container_elements_len; i++) {197 ci = container_elements[i];198 de = ci.dom_element;199 cs = de.computed_style;200201 var li_count = ci.getListItemCount();202 var one_link_count = ci.getListItemCountOneLink();203 var sublist_count = ci.getSublistCount();204205 if (li_count <= (1 + one_link_count + sublist_count)) {206 if (!ci.parent_landmark && (one_link_count > MINIMUM_LINKS)) {207 list_of_links_count += 1;208 rule_result.addResult(TEST_RESULT.FAIL, ci, 'ELEMENT_FAIL_1', [de.tag_name, one_link_count]);209 }210 }211 }212213 // Are there any list of links on the page214 if (list_of_links_count > 0) {215 rule_result.addResult(TEST_RESULT.FAIL, page_element, 'WEBSITE_FAIL_1', []);216 }217 }218 else {219 if (navigation_count === 1) rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_1', []);220 else rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_2', [navigation_count]);221 }222 }223224 } // end validate function225},226227/**228 * @object LANDMARK_4229 *230 * @desc Each page may have one banner landmark231 *232 */233234{ rule_id : 'LANDMARK_4',235 last_updated : '2014-11-28',236 rule_scope : OpenAjax.a11y.RULE_SCOPE.WEBSITE,237 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,238 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,239 wcag_primary_id : '2.4.1',240 wcag_related_ids : ['1.3.1', '2.4.6'],241 target_resources : ['header', '[role="banner"]'],242 primary_property : 'accessible_name',243 resource_properties : ['tag_name', 'role'],244 language_dependency : "",245 validate : function (dom_cache, rule_result) {246247 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;248 var VISIBILITY = OpenAjax.a11y.VISIBILITY;249250 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;251 var landmark_elements_len = landmark_elements.length;252253 var page_element = dom_cache.headings_landmarks_cache.page_element;254255 var landmark_count = 0;256 var les = [];257258 var le, de, cs, tag_name;259260 for (var i = 0; i < landmark_elements_len; i++ ) {261 le = landmark_elements[i];262 de = le.dom_element;263 cs = de.computed_style;264 tag_name = de.tag_name;265266 if (le.landmark === 'banner') {267 if (cs.is_visible_to_at === VISIBILITY.HIDDEN) {268 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [tag_name]);269 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);270 }271 else {272 landmark_count++;273 les.push(le);274 }275 }276 }277278 if (page_element) {279 // Test if no banner landmarks280 if (landmark_count === 0) {281 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, page_element, 'WEBSITE_MC_1', []);282 }283 else {284 if (landmark_count === 1) {285 rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_1', []);286 }287 else {288 rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_2', [landmark_count]);289 }290 for (i = 0; i < les.length; i++) {291 le = les[i];292 de = le.dom_element;293 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [tag_name]);294 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);295 }296 }297 }298299 } // end validate function300},301302/**303 * @object LANDMARK_5304 *305 * @desc Each page may have only one banner landmark306 *307 */308309{ rule_id : 'LANDMARK_5',310 last_updated : '2014-11-28',311 rule_scope : OpenAjax.a11y.RULE_SCOPE.PAGE,312 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,313 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,314 wcag_primary_id : '2.4.1',315 wcag_related_ids : ['1.3.1', '2.4.6'],316 target_resources : ['header', '[role="banner"]'],317 primary_property : 'accessible_name',318 resource_properties : ['tag_name', 'role', 'accessible_name'],319 language_dependency : "",320 validate : function (dom_cache, rule_result) {321322 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;323 var VISIBILITY = OpenAjax.a11y.VISIBILITY;324325 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;326 var landmark_elements_len = landmark_elements.length;327328 var page_element = dom_cache.headings_landmarks_cache.page_element;329330 var landmark_count = 0;331 var les = [];332333 var le, de, cs, tag_name;334335 for (var i = 0; i < landmark_elements_len; i++ ) {336 le = landmark_elements[i];337 de = le.dom_element;338 cs = de.computed_style;339 tag_name = de.tag_name;340341 if (le.landmark === 'banner') {342 if (cs.is_visible_to_at === VISIBILITY.HIDDEN) {343 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [tag_name]);344 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);345 }346 else {347 if (!de.body_element) {348 landmark_count++;349 les.push(le);350 }351 }352 }353 }354355 if (page_element) {356 if (landmark_count > 1) {357 rule_result.addResult(TEST_RESULT.FAIL, page_element, 'PAGE_FAIL_1', [landmark_count]);358 for (i = 0; i < les.length; i++) {359 le = les[i];360 de = le.dom_element;361 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [tag_name]);362 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', []);363 }364 }365 else {366 if (landmark_count === 1) {367 rule_result.addResult(TEST_RESULT.PASS, page_element, 'PAGE_PASS_1', []);368369 le = les[0];370 de = le.dom_element;371 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [tag_name]);372 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);373 }374 }375 }376377 } // end validate function378},379380/**381 * @object LANDMARK_6382 *383 * @desc Each page may have one contentinfo landmark384 *385 */386{ rule_id : 'LANDMARK_6',387 last_updated : '2014-11-28',388 rule_scope : OpenAjax.a11y.RULE_SCOPE.WEBSITE,389 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,390 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,391 wcag_primary_id : '2.4.1',392 wcag_related_ids : ['1.3.1', '2.4.6'],393 target_resources : ['footer', '[role="contentinfo"]'],394 primary_property : 'accessible_name',395 resource_properties : ['tag_name', 'role'],396 language_dependency : "",397 validate : function (dom_cache, rule_result) {398399 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;400 var VISIBILITY = OpenAjax.a11y.VISIBILITY;401402 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;403 var landmark_elements_len = landmark_elements.length;404405 var page_element = dom_cache.headings_landmarks_cache.page_element;406407 var landmark_count = 0;408 var les = [];409410 for (var i = 0; i < landmark_elements_len; i++ ) {411 var le = landmark_elements[i];412 var de = le.dom_element;413 var cs = de.computed_style;414 var tag_name = de.tag_name;415416 if (le.landmark === 'contentinfo') {417 if (cs.is_visible_to_at === VISIBILITY.HIDDEN) {418 if(de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [tag_name]);419 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);420 }421 else {422 landmark_count++;423 les.push(le);424 }425 }426 }427428 if (page_element) {429 // Test if no contentinfo landmarks430 if (landmark_count === 0) {431 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, page_element, 'WEBSITE_MC_1', []);432 }433 else {434 if (landmark_count === 1) {435 de = les[0].dom_element;436 rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_1', []);437 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, les[0], 'ELEMENT_PASS_1', [tag_name]);438 else rule_result.addResult(TEST_RESULT.PASS, les[0], 'ELEMENT_PASS_2', []);439 }440 else {441 rule_result.addResult(TEST_RESULT.PASS, page_element, 'WEBSITE_PASS_2', [landmark_count]);442 for (i = 0; i < les.length; i++) {443 le = les[i];444 de = les[i].dom_element;445 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [tag_name]);446 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);447 }448 }449 }450 }451452 } // end validate function453},454455/**456 * @object LANDMARK_7457 *458 * @desc Each page may have only one contentinfo landmark459 *460 */461{ rule_id : 'LANDMARK_7',462 last_updated : '2014-11-28',463 rule_scope : OpenAjax.a11y.RULE_SCOPE.PAGE,464 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,465 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,466 wcag_primary_id : '2.4.1',467 wcag_related_ids : ['1.3.1', '2.4.6'],468 target_resources : ['footer', '[role="contentinfo"]'],469 primary_property : 'accessible_name',470 resource_properties : ['tag_name', 'role'],471 language_dependency : "",472 validate : function (dom_cache, rule_result) {473474 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;475 var VISIBILITY = OpenAjax.a11y.VISIBILITY;476477 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;478 var landmark_elements_len = landmark_elements.length;479480 var page_element = dom_cache.headings_landmarks_cache.page_element;481482 var landmark_count = 0;483 var les = [];484485 for (var i = 0; i < landmark_elements_len; i++ ) {486 var le = landmark_elements[i];487 var de = le.dom_element;488 var cs = de.computed_style;489 var tag_name = de.tag_name;490491 if (le.landmark === 'contentinfo') {492 if (cs.is_visible_to_at === VISIBILITY.HIDDEN) {493 if(de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [tag_name]);494 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);495 }496 else {497 if (!de.body_element) {498 landmark_count++;499 les.push(le);500 }501 }502 }503 }504505 if (page_element) {506 // Test if no contentinfo landmarks507 if (landmark_count > 1) {508 rule_result.addResult(TEST_RESULT.FAIL, page_element, 'PAGE_FAIL_1', [landmark_count]);509 for (i = 0; i < les.length; i++) {510 le = les[i];511 de = le.dom_element;512 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [tag_name]);513 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', []);514 }515 }516 else {517 if (landmark_count === 1) {518 rule_result.addResult(TEST_RESULT.PASS, page_element, 'PAGE_PASS_1', []);519520 le = les[0];521 de = le.dom_element;522 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [tag_name]);523 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);524 }525 }526 }527528 } // end validate function529},530531/**532 * @object LANDMARK_8533 *534 * @desc banner landmark must be a top level landmark535 */536{ rule_id : 'LANDMARK_8',537 last_updated : '2014-11-28',538 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,539 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,540 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,541 wcag_primary_id : '1.3.1',542 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],543 target_resources : ['header', '[role="banner"]'],544 primary_property : 'parent_landmark',545 resource_properties : ['role', 'tag_name', 'accessible_name'],546 language_dependency : "",547 validate : function (dom_cache, rule_result) {548549 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;550 var VISIBILITY = OpenAjax.a11y.VISIBILITY;551552 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;553 var landmark_elements_len = landmark_elements.length;554555 for (var i = 0; i < landmark_elements_len; i++ ) {556 var le = landmark_elements[i];557 var de = le.dom_element;558 var cs = de.computed_style;559560 if (le.landmark === 'banner') {561562 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {563564 if (de.parent_landmark === null) {565 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [de.tag_name]);566 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', []);567 }568 else {569570 var de1 = de.parent_landmark.dom_element;571572 if (de1 && (de.body_element !== de1.body_element)) {573 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', [de.tag_name]);574 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', []);575 }576 else {577 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [de.tag_name, de.parent_landmark.landmark]);578 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [de.parent_landmark.landmark]);579 }580 }581582 }583 else {584 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);585 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);586 }587 }588 }589 } // end validate function590},591592/**593 * @object LANDMARK_9594 *595 * @desc Banner landmark should only contain only search and navigation landmarks596 */597{ rule_id : 'LANDMARK_9',598 last_updated : '2014-11-28',599 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,600 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,601 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,602 wcag_primary_id : '1.3.1',603 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],604 target_resources : ['header', '[role="banner"]'],605 primary_property : 'accessible_name',606 resource_properties : ['role', 'tag_name', 'parent_landmark'],607 language_dependency : "",608 validate : function (dom_cache, rule_result) {609610 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;611 var VISIBILITY = OpenAjax.a11y.VISIBILITY;612613 function checkLandmarkChildren(landmark) {614615 var cces = landmark.child_cache_elements;616 var cces_len = cces.length;617 var fail_count = 0;618619 for (var i = 0; i < cces_len; i++) {620621 var cce = cces[i];622 var de = cce.dom_element;623 var cs = de.computed_style;624 landmark_count++;625626 if (!cce.landmark) continue;627628 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {629 if ((cce.landmark === 'navigation') ||630 (cce.landmark === 'region') ||631 (cce.landmark === 'search')||632 (cce.landmark === 'application')) {633 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [de.role]);634 else rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [de.tag_name]);635 pass_list += ' ' + cce.landmark;636 }637 else {638 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [de.role]);639 else rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [de.tag_name]);640 fail_count++;641 fail_list += ' ' + cce.landmark;642 }643 if (cce.landmark) fail_count += checkLandmarkChildren(cce);644 }645 else {646 rule_result.addResult(TEST_RESULT.HIDDEN, cce, 'ELEMENT_HIDDEN_1', [de.tag_name]);647 }648 }649650 return fail_count;651 }652653 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;654 var landmark_elements_len = landmark_elements.length;655 var fail_count = 0;656657 for (var i = 0; i < landmark_elements_len; i++ ) {658 var le = landmark_elements[i];659 var de = le.dom_element;660 var cs = de.computed_style;661662 if (le.landmark === 'banner') {663664 var fail_list = '';665 var pass_list = '';666 var landmark_count = 0;667668 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {669 fail_count = checkLandmarkChildren(le);670671 if (fail_count === 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [fail_list.toUpperCase()]);672 else if (fail_count > 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_3', [fail_count, fail_list.toUpperCase()]);673 else if (landmark_count === 0) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);674 else if (landmark_count === 1) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', [pass_list.toUpperCase()]);675 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', [landmark_count, pass_list.toUpperCase()]);676 }677 else {678 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);679 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', [de.tag_name]);680 }681 }682 }683 } // end validate function684},685686/**687 * @object LANDMARK_10688 *689 * @desc Navigation landmark should only contain only region and search landmarks690 */691{ rule_id : 'LANDMARK_10',692 last_updated : '2014-11-28',693 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,694 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,695 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,696 wcag_primary_id : '1.3.1',697 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],698 target_resources : ['nav', '[role="naviation"]'],699 primary_property : 'parent_landmark',700 resource_properties : ['role', 'tag_name', 'accessible_name'],701 language_dependency : "",702 validate : function (dom_cache, rule_result) {703704 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;705 var VISIBILITY = OpenAjax.a11y.VISIBILITY;706707 function checkLandmarkChildren(landmark) {708709 var cces = landmark.child_cache_elements;710 var cces_len = cces.length;711 var fail_count = 0;712713 for (var i = 0; i < cces_len; i++) {714 var cce = cces[i];715 var de = cce.dom_element;716 var cs = de.computed_style;717718 if (!cce.landmark) continue;719720 landmark_count++;721722// OpenAjax.a11y.logger.debug("Landmarks: " + landmark.landmark + " -> " + cce.landmark);723724 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {725 if ((cce.landmark === 'region') ||726 (cce.landmark === 'search')||727 (cce.landmark === 'application')) {728 rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [cce.landmark]);729 pass_list += ' ' + cce.landmark;730 }731 else {732 rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [cce.landmark]);733 fail_count++;734 fail_list += ' ' + cce.landmark;735 }736 fail_count += checkLandmarkChildren(cce);737 }738 else {739 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);740 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', [de.tag_name]);741 }742 }743744 return fail_count;745 }746747748 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;749 var landmark_elements_len = landmark_elements.length;750 var fail_count = 0;751752 for (var i = 0; i < landmark_elements_len; i++ ) {753 var le = landmark_elements[i];754 var de = le.dom_element;755 var cs = de.computed_style;756757758 if (le.landmark === 'navigation') {759760 var fail_list = '';761 var pass_list = '';762 var landmark_count = 0;763764 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {765 fail_count = checkLandmarkChildren(le);766767 if (fail_count === 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [fail_list.toUpperCase()]);768 else if (fail_count > 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_3', [fail_count, fail_list.toUpperCase()]);769 else if (landmark_count === 0) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);770 else if (landmark_count === 1) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', [pass_list.toUpperCase()]);771 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', [landmark_count, pass_list.toUpperCase()]);772 }773 else {774 rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);775 }776 }777 }778 } // end validate function779},780781/**782 * @object LANDMARK_11783 *784 * @desc Main landmark must be a top level lanmark785 */786{ rule_id : 'LANDMARK_11',787 last_updated : '2014-11-28',788 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,789 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,790 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,791 wcag_primary_id : '1.3.1',792 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],793 target_resources : ['main', '[role="main"]'],794 primary_property : 'parent_landmark',795 resource_properties : ['role', 'tag_name', 'accessible_name'],796 language_dependency : "",797 validate : function (dom_cache, rule_result) {798799 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;800 var VISIBILITY = OpenAjax.a11y.VISIBILITY;801802 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;803 var landmark_elements_len = landmark_elements.length;804805 for (var i = 0; i < landmark_elements_len; i++ ) {806 var le = landmark_elements[i];807 var de = le.dom_element;808 var cs = de.computed_style;809810 if (le.landmark === 'main') {811 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {812813 if (de.parent_landmark) {814 var de1 = de.parent_landmark.dom_element;815816 if (de1 && (de.body_element !== de1.body_element)) {817 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', [de.tag_name]);818 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', []);819 }820 else {821 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [de.tag_name, de.parent_landmark.landmark]);822 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [de.parent_landmark.landmark]);823 }824 }825 else {826 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [de.tag_name]);827 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', []);828 }829 }830 else {831 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);832 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);833 }834 }835 }836 } // end validate function837},838839/**840 * @object LANDMARK_12841 *842 * @desc Contentinfo landmark must be a top level landmark843 */844{ rule_id : 'LANDMARK_12',845 last_updated : '2014-11-28',846 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,847 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,848 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,849 wcag_primary_id : '1.3.1',850 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],851 target_resources : ['footer', '[role="contentinfo"]'],852 primary_property : 'parent_landmark',853 resource_properties : ['role', 'tag_name', 'accessible_name'],854 language_dependency : "",855 validate : function (dom_cache, rule_result) {856857 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;858 var VISIBILITY = OpenAjax.a11y.VISIBILITY;859860 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;861 var landmark_elements_len = landmark_elements.length;862863 for (var i = 0; i < landmark_elements_len; i++ ) {864 var le = landmark_elements[i];865 var de = le.dom_element;866 var cs = de.computed_style;867868 if (le.landmark === 'contentinfo') {869870 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {871872 if (de.parent_landmark === null) {873 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [de.tag_name]);874 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', []);875 }876 else {877878 var de1 = de.parent_landmark.dom_element;879880 if (de1 && (de.body_element !== de1.body_element)) {881 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', [de.tag_name]);882 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', []);883 }884 else {885 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [de.tag_name, de.parent_landmark.landmark]);886 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [de.parent_landmark.landmark]);887 }888 }889890 }891 else {892 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);893 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);894 }895 }896 }897 } // end validate function898},899900/**901 * @object LANDMARK_13902 *903 * @desc Contentinfo landmark should only contain only search, region and navigation landmarks904 */905{ rule_id : 'LANDMARK_13',906 last_updated : '2014-11-28',907 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,908 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,909 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,910 wcag_primary_id : '1.3.1',911 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],912 target_resources : ['header', '[role="banner"]'],913 primary_property : 'accessible_name',914 resource_properties : ['role', 'tag_name', 'parent_landmark'],915 language_dependency : "",916 validate : function (dom_cache, rule_result) {917918 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;919 var VISIBILITY = OpenAjax.a11y.VISIBILITY;920921 function checkLandmarkChildren(landmark) {922923 var cces = landmark.child_cache_elements;924 var cces_len = cces.length;925 var fail_count = 0;926927 for (var i = 0; i < cces_len; i++) {928929 var cce = cces[i];930 var de = cce.dom_element;931 var cs = de.computed_style;932 landmark_count++;933934 if (!cce.landmark) continue;935936 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {937 if ((cce.landmark === 'navigation') ||938 (cce.landmark === 'region') ||939 (cce.landmark === 'search') ||940 (cce.landmark === 'application')) {941 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [de.role]);942 else rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [de.tag_name]);943 pass_list += ' ' + cce.landmark;944 }945 else {946 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [de.role]);947 else rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [de.tag_name]);948 fail_count++;949 fail_list += ' ' + cce.landmark;950 }951 if (cce.landmark) fail_count += checkLandmarkChildren(cce);952 }953 else {954 rule_result.addResult(TEST_RESULT.HIDDEN, cce, 'ELEMENT_HIDDEN_1', [de.tag_name]);955 }956 }957958 return fail_count;959 }960961 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;962 var landmark_elements_len = landmark_elements.length;963 var fail_count = 0;964965 for (var i = 0; i < landmark_elements_len; i++ ) {966 var le = landmark_elements[i];967 var de = le.dom_element;968 var cs = de.computed_style;969970 if (le.landmark === 'contentinfo') {971972 var fail_list = '';973 var pass_list = '';974 var landmark_count = 0;975976 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {977 fail_count = checkLandmarkChildren(le);978979 if (fail_count === 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [fail_list.toUpperCase()]);980 else if (fail_count > 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_3', [fail_count, fail_list.toUpperCase()]);981 else if (landmark_count === 0) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);982 else if (landmark_count === 1) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', [pass_list.toUpperCase()]);983 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', [landmark_count, pass_list.toUpperCase()]);984 }985 else {986 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);987 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', [de.tag_name]);988 }989 }990 }991 } // end validate function992},993994/**995 * @object LANDMARK_14996 *997 * @desc Search landmark should only contain only region landmarks998 */999{ rule_id : 'LANDMARK_14',1000 last_updated : '2014-11-28',1001 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1002 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1003 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1004 wcag_primary_id : '1.3.1',1005 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1006 target_resources : ['[role="search"]'],1007 primary_property : 'parent_landmark',1008 resource_properties : ['role', 'tag_name', 'accessible_name'],1009 language_dependency : "",1010 validate : function (dom_cache, rule_result) {10111012 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1013 var VISIBILITY = OpenAjax.a11y.VISIBILITY;10141015 function checkLandmarkChildren(landmark) {10161017 var cces = landmark.child_cache_elements;1018 var cces_len = cces.length;1019 var fail_count = 0;10201021 for (var i = 0; i < cces_len; i++) {10221023 var cce = cces[i];1024 var de = cce.dom_element;1025 var cs = de.computed_style;10261027 if (!cce.landmark) continue;10281029 landmark_count++;10301031 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {1032 if ((cce.landmark === 'region') ||1033 (cce.landmark === 'application')) {1034 rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [cce.landmark]);10351036 pass_list += ' ' + cce.landmark;1037 }1038 else {1039 rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [cce.landmark]);1040 fail_count++;1041 fail_list += ' ' + cce.landmark;1042 }1043 fail_count += checkLandmarkChildren(cce);1044 }1045 else {1046 rule_result.addResult(TEST_RESULT.HIDDEN, cce, 'ELEMENT_HIDDEN_2', [de.tag_name, de.landmark]);1047 }1048 }10491050 return fail_count;1051 }105210531054 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1055 var landmark_elements_len = landmark_elements.length;1056 var fail_count = 0;10571058// OpenAjax.a11y.logger.debug(" LANDMARK 14 Rule");10591060 for (var i = 0; i < landmark_elements_len; i++ ) {10611062 var le = landmark_elements[i];1063 var de = le.dom_element;1064 var cs = de.computed_style;10651066 if (le.landmark === 'search') {10671068 var fail_list = '';1069 var pass_list = '';1070 var landmark_count = 0;107110721073 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {1074 fail_count = checkLandmarkChildren(le);10751076 if (fail_count === 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [fail_list.toUpperCase()]);1077 else if (fail_count > 1) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_3', [fail_count, fail_list.toUpperCase()]);1078 else if (landmark_count === 0) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);1079 else if (landmark_count === 1) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', [pass_list.toUpperCase()]);1080 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', [landmark_count, pass_list.toUpperCase()]);10811082 }1083 else {1084 rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);1085 }1086 }1087 }1088 } // end validate function1089},10901091/**1092 * @object LANDMARK_151093 *1094 * @desc Form landmark should only contain only region landmarks1095 */1096{ rule_id : 'LANDMARK_15',1097 last_updated : '2014-11-28',1098 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1099 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1100 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1101 wcag_primary_id : '1.3.1',1102 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1103 target_resources : ['[role="form"]'],1104 primary_property : 'parent_landmark',1105 resource_properties : ['role', 'tag_name', 'accessible_name'],1106 language_dependency : "",1107 validate : function (dom_cache, rule_result) {11081109 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1110 var VISIBILITY = OpenAjax.a11y.VISIBILITY;11111112 function checkLandmarkChildren(landmark) {11131114 var cces = landmark.child_cache_elements;1115 var cces_len = cces.length;1116 var fail_count = 0;11171118 for (var i = 0; i < cces_len; i++) {11191120 var cce = cces[i];1121 var de = cce.dom_element;1122 var cs = de.computed_style;11231124 if (!cce.landmark) continue;11251126 landmark_count++;11271128 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {1129 if ((cce.landmark === 'region') ||1130 (cce.landmark === 'application')) {1131 rule_result.addResult(TEST_RESULT.PASS, cce, 'ELEMENT_PASS_1', [cce.landmark]);1132 }1133 else {1134 rule_result.addResult(TEST_RESULT.FAIL, cce, 'ELEMENT_FAIL_1', [cce.landmark]);1135 fail_count++;1136 }1137 fail_count += checkLandmarkChildren(cce);1138 }1139 else {1140 rule_result.addResult(TEST_RESULT.HIDDEN, cce, 'ELEMENT_HIDDEN_3', [cce.dom_element.tag_name, cce.landmark]);1141 }1142 }11431144 return fail_count;1145 }114611471148 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1149 var landmark_elements_len = landmark_elements.length;1150 var fail_count = 0;11511152 for (var i = 0; i < landmark_elements_len; i++ ) {11531154 var le = landmark_elements[i];1155 var de = le.dom_element;1156 var cs = de.computed_style;11571158 if (le.landmark === 'form') {11591160 var landmark_count = 0;11611162 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {1163 fail_count = checkLandmarkChildren(le);11641165// OpenAjax.a11y.logger.debug(" Search: " + fail_count);11661167 if (fail_count > 0) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', []);1168 else if (landmark_count === 0) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);1169 else if (landmark_count === 1) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', []);1170 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', [landmark_count]);1171 }1172 else {1173 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);1174 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);1175 }1176 }1177 }1178 } // end validate function1179},11801181/**1182 * @object LANDMARK_161183 *1184 * @desc Elements with the role=region must have accessible name to be considered a landmark1185 */1186{ rule_id : 'LANDMARK_16',1187 last_updated : '2014-11-28',1188 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1189 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1190 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1191 wcag_primary_id : '1.3.1',1192 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1193 target_resources : ['[role="region"]'],1194 primary_property : 'computed_label',1195 resource_properties : ['tag_name', 'role', 'computed_label_source', 'aria-label', 'aria-labelledby', 'title'],1196 language_dependency : "",1197 validate : function (dom_cache, rule_result) {11981199 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1200 var VISIBILITY = OpenAjax.a11y.VISIBILITY;12011202 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1203 var landmark_elements_len = landmark_elements.length;12041205 for (var i = 0; i < landmark_elements_len; i++ ) {12061207 var le = landmark_elements[i];1208 var de = le.dom_element;1209 var cs = de.computed_style;12101211 if (le.landmark === 'region') {12121213// OpenAjax.a11y.logger.debug(" Region: " + fail_count);12141215 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {12161217 if ((le.computed_label_source !== OpenAjax.a11y.SOURCE.NONE) &&1218 (le.computed_label.length > 0)) {1219 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [ de.tag_name]);1220 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', []);1221 }1222 else {1223 if (de.has_role) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, le, 'ELEMENT_MC_1', [de.tag_name]);1224 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, le, 'ELEMENT_MC_2', []);1225 }1226 }1227 else {1228 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);1229 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);1230 }1231 }1232 }12331234 var section_elements = dom_cache.headings_landmarks_cache.all_section_elements;1235 var section_elements_len = section_elements.length;12361237 for (i = 0; i < section_elements_len; i++ ) {12381239 le = section_elements[i];1240 de = le.dom_element;1241 cs = de.computed_style;12421243// OpenAjax.a11y.logger.debug("TAG NAME: " + de.tag_name);12441245 if (de.tag_name === 'section' &&1246 !de.has_role &&1247 !de.has_aria_labelledby &&1248 !de.has_aria_label &&1249 !de.has_title) {1250 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {1251 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, le, 'ELEMENT_MC_2', []);1252 }1253 else {1254 rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);1255 }1256 }1257 }12581259 } // end validate function1260},12611262/**1263 * @object LANDMARK_171264 *1265 * @desc Landmark must have unique labels1266 */12671268{ rule_id : 'LANDMARK_17',1269 last_updated : '2014-11-28',1270 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1271 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1272 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1273 wcag_primary_id : '1.3.1',1274 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1275 target_resources : ['main', 'nav', 'header', 'footer', 'section', 'aside', '[role="application"]','[role="banner"]', '[role="complementary"]','[role="contentinfo"]','[role="form"]','[role="main"]','[role="navigation"]','[role="region"]','[role="search"]'],1276 primary_property : 'computed_label',1277 resource_properties : ['tag_name', 'role', 'computed_label_source', 'aria-label', 'aria-labelledby', 'title'],1278 language_dependency : "",1279 validate : function (dom_cache, rule_result) {12801281 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1282 var VISIBILITY = OpenAjax.a11y.VISIBILITY;12831284 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1285 var landmark_elements_len = landmark_elements.length;12861287 var i;1288 var les = [];12891290 for (i = 0; i < landmark_elements_len; i++ ) {12911292 var le = landmark_elements[i];1293 var de = le.dom_element;1294 var cs = de.computed_style;12951296 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) les.push(le);1297 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name, de.landmark]);12981299 } // end loop13001301 // sort labels13021303 les = dom_cache.sortArrayOfObjects(les,'computed_label_for_comparison', true);13041305 for (i = 0; i < les.length; i++) {13061307 le = les[i];13081309 if (le.duplicate) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [le.computed_label, le.landmark]);1310 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [le.landmark]);13111312 }13131314 } // end validate function1315},13161317{ rule_id : 'LANDMARK_18',1318 last_updated : '2015-08-07',1319 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1320 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1321 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1322 wcag_primary_id : '1.3.1',1323 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1324 target_resources : ['main', 'nav', 'header', 'footer', 'section', 'aside', '[role="application"]','[role="banner"]', '[role="complementary"]','[role="contentinfo"]','[role="form"]','[role="main"]','[role="navigation"]','[role="region"]','[role="search"]'],1325 primary_property : 'computed_label',1326 resource_properties : ['tag_name', 'role', 'computed_label_source', 'aria-label', 'aria-labelledby', 'title'],1327 language_dependency : "",1328 validate : function (dom_cache, rule_result) {13291330 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1331 var VISIBILITY = OpenAjax.a11y.VISIBILITY;13321333 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1334 var landmark_elements_len = landmark_elements.length;13351336 for (var i = 0; i < landmark_elements_len; i++ ) {1337 var le = landmark_elements[i];1338 var de = le.dom_element;1339 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {1340 rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [le.landmark]);1341 }1342 else {1343 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, le, 'ELEMENT_MC_1', [le.landmark, le.computed_label]);1344 }1345 }1346 } // end validate function1347},13481349/**1350 * @object LANDMARK_191351 *1352 * @desc Complementary landmark must be a top level landmark1353 */1354{ rule_id : 'LANDMARK_19',1355 last_updated : '2014-11-28',1356 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1357 rule_category : OpenAjax.a11y.RULE_CATEGORIES.LANDMARKS,1358 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1359 wcag_primary_id : '1.3.1',1360 wcag_related_ids : ['2.4.1', '2.4.6', '2.4.10'],1361 target_resources : ['aside', '[role="complementary"]'],1362 primary_property : 'parent_landmark',1363 resource_properties : ['role', 'tag_name', 'accessible_name'],1364 language_dependency : "",1365 validate : function (dom_cache, rule_result) {13661367 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1368 var VISIBILITY = OpenAjax.a11y.VISIBILITY;13691370 var landmark_elements = dom_cache.headings_landmarks_cache.landmark_elements;1371 var landmark_elements_len = landmark_elements.length;13721373 for (var i = 0; i < landmark_elements_len; i++ ) {1374 var le = landmark_elements[i];1375 var de = le.dom_element;1376 var cs = de.computed_style;13771378 if (le.landmark === 'complementary') {13791380 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {13811382 if (!de.parent_landmark) {1383 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_1', [de.tag_name]);1384 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_3', []);1385 }1386 else {1387 var de1 = de.parent_landmark.dom_element;13881389 if (de1 && (de.body_element !== de1.body_element)) {1390 if (de.has_role) rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_2', [de.tag_name]);1391 else rule_result.addResult(TEST_RESULT.PASS, le, 'ELEMENT_PASS_4', []);1392 }1393 else {1394 if (de.has_role) rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_1', [de.tag_name, de.parent_landmark.landmark]);1395 else rule_result.addResult(TEST_RESULT.FAIL, le, 'ELEMENT_FAIL_2', [de.parent_landmark.landmark]);1396 }1397 }1398 }1399 else {1400 if (de.has_role) rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_1', [de.tag_name]);1401 else rule_result.addResult(TEST_RESULT.HIDDEN, le, 'ELEMENT_HIDDEN_2', []);1402 }1403 }1404 }1405 } // end validate function1406}1407 ...

Full Screen

Full Screen

rules_widgets.js

Source:rules_widgets.js Github

copy

Full Screen

1/**2 * Copyright 2011-2018 OpenAjax Alliance3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617// import {OpenAjax} from '../openajax_a11y_constants.js';1819/* ---------------------------------------------------------------- */20/* OpenAjax Alliance Control Rules */21/* ---------------------------------------------------------------- */2223OpenAjax.a11y.RuleManager.addRulesFromJSON([2425/**26 * @object WIDGET_127 *28 * @desc ARIA Widgets must have accessible names29 */3031{ rule_id : 'WIDGET_1',32 last_updated : '2021-07-07',33 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,34 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,35 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,36 wcag_primary_id : '4.1.2',37 wcag_related_ids : ['1.3.1', '3.3.2'],38 target_resources : ['[role="widget"]'],39 primary_property : 'accessible_name',40 resource_properties : ['accessible_description', 'computed_label_source'],41 language_dependency : "",42 validate : function (dom_cache, rule_result) {4344 var VISIBILITY = OpenAjax.a11y.VISIBILITY;45 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;4647 var widgets = dom_cache.controls_cache.widget_elements;48 var widgets_len = widgets.length;4950 // Check to see if valid cache reference51 if (widgets && widgets_len) {5253 for (var i = 0; i < widgets_len; i++) {54 var we = widgets[i];55 var de = we.dom_element;5657 if (de.is_widget) {5859 if (de.computed_style.is_visible_to_at == VISIBILITY.VISIBLE) {6061 if (we.computed_label && we.computed_label.length) {62 rule_result.addResult(TEST_RESULT.PASS, we, 'ELEMENT_PASS_1', [de.tag_name, de.role, we.computed_label]);63 }64 else {65 if (de.role_info.nameRequired) {66 rule_result.addResult(TEST_RESULT.FAIL, we, 'ELEMENT_FAIL_1', [de.tag_name, de.role]);67 } else {68 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, we, 'ELEMENT_MC_1', [de.tag_name, de.role]);69 }70 }71 }72 else {73 rule_result.addResult(TEST_RESULT.HIDDEN, we, 'ELEMENT_HIDDEN_1', [de.tag_name, de.role]);74 }75 }76 } // end loop77 }78 } // end validation function79},8081/**82 * @object WIDGET_283 *84 * @desc Elements with onClick event handlers event handlers need role85 */8687{ rule_id : 'WIDGET_2',88 last_updated : '2021-07-07',89 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,90 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,91 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,92 wcag_primary_id : '4.1.2',93 wcag_related_ids : ['1.3.1', '3.3.2'],94 target_resources : ['[onClick]'],95 primary_property : 'has_click',96 resource_properties : ['tag_name', 'role', 'is_widget'],97 language_dependency : "",98 validate : function (dom_cache, rule_result) {99100 function hasDecendantWidgetRole(dom_element) {101102 function checkChildren(list) {103104 if (!list) return false;105106 var flag = false;107108 for (var i = 0; (i < list.length) && !flag; i++) {109110 var de = list[i];111112 if (de.type != Node.ELEMENT_NODE) continue;113114 if (de.is_widget ||115 "input textarea button select".indexOf(de.tag_name) ||116 de.tag_name === "a" ||117 de.tag_name === "area") return true;118119 if (de.child_dom_elements.length) flag = checkChildren(de.child_dom_elements);120121 }122123 return flag;124125 }126127 return checkChildren(dom_element.child_dom_elements);128 }129130 var VISIBILITY = OpenAjax.a11y.VISIBILITY;131 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;132133 var dom_elements = dom_cache.element_cache.dom_elements;134 var dom_elements_len = dom_elements.length;135136 if (dom_elements && dom_elements_len) {137138 for (var i = 0; i < dom_elements_len; i++) {139 var de = dom_elements[i];140 var style = de.computed_style;141142 if (de.events.has_click &&143 ((de.tag_name !== 'body') &&144 (de.tag_name !== 'frame') &&145 (de.tag_name !== 'iframe') &&146 (de.tag_name !== 'embed') &&147 (de.tag_name !== 'object') &&148 (de.tag_name !== 'applet'))) {149150 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {151152 if (de.is_widget) {153 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de.tag_name]);154 }155 else {156 if ("input textarea button select".indexOf(de.tag_name) >= 0) {157 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_2', [de.tag_name]);158 }159 else {160 if ("a area".indexOf(de.tag_name) >= 0) {161 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_3', [de.tag_name]);162 }163 else {164 if (hasDecendantWidgetRole(de)) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_1', [de.tag_name]);165 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.tag_name]);166 }167 }168 }169 }170 else {171 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name]);172 }173 }174 } // end loop175 }176 } // end validation function177},178179/**180 * @object WIDGET_3181 *182 * @desc Elements with role values must have valid widget or landmark roles183 */184185{ rule_id : 'WIDGET_3',186 last_updated : '2021-07-07',187 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,188 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,189 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,190 wcag_primary_id : '4.1.2',191 wcag_related_ids : ['1.3.1', '3.3.2'],192 target_resources : ['[role]'],193 primary_property : 'role',194 resource_properties : [],195 language_dependency : "",196 validate : function (dom_cache, rule_result) {197198 var VISIBILITY = OpenAjax.a11y.VISIBILITY;199 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;200201 var elements_with_role = dom_cache.controls_cache.elements_with_role;202 var elements_with_role_len = elements_with_role.length;203204 if (elements_with_role && elements_with_role_len) {205206 for (var i = 0; i < elements_with_role_len; i++) {207 var de = elements_with_role[i];208 var style = de.computed_style;209210 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {211212 if (de.is_widget) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de.role]);213 else if (de.is_landmark) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_2', [de.role]);214 else if (de.is_live) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_3', [de.role]);215 else if (de.is_section) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_4', [de.role]);216 else if (de.is_abstract) rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.role]);217 else if (de.role.length === 0) rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', []);218 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_3', [de.role]);219 }220 else {221 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name, de.role]);222 }223 } // end loop224 }225 } // end validation function226},227228/**229 * @object WIDGET_4230 *231 * @desc Elements with ARIA attributes have valid values232 */233234{ rule_id : 'WIDGET_4',235 last_updated : '2021-07-07',236 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,237 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,238 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,239 wcag_primary_id : '4.1.2',240 wcag_related_ids : ['1.3.1', '3.3.2'],241 target_resources : ['[aria-atomic]',242 '[aria-autocomplete]',243 '[aria-busy]',244 '[aria-checked]',245 '[aria-colcount]',246 '[aria-colindex]',247 '[aria-colspan]',248 '[aria-current]',249 '[aria-disabled]',250 '[aria-dropeffect]',251 '[aria-expanded]',252 '[aria-grabbed]',253 '[aria-haspopup]',254 '[aria-hidden]',255 '[aria-invalid]',256 '[aria-label]',257 '[aria-labelledby]',258 '[aria-live]',259 '[aria-modal]',260 '[aria-multiline]',261 '[aria-multiselectable]',262 '[aria-orientation]',263 '[aria-pressed]',264 '[aria-readonly]',265 '[aria-relevant]',266 '[aria-required]',267 '[aria-rowcount]',268 '[aria-rowindex]',269 '[aria-rowspan]',270 '[aria-selected]',271 '[aria-sort]'],272 primary_property : '',273 resource_properties : [],274 language_dependency : "",275 validate : function (dom_cache, rule_result) {276277 function makeProp(label, value) {278279 var p = {};280281 p.label = label;282 p.value = value;283 p.description = "";284285 return p;286287 }288289 var VISIBILITY = OpenAjax.a11y.VISIBILITY;290 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;291292 var elements_with_aria_attributes = dom_cache.controls_cache.elements_with_aria_attributes;293 var elements_with_aria_attributes_len = elements_with_aria_attributes.length;294295 if (elements_with_aria_attributes && elements_with_aria_attributes_len) {296297 for (var i = 0; i < elements_with_aria_attributes_len; i++) {298 var de = elements_with_aria_attributes[i];299 var style = de.computed_style;300 var aria_attrs = de.aria_attributes;301 var aria_attrs_len = aria_attrs.length;302303 for (var j = 0; j < aria_attrs_len; j++) {304305 var attr = aria_attrs[j];306307 var prop = makeProp(attr.name, attr.value);308309 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {310311 if (attr.is_value_valid && attr.tokens) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [attr.name, attr.value], [prop]);312 else if (attr.is_value_valid) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_2', [attr.name, attr.value, attr.type], [prop]);313 else if (attr.type === 'nmtoken' || attr.type === 'boolean') rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [attr.name, attr.value, attr.tokens], [prop]);314 else if (attr.type === 'nmtokens') rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', [attr.name, attr.value, attr.tokens], [prop]);315 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_3', [attr.name, attr.value, attr.type], [prop]);316317 }318 else {319 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [attr.name, attr.value], [prop]);320 }321322 } // end loop323 } // end loop324 }325 } // end validation function326},327328/**329 * @object WIDGET_5330 *331 * @desc ARIA attributes must be defined332 */333334{ rule_id : 'WIDGET_5',335 last_updated : '2021-07-07',336 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,337 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,338 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,339 wcag_primary_id : '4.1.2',340 wcag_related_ids : ['1.3.1', '3.3.2'],341 target_resources : ['[aria-atomic]',342 '[aria-autocomplete]',343 '[aria-busy]',344 '[aria-checked]',345 '[aria-controls]',346 '[aria-describedby]',347 '[aria-disabled]',348 '[aria-dropeffect]',349 '[aria-expanded]',350 '[aria-flowto]',351 '[aria-grabbed]',352 '[aria-haspopup]',353 '[aria-hidden]',354 '[aria-invalid]',355 '[aria-label]',356 '[aria-labelledby]',357 '[aria-level]',358 '[aria-live]',359 '[aria-multiline]',360 '[aria-multiselectable]',361 '[aria-orientation]',362 '[aria-owns]',363 '[aria-pressed]',364 '[aria-readonly]',365 '[aria-relevant]',366 '[aria-required]',367 '[aria-selected]',368 '[aria-sort]',369 '[aria-valuemax]',370 '[aria-valuemin]',371 '[aria-valuenow]',372 '[aria-valuetext]'],373 primary_property : '',374 resource_properties : [],375 language_dependency : "",376 validate : function (dom_cache, rule_result) {377378 function makeProp(label, value) {379380 var p = {};381382 p.label = label;383 p.value = value;384 p.description = "";385386 return p;387388 }389390 var VISIBILITY = OpenAjax.a11y.VISIBILITY;391 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;392393 var elements_with_aria_attributes = dom_cache.controls_cache.elements_with_aria_attributes;394 var elements_with_aria_attributes_len = elements_with_aria_attributes.length;395396 if (elements_with_aria_attributes && elements_with_aria_attributes_len) {397398 for (var i = 0; i < elements_with_aria_attributes_len; i++) {399 var de = elements_with_aria_attributes[i];400 var style = de.computed_style;401 var aria_attrs = de.aria_attributes;402 var aria_attrs_len = aria_attrs.length;403404 for (var j = 0; j < aria_attrs_len; j++) {405406 var attr = aria_attrs[j];407408 var prop = makeProp(attr.name, attr.value);409410 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {411412 if (attr.is_valid_attribute) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [attr.name], [prop]);413 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [attr.name], [prop]);414415 }416 else {417 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [attr.name, attr.value], [prop]);418 }419420 } // end loop421 } // end loop422 }423 } // end validation function424},425426/**427 * @object WIDGET_6428 *429 * @desc Widgets must have required properties430 */431432{ rule_id : 'WIDGET_6',433 last_updated : '2021-07-07',434 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,435 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,436 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,437 wcag_primary_id : '4.1.2',438 wcag_related_ids : ['1.3.1', '3.3.2'],439 target_resources : ['[checkbox]',440 '[combobox]',441 '[menuitemcheckbox]',442 '[option]',443 '[scrollbar]',444 '[slider]',445 '[switch]'],446 primary_property : 'role',447 resource_properties : [],448 language_dependency : "",449 validate : function (dom_cache, rule_result) {450451 function getRequiredPropertiesAndValues(dom_element, required_props) {452453 var rps = [];454455 var attrs = dom_element.aria_attributes;456 var attrs_len = attrs.length;457458 for (var i = 0; i < required_props.length; i++) {459460 var prop = required_props[i];461462 var flag = false;463464 for (var j = 0; j <attrs_len; j++) {465 if (prop === attrs[j].name) {466 flag = true;467 break;468 }469 }470471 var rp = {};472 rp.label = prop;473 rp.description = "";474 rp.defined = flag;475476 if (flag) {477 rp.value = attrs[j].value;478 }479 else {480 rp.value = "undefined";481 }482483 rps.push(rp);484485 }486487 return rps;488489 }490491 function getPropsString(props) {492493 var str = "";494 var prop_max = props.length - 1;495496 for (var i = 0; i < props.length; i++ ) {497 str += props[i];498 if (i !== prop_max) str += ", ";499 }500501 return str;502503 }504505 var VISIBILITY = OpenAjax.a11y.VISIBILITY;506 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;507508 var widget_elements = dom_cache.controls_cache.widget_elements;509 var widget_elements_len = widget_elements.length;510511 if (widget_elements && widget_elements) {512513 for (var i = 0; i < widget_elements_len; i++) {514 var we = widget_elements[i];515 var de = we.dom_element;516 var style = de.computed_style;517518 var required_properties = de.role_info.requiredProps;519520 if (required_properties && required_properties.length) {521522 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {523524 var props_string = getPropsString(required_properties);525 var required_props = getRequiredPropertiesAndValues(de, required_properties);526527 var flag = true;528529 for (var j = 0; (j < required_props.length) && flag; j++) flag = flag && required_props[j].defined;530531 if (flag) rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de.role, props_string], required_props);532 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.role, props_string], required_props);533 }534 else {535 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.role]);536 }537 }538 } // end loop539 }540 } // end validation function541},542543/**544 * @object WIDGET_7545 *546 * @desc Widgets must have required owned elements547 */548549{ rule_id : 'WIDGET_7',550 last_updated : '2021-07-02',551 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,552 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,553 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,554 wcag_primary_id : '4.1.2',555 wcag_related_ids : ['1.3.1', '3.3.2'],556 target_resources : ['[feed]',557 '[grid]',558 '[list]',559 '[listbox]',560 '[menu]',561 '[menubar]',562 '[radiogroup]',563 '[row]',564 '[rowgroup]',565 '[table]',566 '[tablist]',567 '[tree]',568 '[treegrid]'],569 primary_property : 'role',570 resource_properties : ['aria_busy', 'aria_owns'],571 language_dependency : "",572 validate : function (dom_cache, rule_result) {573574575 function getRequiredChildRolesString(required_children) {576577 var str = "";578 var required_children_max = required_children.length - 1;579580 for (var i = 0; i < required_children.length; i++ ) {581 str += required_children[i];582 if (i !== required_children_max) str += ", ";583 }584585 return str;586587 }588589 var VISIBILITY = OpenAjax.a11y.VISIBILITY;590 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;591592 var widget_elements = dom_cache.controls_cache.widget_elements;593 var widget_elements_len = widget_elements.length;594595 if (widget_elements && widget_elements) {596597 for (var i = 0; i < widget_elements_len; i++) {598 var we = widget_elements[i];599 var de = we.dom_element;600 var style = de.computed_style;601602 var required_child_roles = de.role_info.requiredChildren;603604 if (required_child_roles && required_child_roles.length) {605606 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {607608 if (we.aria_busy) {609 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_2', [de.role]);610 } else {611 var flag = false;612613 for (var j = 0; (j < required_child_roles.length) && !flag; j++) {614 flag = we.hasRequiredChildRole(required_child_roles[j]);615 }616617 var required_child_roles_string = getRequiredChildRolesString(required_child_roles);618619 if (flag) {620 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de.role, required_child_roles_string]);621 } else {622 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.role, required_child_roles_string]);623 }624 }625 }626 else {627 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.role]);628 }629 }630 } // end loop631 }632 } // end validation function633},634635/**636 * @object WIDGET_8637 *638 * @desc Widgets must have required parent roles639 */640641{ rule_id : 'WIDGET_8',642 last_updated : '2021-07-07',643 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,644 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,645 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,646 wcag_primary_id : '4.1.2',647 wcag_related_ids : ['1.3.1', '3.3.2'],648 target_resources : [ "caption",649 "cell",650 "columnheader",651 "gridcell",652 "listitem",653 "menuitem",654 "menuitemcheckbox",655 "menuitemradio",656 "option",657 "row",658 "rowgroup",659 "rowheader",660 "tab",661 "treeitem"662 ],663 primary_property : 'role',664 resource_properties : ['aria_owns'],665 language_dependency : "",666 validate : function (dom_cache, rule_result) {667668669 function getRequiredRolesString(required_roles) {670671 var str = "";672 var required_roles_max = required_roles.length - 1;673674 for (var i = 0; i < required_roles.length; i++ ) {675 if (i > 0) {676 if ( i === required_roles_max) {677 str += "@ or @" + required_roles[i];678 } else {679 str += "@, @" + required_roles[i];680;681 }682 } else {683 str += required_roles[i];684 }685 }686687 return str;688689 }690691 var VISIBILITY = OpenAjax.a11y.VISIBILITY;692 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;693694 var widget_elements = dom_cache.controls_cache.widget_elements;695 var widget_elements_len = widget_elements.length;696697 if (widget_elements && widget_elements) {698699 for (var i = 0; i < widget_elements_len; i++) {700 var we = widget_elements[i];701 var de = we.dom_element;702 var style = de.computed_style;703704 var required_parent_roles = de.role_info.requiredParents;705706 if (required_parent_roles && required_parent_roles.length) {707708 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {709710 var flag = false;711712 for (var j = 0; (j < required_parent_roles.length) && !flag; j++) {713 var role = required_parent_roles[j];714 flag = we.isOwnedByRole(role);715 }716717 var required_roles_string = getRequiredRolesString(required_parent_roles);718719 if (flag) {720 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de.role, role]);721 } else {722 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [required_roles_string, de.role]);723 }724 }725 else {726 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.role]);727 }728 }729 } // end loop730 }731 } // end validation function732},733/**734 * @object WIDGET_9735 *736 * @desc Widgets cannot be owned by more than one widget737 */738739{ rule_id : 'WIDGET_9',740 last_updated : '2021-07-07',741 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,742 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,743 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,744 wcag_primary_id : '4.1.2',745 wcag_related_ids : ['1.3.1', '3.3.2'],746 target_resources : ['[aria-owns]'],747 primary_property : 'is_owned',748 resource_properties : ['owner_controls'],749 language_dependency : "",750 validate : function (dom_cache, rule_result) {751752 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;753754 var dom_elements = dom_cache.element_cache.dom_elements;755 var dom_elements_len = dom_elements.length;756 var we;757758 for (var i = 0; i < dom_elements_len; i++) {759 var de = dom_elements[i];760761 if (de.owned_by.length === 1) {762 we = de.owned_by[0];763 rule_result.addResult(TEST_RESULT.PASS, we, 'ELEMENT_PASS_1', [we, de]);764 } else {765 if (de.owned_by.length > 1) {766 for (var j = 0; j < de.owned_by.length; j += 1) {767 we = de.owned_by[j];768 rule_result.addResult(TEST_RESULT.FAIL, we, 'ELEMENT_FAIL_1', [we, de]);769 } // end loop770 }771 }772 } // end loop773774 } // end validation function775},776777/**778 * @object WIDGET_10779 *780 * @desc Range widgets with ariavaluenow mut be in range of aria-valuemin and aria-valuemax781 */782783{ rule_id : 'WIDGET_10',784 last_updated : '2021-07-07',785 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,786 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,787 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,788 wcag_primary_id : '4.1.2',789 wcag_related_ids : ['1.3.1', '3.3.2'],790 target_resources : ['[role="meter"]',791 '[role="progress"]',792 '[role="scrollbar"]',793 '[role="slider"]',794 '[role="spinbutton"]'],795 primary_property : '',796 resource_properties : ['aria-valuemin', 'aria-valuenow', 'aria-valuemax'],797 language_dependency : "",798 validate : function (dom_cache, rule_result) {799800 var VISIBILITY = OpenAjax.a11y.VISIBILITY;801 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;802803 var dom_elements = dom_cache.element_cache.dom_elements;804 var dom_elements_len = dom_elements.length;805806 if (dom_elements && dom_elements) {807808 for (var i = 0; i < dom_elements_len; i++) {809 var de = dom_elements[i];810 var style = de.computed_style;811812 if (de.is_range) {813814 if (style.is_visible_to_at === VISIBILITY.VISIBLE) {815816 var is_value_required = !('progressbar spinbutton'.indexOf(de.role) >= 0);817818 var valuetext = de.getAttributeValue('aria-valuetext');819 var is_valuetext_valid = de.isAttributeValueValid('aria-valuetext', valuetext);820821 var min = de.getAttributeValue('aria-valuemin');822 var is_min_valid = de.isAttributeValueValid('aria-valuemin', min);823824 var max = de.getAttributeValue('aria-valuemax');825 var is_max_valid = de.isAttributeValueValid('aria-valuemax', max);826827 var value = de.getAttributeValue('aria-valuenow');828 var is_value_valid = de.isAttributeValueValid('aria-valuenow', value);829830 if (is_valuetext_valid) {831 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_1', [de, valuetext]);832 } else {833 if (is_value_valid) {834 if (is_max_valid && is_min_valid) {835 if (min < max) {836 if ((min <= value) && (value <= max)) {837 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_2', [de, value, min, max]);838 } else {839 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [value, min, max]);840 }841 } else {842 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', [min, max]);843 }844 } else {845 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_3', [de, min, max]);846 }847 } else {848 if (is_value_required) {849 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_4', [de]);850 } else {851 rule_result.addResult(TEST_RESULT.PASS, de, 'ELEMENT_PASS_3', [de]);852 }853 }854 }855 } else {856 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de]);857 }858 }859 } // end loop860 }861 } // end validation function862},863864/**865 * @object WIDGET_11866 *867 * @desc Elements with mouse down, mouse move and mouse up events must have roles868 */869870{ rule_id : 'WIDGET_11',871 last_updated : '2021-07-07',872 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,873 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,874 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP3,875 wcag_primary_id : '4.1.2',876 wcag_related_ids : ['1.3.1', '3.3.2'],877 target_resources : ['[onmousedown]', '[onmouseup]', '[onmousemove]', '[onkeydown]', '[onkeyup]', '[onkeypress]', '[onclick]', '[ondbclick]', '[ondrag]', '[ondragstart]', '[ondragend]', '[ondragover]', '[onenter]', '[ondragleave]', '[ondrop]'],878 primary_property : '',879 resource_properties : [],880 language_dependency : "",881 validate : function (dom_cache, rule_result) {882883 function getUIEvents(dom_element) {884885 var events = dom_element.getMouseEvents();886 events += dom_element.getClickEvents();887 events += dom_element.getDragEvents();888 events += dom_element.getKeyboardEvents();889890 return events;891 }892893 var VISIBILITY = OpenAjax.a11y.VISIBILITY;894 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;895896 var dom_elements_with_events = dom_cache.controls_cache.elements_with_events;897 var dom_elements_with_events_len = dom_elements_with_events.length;898899 if (dom_elements_with_events_len) {900901 for (var i = 0; i < dom_elements_with_events_len; i++) {902 var de = dom_elements_with_events[i];903904 var style = de.computed_style;905 var events = getUIEvents(de);906907 if (events.length &&908 (de.tag_name !== 'embed') &&909 (de.tag_name !== 'applet') &&910 (de.tag_name !== 'object') &&911 (de.tag_name !== 'video') &&912 (de.tag_name !== 'audio')) {913914 if (style.is_visible_to_at === VISIBILITY.VISIBLE) {915916 if (de.is_widget) {917 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MANUAL_CHECK_1', [de.role, events]);918 }919 else {920 if (de.is_interactive) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MANUAL_CHECK_2', [de.tag_name, events]);921 else if (de.containsInteractiveElements()) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MANUAL_CHECK_3', [de.tag_name, events]);922 else rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.tag_name, events]);923 }924 }925 else {926 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name]);927 }928 }929 } // end loop930 }931 } // end validation function932},933/**934 * @object WIDGET_12935 *936 * @desc Element with widget role label should describe the purpose of the widget937 *938 */939940{ rule_id : 'WIDGET_12',941 last_updated : '2015-08-10',942 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,943 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,944 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,945 wcag_primary_id : '2.4.6',946 wcag_related_ids : ['1.3.1', '3.3.2'],947 target_resources : ['[role="widget"]'],948 primary_property : 'accessible_name',949 resource_properties : ['accessible_description', 'computed_label_source'],950 language_dependency : "",951 validate : function (dom_cache, rule_result) {952953 var VISIBILITY = OpenAjax.a11y.VISIBILITY;954 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;955956 var widgets = dom_cache.controls_cache.widget_elements;957 var widgets_len = widgets.length;958959 // Check to see if valid cache reference960 if (widgets && widgets_len) {961962 for (var i = 0; i < widgets_len; i++) {963 var we = widgets[i];964 var de = we.dom_element;965966 if (de.is_widget) {967968 if (de.computed_style.is_visible_to_at == VISIBILITY.VISIBLE) {969970 if (we.computed_label && we.computed_label.length) {971 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, we, 'ELEMENT_MC_1', [we.computed_label, de.tag_name, de.role]);972 }973 else {974 if (!de.role_info.nameRequired) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, we, 'ELEMENT_MC_2', [de.tag_name, de.role]);975 else rule_result.addResult(TEST_RESULT.FAIL, we, 'ELEMENT_FAIL_1', [de.tag_name, de.role]);976 }977 }978 else {979 rule_result.addResult(TEST_RESULT.HIDDEN, we, 'ELEMENT_HIDDEN_1', [de.tag_name, de.role]);980 }981 }982 } // end loop983 }984 } // end validation function985},986987/**988 * @object WIDGET_13989 *990 * @desc Roles that prohibit accessible names991 */992993{ rule_id : 'WIDGET_13',994 last_updated : '2021-07-07',995 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,996 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,997 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,998 wcag_primary_id : '4.1.2',999 wcag_related_ids : ['2.4.6'],1000 target_resources : [ "caption",1001 "code",1002 "deletion",1003 "emphasis",1004 "generic",1005 "insertion",1006 "none",1007 "paragraph",1008 "presentation",1009 "strong",1010 "subscript",1011 "superscript"],1012 primary_property : '',1013 resource_properties : [],1014 language_dependency : "",1015 validate : function (dom_cache, rule_result) {101610171018 var VISIBILITY = OpenAjax.a11y.VISIBILITY;1019 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;10201021 var dom_elements = dom_cache.element_cache.dom_elements;1022 var dom_elements_len = dom_elements.length;10231024 for (var i = 0; i < dom_elements_len; i++) {1025 var de = dom_elements[i];1026 var style = de.computed_style;1027 var implicit_role = '';10281029 if (de.element_aria_info) {1030 implicit_role = de.element_aria_info.defaultRole;1031 }10321033 if (de.has_aria_label || de.has_aria_labelledby) {10341035 if (de.role && OpenAjax.a11y.aria.designPatterns[de.role].nameProhibited) {1036 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {1037 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [de.tag_name, de.role]);1038 } else {1039 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name, de.role]);1040 }1041 } else {1042 if (!de.role && implicit_role && OpenAjax.a11y.aria.designPatterns[implicit_role].nameProhibited) {1043 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {1044 if (de.tag_name === 'a') {1045 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_3', []);1046 } else {1047 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', [de.tag_name]);1048 }1049 } else {1050 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_2', [de.tag_name]);1051 }1052 }1053 }1054 } // end loop1055 }1056 } // end validation function1057},10581059/**1060 * @object WIDGET_141061 *1062 * @desc Verify live regions are being used properly1063 */1064{ rule_id : 'WIDGET_14',1065 last_updated : '2017-02-08',1066 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1067 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,1068 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1069 wcag_primary_id : '4.1.2',1070 wcag_related_ids : [],1071 target_resources : ['[role="alert"]','[role="log"]','[role="status"]','[aria-live]'],1072 primary_property : 'is_live',1073 resource_properties : ['is_live', 'role','aria_live', 'aria_atomic', 'aria_busy', 'aria_relavent'],1074 language_dependency : "",1075 validate : function (dom_cache, rule_result) {10761077 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;1078 var VISIBILITY = OpenAjax.a11y.VISIBILITY;10791080 var dom_elements = dom_cache.element_cache.dom_elements;1081 var dom_elements_len = dom_elements.length;108210831084 for (var i = 0; i < dom_elements_len; i++ ) {10851086 var de =dom_elements[i];10871088 if (de.type != Node.ELEMENT_NODE || !de.is_live || (de.aria_live === 'off')) continue;10891090 var has_failure = false;10911092 var has_live_role = de.role && de.role.length && (" alert log status".indexOf(de.role) > 0);109310941095 if (de.has_aria_live) {1096 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {1097 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name, de.aria_live]);1098 }1099 else {1100 if (has_live_role) {11011102 switch (de.role) {11031104 case 'alert':1105 if (de.aria_live === 'polite') {1106 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', ['polite', 'assertive', de.role]);1107 has_failure = true;1108 }1109 break;11101111 case 'log':1112 case 'status':1113 if (de.aria_live === 'assertive') {1114 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', ['assertive', 'polite', de.role]);1115 has_failure = true;1116 }1117 break;11181119 default:1120 break;11211122 }1123 }1124 else {1125 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_1', [de.tag_name, de.aria_live]);1126 }1127 }1128 }11291130 if (de.has_aria_atomic && has_live_role && (de.role === 'alert' || de.role === 'status')) {11311132 if (de.aria_atomic === 'false') {1133 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', [de.role]);1134 has_failure = true;1135 }11361137 }11381139 if(has_live_role && !has_failure) {11401141 switch (de.role) {11421143 case 'alert':1144 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {1145 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_2', [de.tag_name, de.role]);1146 }1147 else {1148 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_2', [de.tag_name]);1149 }1150 break;11511152 case 'log':1153 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {1154 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_2', [de.tag_name, de.role]);1155 }1156 else {1157 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_3', [de.tag_name]);1158 }1159 break;11601161 case 'status':1162 if (de.computed_style.is_visible_to_at === VISIBILITY.HIDDEN) {1163 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_2', [de.tag_name, de.role]);1164 }1165 else {1166 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_4', [de.tag_name]);1167 }1168 break;11691170 default:1171 break;1172 }1173 }1174 }1175 } // end validation function1176},11771178/**1179 * @object WIDGET_151180 *1181 * @desc Roles with deprecated ARIA attributes1182 */1183{ rule_id : 'WIDGET_15',1184 last_updated : '2021-08-10',1185 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1186 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,1187 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1188 wcag_primary_id : '4.1.1',1189 wcag_related_ids : ['4.1.2'],1190 target_resources : [1191 "alert",1192 "alertdialog",1193 "article",1194 "banner",1195 "blockquote",1196 "button",1197 "caption",1198 "cell",1199 "checkbox",1200 "code",1201 "command",1202 "complementary",1203 "composite",1204 "contentinfo",1205 "definition",1206 "deletion",1207 "dialog",1208 "directory",1209 "document",1210 "emphasis",1211 "feed",1212 "figure",1213 "form",1214 "generic",1215 "grid",1216 "group",1217 "heading",1218 "img",1219 "input",1220 "insertion",1221 "landmark",1222 "link",1223 "list",1224 "listbox",1225 "listitem",1226 "log",1227 "main",1228 "marquee",1229 "math",1230 "meter",1231 "menu",1232 "menubar",1233 "menuitem",1234 "menuitemcheckbox",1235 "menuitemradio",1236 "navigation",1237 "note",1238 "option",1239 "paragraph",1240 "presentation",1241 "progressbar",1242 "radio",1243 "radiogroup",1244 "range",1245 "region",1246 "row",1247 "rowgroup",1248 "scrollbar",1249 "search",1250 "section",1251 "sectionhead",1252 "select",1253 "separator",1254 "spinbutton",1255 "status",1256 "strong",1257 "structure",1258 "subscript",1259 "superscript",1260 "switch",1261 "tab",1262 "table",1263 "tablist",1264 "tabpanel",1265 "term",1266 "time",1267 "timer",1268 "toolbar",1269 "tooltip",1270 "tree",1271 "treegrid",1272 "treeitem",1273 "widget",1274 "window"1275 ],1276 primary_property : 'role',1277 resource_properties : [1278 "aria-disabled",1279 "aria-errormessage",1280 "aria-haspopup",1281 "aria-invalid",1282 "aria-checked",1283 "aria-selected"1284 ],1285 language_dependency : "",1286 validate : function (dom_cache, rule_result) {12871288 var VISIBILITY = OpenAjax.a11y.VISIBILITY;1289 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;12901291 var dom_elements = dom_cache.element_cache.dom_elements;1292 var dom_elements_len = dom_elements.length;12931294 for (var i = 0; i < dom_elements_len; i++) {1295 var de = dom_elements[i];1296 var style = de.computed_style;1297 var role = de.role;1298 var implicit_role = '';1299 var deprecatedProps = [];13001301 if (!de.has_role && de.element_aria_info) {1302 implicit_role = de.element_aria_info.defaultRole;1303 }13041305 if (de.has_role && OpenAjax.a11y.aria.designPatterns[role]) {1306 deprecatedProps = OpenAjax.a11y.aria.designPatterns[role].deprecatedProps;1307 } else {1308 if (implicit_role && OpenAjax.a11y.aria.designPatterns[implicit_role]) {1309 deprecatedProps = OpenAjax.a11y.aria.designPatterns[implicit_role].deprecatedProps;1310 }1311 }13121313 if (deprecatedProps.length) {1314 for (var j = 0; j < deprecatedProps.length; j += 1) {1315 var prop = deprecatedProps[j];13161317 if (de.node.hasAttribute(prop)) {13181319 if (role) {1320 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {1321 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_1', [prop, de.tag_name, role]);1322 } else {1323 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [prop, de.tag_name, role]);1324 }1325 } else {1326 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {1327 rule_result.addResult(TEST_RESULT.FAIL, de, 'ELEMENT_FAIL_2', [prop, de.tag_name, implicit_role]);1328 } else {1329 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_2', [prop, de.tag_name, implicit_role]);1330 }1331 }1332 }1333 }1334 }1335 }1336 } // end validation function1337},13381339/**1340 * @object WIDGET_161341 *1342 * @desc Web compnents require manual check1343 */1344{ rule_id : 'WIDGET_16',1345 last_updated : '2021-09-12',1346 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,1347 rule_category : OpenAjax.a11y.RULE_CATEGORIES.WIDGETS_SCRIPTS,1348 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP2,1349 wcag_primary_id : '2.1.1',1350 wcag_related_ids : ['1.1.1','1.4.1','1.4.3','1.4.4','2.1.2','2.2.1','2.2.2', '2.4.7','2.4.3','2.4.7','3.3.2'],1351 target_resources : ["Custom elements using web component APIs"],1352 primary_property : '',1353 resource_properties : [],1354 language_dependency : "",1355 validate : function (dom_cache, rule_result) {13561357 var VISIBILITY = OpenAjax.a11y.VISIBILITY;1358 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;13591360 var dom_elements = dom_cache.element_cache.dom_elements;1361 var dom_elements_len = dom_elements.length;13621363 for (var i = 0; i < dom_elements_len; i++) {1364 var de = dom_elements[i];1365 var style = de.computed_style;13661367 if (de.tag_name.indexOf('-') >= 0) {1368 if (style.is_visible_to_at == VISIBILITY.VISIBLE || style.is_visible_onscreen == VISIBILITY.VISIBLE ) {1369 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, de, 'ELEMENT_MC_1', [de.tag_name]);1370 } else {1371 rule_result.addResult(TEST_RESULT.HIDDEN, de, 'ELEMENT_HIDDEN_1', [de.tag_name]);1372 }1373 }1374 }1375 } // end validation function1376}13771378]);137913801381 ...

Full Screen

Full Screen

rules_video.js

Source:rules_video.js Github

copy

Full Screen

1/**2 * Copyright 2011-2018 OpenAjax Alliance3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617// import {OpenAjax} from '../openajax_a11y_constants.js';1819/* ---------------------------------------------------------------- */20/* OpenAjax Alliance Media Rules */21/* ---------------------------------------------------------------- */2223OpenAjax.a11y.RuleManager.addRulesFromJSON([2425/**26 * @object VIDEO_127 *28 * @desc Video elements used for prerecorded video only content using the video element must have text or audio description29 */3031{ rule_id : 'VIDEO_1',32 last_updated : '2014-11-28',33 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,34 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,35 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,36 wcag_primary_id : '1.2.1',37 wcag_related_ids : ['1.2.2', '1.2.4'],38 target_resources : ['video', 'track'],39 primary_property : '',40 resource_properties : ['controls', 'autoplay', 'name', 'type', 'src', 'label'],41 language_dependency : "",42 validate : function (dom_cache, rule_result) {4344 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;45 var VISIBILITY = OpenAjax.a11y.VISIBILITY;4647 var video_elements = dom_cache.media_cache.video_elements;48 var video_elements_len = video_elements.length;4950 for (var i = 0; i < video_elements_len; i++) {51 var ve = video_elements[i];52 var de = ve.dom_element;53 var cs = de.computed_style;5455 if ((cs.is_visible_to_at === VISIBILITY.VISIBLE) ||56 (ve.has_autoplay)) {57 if (ve.getTextTracks().length) rule_result.addResult(TEST_RESULT.PASS, ve, 'ELEMENT_PASS_1', []);58 else if (de.has_aria_describedby) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ve, 'ELEMENT_MC_1', []);59 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ve, 'ELEMENT_MC_2', []);60 }61 else {62 rule_result.addResult(TEST_RESULT.HIDDEN, ve, 'ELEMENT_HIDDEN_1', []);63 }64 }65 } // end validate function66},6768/**69 * @object VIDEO_270 *71 * @desc Video elements used for prerecorded video only content using the object element must have text or audio description72 */7374{ rule_id : 'VIDEO_2',75 last_updated : '2014-11-28',76 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,77 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,78 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,79 wcag_primary_id : '1.2.1',80 wcag_related_ids : ['1.2.2', '1.2.4'],81 target_resources : ['object', 'param'],82 primary_property : '',83 resource_properties : ['data', 'type', 'name', 'value', 'valuetype'],84 language_dependency : "",85 validate : function (dom_cache, rule_result) {8687 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;88 var VISIBILITY = OpenAjax.a11y.VISIBILITY;8990 var object_elements = dom_cache.media_cache.object_elements;91 var object_elements_len = object_elements.length;9293 for (var i = 0; i < object_elements_len; i++) {94 var oe = object_elements[i];95 var de = oe.dom_element;96 var cs = de.computed_style;9798 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {99 if (oe.isTypeVideo()) {100 if (de.has_aria_describedby) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_1', []);101 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_2', []);102 }103 else {104 if (de.has_aria_describedby) rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_3', []);105 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_4', []);106 }107 }108 else {109 rule_result.addResult(TEST_RESULT.HIDDEN, oe, 'ELEMENT_HIDDEN_1', []);110 }111 }112 } // end validate function113},114115/**116 * @object VIDEO_3117 *118 * @desc Video elements used for prerecorded video only content using the embed element must have text or audio description119 */120121{ rule_id : 'VIDEO_3',122 last_updated : '2014-11-28',123 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,124 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,125 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,126 wcag_primary_id : '1.2.1',127 wcag_related_ids : ['1.2.2', '1.2.4'],128 target_resources : ['embed'],129 primary_property : '',130 resource_properties : ['src', 'type'],131 language_dependency : "",132 validate : function (dom_cache, rule_result) {133134 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;135 var VISIBILITY = OpenAjax.a11y.VISIBILITY;136137 var embed_elements = dom_cache.media_cache.embed_elements;138 var embed_elements_len = embed_elements.length;139140 for (var i = 0; i < embed_elements_len; i++) {141 var ee = embed_elements[i];142 var de = ee.dom_element;143 var cs = de.computed_style;144145 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {146 if (ee.isTypeVideo()) {147 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_1', []);148 }149 else {150 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_2', []);151 }152 }153 else {154 rule_result.addResult(TEST_RESULT.HIDDEN, ee, 'ELEMENT_HIDDEN_1', []);155 }156 }157 } // end validate function158},159160/**161 * @object VIDEO_4162 *163 * @desc Live and prerecorded video with synchronized audio (i.e. movie, lecture) using the video element must have captions164 */165166{ rule_id : 'VIDEO_4',167 last_updated : '2014-11-28',168 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,169 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,170 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,171 wcag_primary_id : '1.2.2',172 wcag_related_ids : ['1.2.4'],173 target_resources : ['video', 'track'],174 primary_property : '',175 resource_properties : ['controls', 'autoplay', 'name', 'type', 'src', 'label'],176 language_dependency : "",177 validate : function (dom_cache, rule_result) {178179 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;180 var VISIBILITY = OpenAjax.a11y.VISIBILITY;181182 var video_elements = dom_cache.media_cache.video_elements;183 var video_elements_len = video_elements.length;184185 for (var i = 0; i < video_elements_len; i++) {186 var ve = video_elements[i];187 var de = ve.dom_element;188 var cs = de.computed_style;189190 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {191 if (ve.hasCaptionTrack() || ve.hasSubtitleTrack()) rule_result.addResult(TEST_RESULT.PASS, ve, 'ELEMENT_PASS_1', []);192 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ve, 'ELEMENT_MC_1', []);193 }194 else {195 rule_result.addResult(TEST_RESULT.HIDDEN, ve, 'ELEMENT_HIDDEN_1', []);196 }197 }198 } // end validate function199},200201/**202 * @object VIDEO_5203 *204 * @desc Live and prerecorded video with synchronized audio (i.e. movie, lecture) using the object element must have captions205 */206207{ rule_id : 'VIDEO_5',208 last_updated : '2014-11-28',209 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,210 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,211 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,212 wcag_primary_id : '1.2.2',213 wcag_related_ids : ['1.2.4'],214 target_resources : ['object', 'param'],215 primary_property : '',216 resource_properties : ['data', 'type', 'name', 'value', 'valuetype'],217 language_dependency : "",218 validate : function (dom_cache, rule_result) {219220 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;221 var VISIBILITY = OpenAjax.a11y.VISIBILITY;222223 var object_elements = dom_cache.media_cache.object_elements;224 var object_elements_len = object_elements.length;225226 for (var i = 0; i < object_elements_len; i++) {227 var oe = object_elements[i];228 var de = oe.dom_element;229 var cs = de.computed_style;230231 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {232 if (oe.isTypeVideo()) {233 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_1', []);234 }235 else {236 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_2', []);237 }238 }239 else {240 rule_result.addResult(TEST_RESULT.HIDDEN, oe, 'ELEMENT_HIDDEN_1', []);241 }242 }243 } // end validate function244},245246/**247 * @object VIDEO_6248 *249 * @desc Live and prerecorded video with synchronized audio (i.e. movie, lecture) using the embed element must have captions250 */251252{ rule_id : 'VIDEO_6',253 last_updated : '2014-11-28',254 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,255 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,256 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,257 wcag_primary_id : '1.2.2',258 wcag_related_ids : ['1.2.1', '1.2.4'],259 target_resources : ['embed'],260 primary_property : '',261 resource_properties : ['src', 'type'],262 language_dependency : "",263 validate : function (dom_cache, rule_result) {264265 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;266 var VISIBILITY = OpenAjax.a11y.VISIBILITY;267268 var embed_elements = dom_cache.media_cache.embed_elements;269 var embed_elements_len = embed_elements.length;270271 for (var i = 0; i < embed_elements_len; i++) {272 var ee = embed_elements[i];273 var de = ee.dom_element;274 var cs = de.computed_style;275276 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {277 if (ee.isTypeVideo()) {278 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_1', []);279 }280 else {281 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_2', []);282 }283 }284 else {285 rule_result.addResult(TEST_RESULT.HIDDEN, ee, 'ELEMENT_HIDDEN_1', []);286 }287 }288 } // end validate function289},290291/**292 * @object VIDEO_7293 *294 * @desc Prerecorded video with synchronized audio (i.e. movie) using the video element must have audio description295 */296297{ rule_id : 'VIDEO_7',298 last_updated : '2014-11-28',299 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,300 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,301 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,302 wcag_primary_id : '1.2.3',303 wcag_related_ids : ['1.2.5'],304 target_resources : ['video', 'track'],305 primary_property : '',306 resource_properties : ['controls', 'autoplay', 'name', 'type', 'src', 'label'],307 language_dependency : "",308 validate : function (dom_cache, rule_result) {309310 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;311 var VISIBILITY = OpenAjax.a11y.VISIBILITY;312313 var video_elements = dom_cache.media_cache.video_elements;314 var video_elements_len = video_elements.length;315316 for (var i = 0; i < video_elements_len; i++) {317 var ve = video_elements[i];318 var de = ve.dom_element;319 var cs = de.computed_style;320321 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {322 if (ve.hasDescriptionTrack()) rule_result.addResult(TEST_RESULT.PASS, ve, 'ELEMENT_PASS_1', []);323 else rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ve, 'ELEMENT_MC_1', []);324 }325 else {326 rule_result.addResult(TEST_RESULT.HIDDEN, ve, 'ELEMENT_HIDDEN_1', []);327 }328 }329 } // end validate function330},331332/**333 * @object VIDEO_8334 *335 * @desc Prerecorded video with synchronized audio (i.e. movie) using the object element must have audio description336 */337338{ rule_id : 'VIDEO_8',339 last_updated : '2014-11-28',340 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,341 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,342 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,343 wcag_primary_id : '1.2.3',344 wcag_related_ids : ['1.2.1', '1.2.5'],345 target_resources : ['object', 'param'],346 primary_property : '',347 resource_properties : ['data', 'type', 'name', 'value', 'valuetype'],348 language_dependency : "",349 validate : function (dom_cache, rule_result) {350351 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;352 var VISIBILITY = OpenAjax.a11y.VISIBILITY;353354 var object_elements = dom_cache.media_cache.object_elements;355 var object_elements_len = object_elements.length;356357 for (var i = 0; i < object_elements_len; i++) {358 var oe = object_elements[i];359 var de = oe.dom_element;360 var cs = de.computed_style;361362 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {363 if (oe.isTypeVideo()) {364 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_1', []);365 }366 else {367 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, oe, 'ELEMENT_MC_2', []);368 }369 }370 else {371 rule_result.addResult(TEST_RESULT.HIDDEN, oe, 'ELEMENT_HIDDEN_1', []);372 }373 }374 } // end validate function375},376377/**378 * @object VIDEO_9379 *380 * @desc Prerecorded video with synchronized audio (i.e. movie) using the embed element must have audio description381 */382383{ rule_id : 'VIDEO_9',384 last_updated : '2014-11-28',385 rule_scope : OpenAjax.a11y.RULE_SCOPE.ELEMENT,386 rule_category : OpenAjax.a11y.RULE_CATEGORIES.AUDIO_VIDEO,387 rule_group : OpenAjax.a11y.RULE_GROUP.GROUP1,388 wcag_primary_id : '1.2.3',389 wcag_related_ids : ['1.2.1', '1.2.5'],390 target_resources : ['embed'],391 primary_property : '',392 resource_properties : ['src', 'type'],393 language_dependency : "",394 validate : function (dom_cache, rule_result) {395396 var TEST_RESULT = OpenAjax.a11y.TEST_RESULT;397 var VISIBILITY = OpenAjax.a11y.VISIBILITY;398399 var embed_elements = dom_cache.media_cache.embed_elements;400 var embed_elements_len = embed_elements.length;401402 for (var i = 0; i < embed_elements_len; i++) {403 var ee = embed_elements[i];404 var de = ee.dom_element;405 var cs = de.computed_style;406407 if (cs.is_visible_to_at === VISIBILITY.VISIBLE) {408 if (ee.isTypeVideo()) {409 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_1', []);410 }411 else {412 rule_result.addResult(TEST_RESULT.MANUAL_CHECK, ee, 'ELEMENT_MC_2', []);413 }414 }415 else {416 rule_result.addResult(TEST_RESULT.HIDDEN, ee, 'ELEMENT_HIDDEN_1', []);417 }418 }419 } // end validate function420}421 ...

Full Screen

Full Screen

TestCppNsImport.py

Source:TestCppNsImport.py Github

copy

Full Screen

1"""2Tests imported namespaces in C++.3"""4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8class TestCppNsImport(TestBase):9 mydir = TestBase.compute_mydir(__file__)10 def test_with_run_command(self):11 """Tests imported namespaces in C++."""12 self.build()13 # Get main source file14 src_file = os.path.join(self.getSourceDir(), "main.cpp")15 src_file_spec = lldb.SBFileSpec(src_file)16 self.assertTrue(src_file_spec.IsValid(), "Main source file")17 # Get the path of the executable18 exe_path = self.getBuildArtifact("a.out")19 # Load the executable20 target = self.dbg.CreateTarget(exe_path)21 self.assertTrue(target.IsValid(), VALID_TARGET)22 # Break on main function23 break_0 = target.BreakpointCreateBySourceRegex(24 "// break 0", src_file_spec)25 self.assertTrue(26 break_0.IsValid() and break_0.GetNumLocations() >= 1,27 VALID_BREAKPOINT)28 break_1 = target.BreakpointCreateBySourceRegex(29 "// break 1", src_file_spec)30 self.assertTrue(31 break_1.IsValid() and break_1.GetNumLocations() >= 1,32 VALID_BREAKPOINT)33 # Launch the process34 args = None35 env = None36 process = target.LaunchSimple(37 args, env, self.get_process_working_directory())38 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)39 # Get the thread of the process40 self.assertEqual(41 process.GetState(), lldb.eStateStopped,42 PROCESS_STOPPED)43 thread = lldbutil.get_stopped_thread(44 process, lldb.eStopReasonBreakpoint)45 # Get current fream of the thread at the breakpoint46 frame = thread.GetSelectedFrame()47 # Test imported namespaces48 test_result = frame.EvaluateExpression("n")49 self.assertTrue(50 test_result.IsValid() and test_result.GetValueAsSigned() == 1,51 "n = 1")52 test_result = frame.EvaluateExpression("N::n")53 self.assertTrue(54 test_result.IsValid() and test_result.GetValueAsSigned() == 1,55 "N::n = 1")56 test_result = frame.EvaluateExpression("nested")57 self.assertTrue(58 test_result.IsValid() and test_result.GetValueAsSigned() == 3,59 "nested = 3")60 test_result = frame.EvaluateExpression("anon")61 self.assertTrue(62 test_result.IsValid() and test_result.GetValueAsSigned() == 2,63 "anon = 2")64 test_result = frame.EvaluateExpression("global")65 self.assertTrue(66 test_result.IsValid() and test_result.GetValueAsSigned() == 4,67 "global = 4")68 test_result = frame.EvaluateExpression("fun_var")69 self.assertTrue(70 test_result.IsValid() and test_result.GetValueAsSigned() == 9,71 "fun_var = 9")72 test_result = frame.EvaluateExpression("Fun::fun_var")73 self.assertTrue(74 test_result.IsValid() and test_result.GetValueAsSigned() == 0,75 "Fun::fun_var = 0")76 test_result = frame.EvaluateExpression("not_imported")77 self.assertTrue(78 test_result.IsValid() and test_result.GetValueAsSigned() == 35,79 "not_imported = 35")80 # Currently there is no way to distinguish between "::imported" and "imported" in ClangExpressionDeclMap so this fails81 #test_result = frame.EvaluateExpression("::imported")82 #self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 89, "::imported = 89")83 test_result = frame.EvaluateExpression("Imported::imported")84 self.assertTrue(85 test_result.IsValid() and test_result.GetValueAsSigned() == 99,86 "Imported::imported = 99")87 test_result = frame.EvaluateExpression("imported")88 self.assertTrue(89 test_result.IsValid() and test_result.GetValueAsSigned() == 99,90 "imported = 99")91 test_result = frame.EvaluateExpression("single")92 self.assertTrue(93 test_result.IsValid() and test_result.GetValueAsSigned() == 3,94 "single = 3")95 # Continue to second breakpoint96 process.Continue()97 # Get the thread of the process98 self.assertEqual(99 process.GetState(), lldb.eStateStopped,100 PROCESS_STOPPED)101 thread = lldbutil.get_stopped_thread(102 process, lldb.eStopReasonBreakpoint)103 # Get current fream of the thread at the breakpoint104 frame = thread.GetSelectedFrame()105 # Test function inside namespace106 test_result = frame.EvaluateExpression("fun_var")107 self.assertTrue(108 test_result.IsValid() and test_result.GetValueAsSigned() == 5,...

Full Screen

Full Screen

TestCppChainedCalls.py

Source:TestCppChainedCalls.py Github

copy

Full Screen

1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5class TestCppChainedCalls(TestBase):6 mydir = TestBase.compute_mydir(__file__)7 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")8 def test_with_run_command(self):9 self.build()10 # Get main source file11 src_file = "main.cpp"12 src_file_spec = lldb.SBFileSpec(src_file)13 self.assertTrue(src_file_spec.IsValid(), "Main source file")14 # Get the path of the executable15 cwd = os.getcwd()16 exe_file = "a.out"17 exe_path = os.path.join(cwd, exe_file)18 # Load the executable19 target = self.dbg.CreateTarget(exe_path)20 self.assertTrue(target.IsValid(), VALID_TARGET)21 # Break on main function22 main_breakpoint = target.BreakpointCreateBySourceRegex(23 "break here", src_file_spec)24 self.assertTrue(25 main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1,26 VALID_BREAKPOINT)27 # Launch the process28 args = None29 env = None30 process = target.LaunchSimple(31 args, env, self.get_process_working_directory())32 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)33 # Get the thread of the process34 self.assertTrue(35 process.GetState() == lldb.eStateStopped,36 PROCESS_STOPPED)37 thread = lldbutil.get_stopped_thread(38 process, lldb.eStopReasonBreakpoint)39 # Get frame for current thread40 frame = thread.GetSelectedFrame()41 # Test chained calls42 test_result = frame.EvaluateExpression("get(set(true))")43 self.assertTrue(44 test_result.IsValid() and test_result.GetValue() == "true",45 "get(set(true)) = true")46 test_result = frame.EvaluateExpression("get(set(false))")47 self.assertTrue(48 test_result.IsValid() and test_result.GetValue() == "false",49 "get(set(false)) = false")50 test_result = frame.EvaluateExpression("get(t & f)")51 self.assertTrue(52 test_result.IsValid() and test_result.GetValue() == "false",53 "get(t & f) = false")54 test_result = frame.EvaluateExpression("get(f & t)")55 self.assertTrue(56 test_result.IsValid() and test_result.GetValue() == "false",57 "get(f & t) = false")58 test_result = frame.EvaluateExpression("get(t & t)")59 self.assertTrue(60 test_result.IsValid() and test_result.GetValue() == "true",61 "get(t & t) = true")62 test_result = frame.EvaluateExpression("get(f & f)")63 self.assertTrue(64 test_result.IsValid() and test_result.GetValue() == "false",65 "get(f & f) = false")66 test_result = frame.EvaluateExpression("get(t & f)")67 self.assertTrue(68 test_result.IsValid() and test_result.GetValue() == "false",69 "get(t & f) = false")70 test_result = frame.EvaluateExpression("get(f) && get(t)")71 self.assertTrue(72 test_result.IsValid() and test_result.GetValue() == "false",73 "get(f) && get(t) = false")74 test_result = frame.EvaluateExpression("get(f) && get(f)")75 self.assertTrue(76 test_result.IsValid() and test_result.GetValue() == "false",77 "get(f) && get(t) = false")78 test_result = frame.EvaluateExpression("get(t) && get(t)")79 self.assertTrue(80 test_result.IsValid() and test_result.GetValue() == "true",...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 wpt.testResult(data.data.testId, function(err, data) {7 if (err) {8 console.log(err);9 } else {10 console.log(data);11 }12 });13 }14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org');8 if (err) return console.error(err);9 console.log(data);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) return console.error(err);14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) return console.error(err);19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23 if (err) return console.error(err);24 console.log(data);25});26var wpt = require('webpagetest');27var wpt = new WebPageTest('www.webpagetest.org');28 if (err) return console.error(err);29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('API_KEY');3 if (err) console.log(err);4 else {5 test.testResult(data.data.testId, function(err, data) {6 if (err) console.log(err);7 else console.log(data);8 });9 }10});11{12 "data": {13 "median": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.test_result('wpt_test_1', function (err, data) {3 if (err) {4 console.log(err);5 }6 console.log(data);7});8{ statusCode: 200,9 { statusCode: 200,10 data: { testId: 'wpt_test_1', data: [Object] } } }11var wpt = require('wpt');12wpt.test_result('wpt_test_1', function (err, data) {13 if (err) {14 console.log(err);15 }16 console.log(data);17});18{ statusCode: 200,19 { statusCode: 200,20 data: { testId: 'wpt_test_1', data: [Object] } } }21var wpt = require('wpt');22wpt.test_result('wpt_test_1', function (err, data) {23 if (err) {24 console.log(err);25 }26 console.log(data);27});28{ statusCode: 200,29 { statusCode: 200,30 data: { testId: 'wpt_test_1', data: [Object] } } }31var wpt = require('wpt');32wpt.test_result('wpt_test_1', function (err, data) {33 if (err) {34 console.log(err);35 }36 console.log(data);37});38{ statusCode: 200,39 { statusCode: 200,40 data: { testId: 'wpt_test_1', data: [Object] } } }41var wpt = require('wpt');42wpt.test_result('wpt_test_1', function (err, data) {43 if (err) {44 console.log(err);45 }46 console.log(data);47});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful