Changeset 276680 in webkit
- Timestamp:
- Apr 27, 2021 4:53:42 PM (15 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/audit/non-minified-default-audits-expected.txt (added)
-
LayoutTests/inspector/audit/non-minified-default-audits.html (added)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/Scripts/combine-resources.pl (modified) (5 diffs)
-
Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl (modified) (8 diffs)
-
Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Main.html (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/NonMinified (added)
-
Source/WebInspectorUI/UserInterface/NonMinified/DefaultAudits.js (added)
-
Source/WebInspectorUI/UserInterface/Test.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r276677 r276680 1 2021-04-27 Patrick Angle <pangle@apple.com> 2 3 Web Inspector: Default Audits script are minified in release builds 4 https://bugs.webkit.org/show_bug.cgi?id=225009 5 6 Reviewed by BJ Burg. 7 8 Added test to check that whitespace is preserved in default audits. 9 10 * inspector/audit/non-minified-default-audits-expected.txt: Added. 11 * inspector/audit/non-minified-default-audits.html: Added. 12 1 13 2021-04-27 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Source/WebInspectorUI/ChangeLog
r276645 r276680 1 2021-04-27 Patrick Angle <pangle@apple.com> 2 3 Web Inspector: Default Audits script are minified in release builds 4 https://bugs.webkit.org/show_bug.cgi?id=225009 5 6 Reviewed by BJ Burg. 7 8 Covered by new test: 9 - inspector/audit/non-minified-default-audits.html 10 11 The default audits have been moved out of `AuditManager.js` and into a special `DefaultAudits.js` in the new 12 `NonMinified` directory, which contains JavaScript sources that should be included in `Main.js` and 13 `TestCombined.js`, but should not have whitespace stripped from their contents because the whitespace is 14 important to the script. For example, the source for the default audits are visible to the user, and therefore 15 we want to present well-formatted source in those contexts. 16 17 * Scripts/combine-resources.pl: 18 - Added `NonMinified` directory to list of default `inputDirectoryPattern` exceptions for combining resources. 19 - Added `--skip-concatenate-tag` so that we don't add tags for script we will eventually append to another script. 20 * Scripts/copy-user-interface-resources.pl: 21 - Handle `NonMinified` directory for sources that will be appended to Main.js, but should not be minified. 22 - Handle `NonMinified` directory for sources that will be appended to TestCombined.js. 23 (combineOrStripResourcesForWebKitAdditions): 24 - Drive-by fix for typo in combineOrStripResourcesForWebKitAdditions that caused errors to be emitted during builds. 25 * UserInterface/Controllers/AuditManager.js: 26 (WI.AuditManager.prototype._addDefaultTests): 27 (WI.AuditManager): 28 (WI.AuditManager.prototype._addDefaultTests.const.levelPass): Deleted. 29 (WI.AuditManager.prototype._addDefaultTests.const.levelWarn): Deleted. 30 (WI.AuditManager.prototype._addDefaultTests.const.levelFail): Deleted. 31 (WI.AuditManager.prototype._addDefaultTests.const.levelError): Deleted. 32 (WI.AuditManager.prototype._addDefaultTests.const.levelUnsupported): Deleted. 33 (WI.AuditManager.prototype._addDefaultTests.const.dataDOMNodes): Deleted. 34 (WI.AuditManager.prototype._addDefaultTests.const.dataDOMAttributes): Deleted. 35 (WI.AuditManager.prototype._addDefaultTests.const.dataErrors): Deleted. 36 (WI.AuditManager.prototype._addDefaultTests.const.dataCustom): Deleted. 37 (WI.AuditManager.prototype._addDefaultTests.const.getElementsByComputedRole): Deleted. 38 (WI.AuditManager.prototype._addDefaultTests.const.getActiveDescendant): Deleted. 39 (WI.AuditManager.prototype._addDefaultTests.const.getChildNodes): Deleted. 40 (WI.AuditManager.prototype._addDefaultTests.const.getComputedProperties): Deleted. 41 (WI.AuditManager.prototype._addDefaultTests.const.getControlledNodes): Deleted. 42 (WI.AuditManager.prototype._addDefaultTests.const.getFlowedNodes): Deleted. 43 (WI.AuditManager.prototype._addDefaultTests.const.getMouseEventNode): Deleted. 44 (WI.AuditManager.prototype._addDefaultTests.const.getOwnedNodes): Deleted. 45 (WI.AuditManager.prototype._addDefaultTests.const.getParentNode): Deleted. 46 (WI.AuditManager.prototype._addDefaultTests.const.getSelectedChildNodes): Deleted. 47 (WI.AuditManager.prototype._addDefaultTests.const.hasEventListeners): Deleted. 48 (WI.AuditManager.prototype._addDefaultTests.const.hasEventListenersClick): Deleted. 49 (WI.AuditManager.prototype._addDefaultTests.const.getResources): Deleted. 50 (WI.AuditManager.prototype._addDefaultTests.const.getResourceContent): Deleted. 51 (WI.AuditManager.prototype._addDefaultTests.const.unsupported): Deleted. 52 (WI.AuditManager.prototype._addDefaultTests.hasChildWithRole): Deleted. 53 (WI.AuditManager.prototype._addDefaultTests.const.testMenuRoleForRequiredChildren): Deleted. 54 (WI.AuditManager.prototype._addDefaultTests.const.testGridRoleForRequiredChildren): Deleted. 55 (WI.AuditManager.prototype._addDefaultTests.const.testForAriaLabelledBySpelling): Deleted. 56 (WI.AuditManager.prototype._addDefaultTests.const.testForMultipleBanners): Deleted. 57 (WI.AuditManager.prototype._addDefaultTests.const.testForLinkLabels): Deleted. 58 (WI.AuditManager.prototype._addDefaultTests.const.testRowGroupRoleForRequiredChildren): Deleted. 59 (WI.AuditManager.prototype._addDefaultTests.const.testTableRoleForRequiredChildren): Deleted. 60 (WI.AuditManager.prototype._addDefaultTests.const.testForMultipleLiveRegions): Deleted. 61 (WI.AuditManager.prototype._addDefaultTests.const.testListBoxRoleForRequiredChildren): Deleted. 62 (WI.AuditManager.prototype._addDefaultTests.const.testImageLabels): Deleted. 63 (WI.AuditManager.prototype._addDefaultTests.const.testForAriaHiddenFalse): Deleted. 64 (WI.AuditManager.prototype._addDefaultTests.const.testTreeRoleForRequiredChildren): Deleted. 65 (WI.AuditManager.prototype._addDefaultTests.const.testRadioGroupRoleForRequiredChildren): Deleted. 66 (WI.AuditManager.prototype._addDefaultTests.const.testFeedRoleForRequiredChildren): Deleted. 67 (WI.AuditManager.prototype._addDefaultTests.const.testTabListRoleForRequiredChildren): Deleted. 68 (WI.AuditManager.prototype._addDefaultTests.const.testButtonLabels): Deleted. 69 (WI.AuditManager.prototype._addDefaultTests.const.testRowRoleForRequiredChildren): Deleted. 70 (WI.AuditManager.prototype._addDefaultTests.const.testListRoleForRequiredChildren): Deleted. 71 (WI.AuditManager.prototype._addDefaultTests.const.testComboBoxRoleForRequiredChildren): Deleted. 72 (WI.AuditManager.prototype._addDefaultTests.const.testForMultipleMainContentSections): Deleted. 73 (WI.AuditManager.prototype._addDefaultTests.const.testDialogsForLabels): Deleted. 74 (WI.AuditManager.prototype._addDefaultTests.const.testForInvalidAriaHiddenValue): Deleted. 75 (WI.AuditManager.prototype._addDefaultTests.removeWhitespace): Deleted. 76 * UserInterface/Main.html: 77 * UserInterface/NonMinified/DefaultAudits.js: Added. 78 (WI.DefaultAudits.levelPass): 79 (WI.DefaultAudits.levelWarn): 80 (WI.DefaultAudits.levelFail): 81 (WI.DefaultAudits.levelError): 82 (WI.DefaultAudits.levelUnsupported): 83 (WI.DefaultAudits.dataDOMNodes): 84 (WI.DefaultAudits.dataDOMAttributes): 85 (WI.DefaultAudits.dataErrors): 86 (WI.DefaultAudits.dataCustom): 87 (WI.DefaultAudits.getElementsByComputedRole): 88 (WI.DefaultAudits.getActiveDescendant): 89 (WI.DefaultAudits.getChildNodes): 90 (WI.DefaultAudits.getComputedProperties): 91 (WI.DefaultAudits.getControlledNodes): 92 (WI.DefaultAudits.getFlowedNodes): 93 (WI.DefaultAudits.getMouseEventNode): 94 (WI.DefaultAudits.getOwnedNodes): 95 (WI.DefaultAudits.getParentNode): 96 (WI.DefaultAudits.getSelectedChildNodes): 97 (WI.DefaultAudits.hasEventListeners): 98 (WI.DefaultAudits.hasEventListenersClick): 99 (WI.DefaultAudits.getResources): 100 (WI.DefaultAudits.getResourceContent): 101 (WI.DefaultAudits.unsupported): 102 (hasChildWithRole): 103 (WI.DefaultAudits.testMenuRoleForRequiredChildren): 104 (WI.DefaultAudits.testGridRoleForRequiredChildren): 105 (WI.DefaultAudits.testForAriaLabelledBySpelling): 106 (WI.DefaultAudits.testForMultipleBanners): 107 (WI.DefaultAudits.testForLinkLabels): 108 (WI.DefaultAudits.testRowGroupRoleForRequiredChildren): 109 (WI.DefaultAudits.testTableRoleForRequiredChildren): 110 (WI.DefaultAudits.testForMultipleLiveRegions): 111 (WI.DefaultAudits.testListBoxRoleForRequiredChildren): 112 (WI.DefaultAudits.testImageLabels): 113 (WI.DefaultAudits.testForAriaHiddenFalse): 114 (WI.DefaultAudits.testTreeRoleForRequiredChildren): 115 (WI.DefaultAudits.testRadioGroupRoleForRequiredChildren): 116 (WI.DefaultAudits.testFeedRoleForRequiredChildren): 117 (WI.DefaultAudits.testTabListRoleForRequiredChildren): 118 (WI.DefaultAudits.testButtonLabels): 119 (WI.DefaultAudits.testRowRoleForRequiredChildren): 120 (WI.DefaultAudits.testListRoleForRequiredChildren): 121 (WI.DefaultAudits.testComboBoxRoleForRequiredChildren): 122 (WI.DefaultAudits.testForMultipleMainContentSections): 123 (WI.DefaultAudits.testDialogsForLabels): 124 (WI.DefaultAudits.testForInvalidAriaHiddenValue): 125 * UserInterface/Test.html: 126 1 127 2021-04-27 Don Olmstead <don.olmstead@sony.com> 2 128 -
trunk/Source/WebInspectorUI/Scripts/combine-resources.pl
r229932 r276680 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2015-20 18Apple Inc. All rights reserved.3 # Copyright (C) 2015-2021 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 39 39 our $strip; 40 40 our $verbose; 41 our $skipConcatenateTag; 41 42 42 43 GetOptions('output-dir=s' => \$outputDirectory, … … 48 49 'input-html=s' => \$htmlFile, 49 50 'verbose' => \$verbose, 50 'strip' => \$strip); 51 'strip' => \$strip, 52 'skip-concatenate-tag' => \$skipConcatenateTag); 51 53 52 54 unless (defined $htmlFile and defined $derivedSourcesDirectory and defined $outputDirectory and (defined $strip or defined $outputScriptName or defined $outputStylesheetName)) { 53 print "Usage: $0 --input-html <path> --derived-sources-dir <path> --output-dir <path> [--output-script-name <name>] [--output-style-name <name>] [--strip] \n";55 print "Usage: $0 --input-html <path> --derived-sources-dir <path> --output-dir <path> [--output-script-name <name>] [--output-style-name <name>] [--strip] [--skip-concatenate-tag]\n"; 54 56 exit; 55 57 } … … 119 121 } 120 122 121 my $inputDirectoryPattern = "(?!WebKitAdditions\/)(?!External\/)(?!Workers\/) [^\"]*";123 my $inputDirectoryPattern = "(?!WebKitAdditions\/)(?!External\/)(?!Workers\/)(?!NonMinified\/)[^\"]*"; 122 124 $inputDirectoryPattern = $inputDirectory . "\/[^\"]*" if $inputDirectory; 123 125 … … 126 128 stripIncludedFilesMatchingPattern("<script src=\"($inputDirectoryPattern)\"><\/script>"); 127 129 } else { 128 concatenateIncludedFilesMatchingPattern($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">") if defined $outputStylesheetName;129 concatenateIncludedFilesMatchingPattern($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", "<script src=\"$outputScriptName\"></script>") if defined $outputScriptName;130 concatenateIncludedFilesMatchingPattern($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", defined $skipConcatenateTag ? "" : "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">") if defined $outputStylesheetName; 131 concatenateIncludedFilesMatchingPattern($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", defined $skipConcatenateTag ? "" : "<script src=\"$outputScriptName\"></script>") if defined $outputScriptName; 130 132 } 131 133 -
trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl
r241496 r276680 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2015-20 18Apple Inc. All rights reserved.3 # Copyright (C) 2015-2021 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 113 113 my $inspectorLicense = <<'EOF'; 114 114 /* 115 * Copyright (C) 2007-20 19Apple Inc. All rights reserved.115 * Copyright (C) 2007-2021 Apple Inc. All rights reserved. 116 116 * Copyright (C) 2008 Matt Lilek. All rights reserved. 117 117 * Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org> … … 239 239 my $foundCSSFile = 0; 240 240 foreach my $file (@files) { 241 my $path = File::Spec->catdir($ $webInspectorUIAdditionsDir, $file);241 my $path = File::Spec->catdir($webInspectorUIAdditionsDir, $file); 242 242 next if -d $path; 243 243 if ($file =~ /\.js$/) { … … 347 347 '--output-script-name', 'Three.js'); 348 348 349 # Combine non-minified JavaScript files in Production builds into a single file (NonMinified.js), which will be 350 # appended to Main.js after Main.js has been minified. 351 system($perl, $combineResourcesCmd, 352 '--input-dir', 'NonMinified', 353 '--input-html', $derivedSourcesMainHTML, 354 '--input-html-dir', $uiRoot, 355 '--derived-sources-dir', $derivedSourcesDir, 356 '--output-dir', $derivedSourcesDir, 357 '--output-script-name', 'NonMinified.js', 358 '--skip-concatenate-tag'); 359 349 360 # Remove console.assert calls from the Main.js file. 350 361 my $derivedSourcesMainJS = File::Spec->catfile($derivedSourcesDir, 'Main.js'); … … 352 363 '--input-script', $derivedSourcesMainJS, 353 364 '--output-script', $derivedSourcesMainJS); 365 366 # Remove console.assert calls from the NonMinified.js file. 367 my $derivedSourcesNonMinifiedJS = File::Spec->catfile($derivedSourcesDir, 'NonMinified.js'); 368 system($perl, File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'), 369 '--input-script', $derivedSourcesNonMinifiedJS, 370 '--output-script', $derivedSourcesNonMinifiedJS); 354 371 355 372 # Fix Image URLs in the Main.css file by removing the "../". … … 407 424 system(qq("$python" "$jsMinScript" < "$derivedSourcesThreejsJS" >> "$targetThreejsJS")) and die "Failed to minify $derivedSourcesThreejsJS: $!"; 408 425 426 # Append non-minified JavaScript to Main.js. 427 appendFile($targetMainJS, $derivedSourcesNonMinifiedJS); 428 409 429 # Copy over the Images directory. 410 430 ditto(File::Spec->catdir($uiRoot, 'Images'), File::Spec->catdir($targetResourcePath, 'Images')); … … 444 464 my $derivedSourcesTestHTML = File::Spec->catfile($derivedSourcesDir, 'Test.html'); 445 465 my $derivedSourcesTestJS = File::Spec->catfile($derivedSourcesDir, 'TestCombined.js'); 466 467 # Combine non-minified JavaScript files in Production builds into the same TestCombined.js, because test files are not minified. 468 system($perl, $combineResourcesCmd, 469 '--input-dir', 'NonMinified', 470 '--input-html', $derivedSourcesTestHTML, 471 '--input-html-dir', $uiRoot, 472 '--derived-sources-dir', $derivedSourcesDir, 473 '--output-dir', $derivedSourcesDir, 474 '--output-script-name', 'NonMinifiedTestCombined.js', 475 '--skip-concatenate-tag'); 476 477 my $derivedSourcesNonMinifiedTestJS = File::Spec->catfile($derivedSourcesDir, 'NonMinifiedTestCombined.js'); 478 446 479 # Combine the CodeMirror JavaScript files into single file (TestCodeMirror.js). 447 480 system($perl, $combineResourcesCmd, … … 477 510 appendFile($targetTestJS, $derivedSourcesTestJS); 478 511 512 # Append the non-minified sources to TestCombined.js. 513 appendFile($targetTestJS, $derivedSourcesNonMinifiedTestJS); 514 479 515 # Append CodeMirror.js to the license that was exported above. 480 516 my $derivedSourcesCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'TestCodeMirror.js'); -
trunk/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js
r276603 r276680 342 342 _addDefaultTests() 343 343 { 344 const levelPass = function() { 345 return {level: "pass"}; 346 }; 347 348 const levelWarn = function() { 349 return {level: "warn"}; 350 }; 351 352 const levelFail = function() { 353 return {level: "fail"}; 354 }; 355 356 const levelError = function() { 357 return {level: "error"}; 358 }; 359 360 const levelUnsupported = function() { 361 return {level: "unsupported"}; 362 }; 363 364 const dataDOMNodes = function() { 365 return {level: "pass", domNodes: [document.body]}; 366 }; 367 368 const dataDOMAttributes = function() { 369 return {level: "pass", domNodes: Array.from(document.querySelectorAll("[id]")), domAttributes: ["id"]}; 370 }; 371 372 const dataErrors = function() { 373 throw Error("this error was thrown from inside the audit test code."); 374 }; 375 376 const dataCustom = function() { 377 return {level: "pass", a: 1, b: [2], c: {key: 3}}; 378 }; 379 380 const getElementsByComputedRole = function() { 381 return {level: "pass", domNodes: WebInspectorAudit.Accessibility.getElementsByComputedRole("link"), domAttributes: ["role"]}; 382 }; 383 384 const getActiveDescendant = function() { 385 let result = {level: "pass"}; 386 let activeDescendant = WebInspectorAudit.Accessibility.getActiveDescendant(document.body); 387 if (activeDescendant) 388 result.domNodes = [activeDescendant]; 389 return result; 390 }; 391 392 const getChildNodes = function() { 393 let childNodes = WebInspectorAudit.Accessibility.getChildNodes(document.body); 394 return {level: "pass", domNodes: childNodes || []}; 395 }; 396 397 const getComputedProperties = function() { 398 let domAttributes = ["alt", "aria-atomic", "aria-busy", "aria-checked", "aria-current", "aria-disabled", "aria-expanded", "aria-haspopup", "aria-hidden", "aria-invalid", "aria-label", "aria-labelledby", "aria-level", "aria-live", "aria-pressed", "aria-readonly", "aria-relevant", "aria-required", "aria-selected", "role", "title"].filter((attribute) => document.body.hasAttribute(attribute)); 399 let computedProperties = WebInspectorAudit.Accessibility.getComputedProperties(document.body); 400 return {level: "pass", domNodes: [document.body], domAttributes, ...(computedProperties || {})}; 401 }; 402 403 const getControlledNodes = function() { 404 let controlledNodes = WebInspectorAudit.Accessibility.getControlledNodes(document.body); 405 return {level: "pass", domNodes: controlledNodes || []}; 406 }; 407 408 const getFlowedNodes = function() { 409 let flowedNodes = WebInspectorAudit.Accessibility.getFlowedNodes(document.body); 410 return {level: "pass", domNodes: flowedNodes || []}; 411 }; 412 413 const getMouseEventNode = function() { 414 let result = {level: "pass"}; 415 let mouseEventNode = WebInspectorAudit.Accessibility.getMouseEventNode(document.body); 416 if (mouseEventNode) 417 result.domNodes = [mouseEventNode]; 418 return result; 419 }; 420 421 const getOwnedNodes = function() { 422 let ownedNodes = WebInspectorAudit.Accessibility.getOwnedNodes(document.body); 423 return {level: "pass", domNodes: ownedNodes || []}; 424 }; 425 426 const getParentNode = function() { 427 let result = {level: "pass"}; 428 let parentNode = WebInspectorAudit.Accessibility.getParentNode(document.body); 429 if (parentNode) 430 result.domNodes = [parentNode]; 431 return result; 432 }; 433 434 const getSelectedChildNodes = function() { 435 let selectedChildNodes = WebInspectorAudit.Accessibility.getSelectedChildNodes(document.body); 436 return {level: "pass", domNodes: selectedChildNodes || []}; 437 }; 438 439 const hasEventListeners = function() { 440 let domAttributes = Array.from(document.body.attributes).filter((attribute) => attribute.name.startsWith("on")); 441 return {level: "pass", domNodes: [document.body], domAttributes, hasEventListeners: WebInspectorAudit.DOM.hasEventListeners(document.body)}; 442 }; 443 444 const hasEventListenersClick = function() { 445 let domAttributes = ["onclick"].filter((attribute) => document.body.hasAttribute(attribute)); 446 return {level: "pass", domNodes: [document.body], domAttributes, hasClickEventListener: WebInspectorAudit.DOM.hasEventListeners(document.body, "click")}; 447 }; 448 449 const getResources = function() { 450 return {level: "pass", resources: WebInspectorAudit.Resources.getResources()}; 451 }; 452 453 const getResourceContent = function() { 454 let resources = WebInspectorAudit.Resources.getResources(); 455 let mainResource = resources.find((resource) => resource.url === window.location.href); 456 return {level: "pass", mainResource, resourceContent: WebInspectorAudit.Resources.getResourceContent(mainResource.id)}; 457 }; 458 459 const unsupported = function() { 460 throw Error("this test should not be supported."); 461 }; 462 463 const testMenuRoleForRequiredChildren = function() { 464 const relationships = { 465 menu: ["menuitem", "menuitemcheckbox", "menuitemradio"], 466 menubar: ["menuitem", "menuitemcheckbox", "menuitemradio"], 467 }; 468 let domNodes = []; 469 let visitedParents = new Set; 470 function hasChildWithRole(node, expectedRoles) { 471 let childNode = node; 472 if (!childNode) 473 return false; 474 475 if (childNode.parentNode) 476 visitedParents.add(childNode.parentNode); 477 478 while (childNode) { 479 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 480 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 481 if (expectedRoles.includes(properties.role)) 482 return true; 483 484 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 485 return true; 486 } 487 childNode = childNode.nextSibling; 488 } 489 return false; 490 } 491 for (let role in relationships) { 492 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 493 if (visitedParents.has(parentNode)) 494 continue; 495 496 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 497 domNodes.push(parentNode); 498 } 499 } 500 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 501 }; 502 503 const testGridRoleForRequiredChildren = function() { 504 const relationships = { 505 grid: ["row", "rowgroup"], 506 }; 507 let domNodes = []; 508 let visitedParents = new Set; 509 function hasChildWithRole(node, expectedRoles) { 510 let childNode = node; 511 if (!childNode) 512 return false; 513 514 if (childNode.parentNode) 515 visitedParents.add(childNode.parentNode); 516 517 while (childNode) { 518 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 519 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 520 if (expectedRoles.includes(properties.role)) 521 return true; 522 523 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 524 return true; 525 } 526 childNode = childNode.nextSibling; 527 } 528 return false; 529 } 530 for (let role in relationships) { 531 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 532 if (visitedParents.has(parentNode)) 533 continue; 534 535 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 536 domNodes.push(parentNode); 537 } 538 } 539 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 540 }; 541 542 const testForAriaLabelledBySpelling = function() { 543 let domNodes = Array.from(document.querySelectorAll("[aria-labeledby]")); 544 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-labeledby"]}; 545 }; 546 547 const testForMultipleBanners = function() { 548 let domNodes = []; 549 let banners = WebInspectorAudit.Accessibility.getElementsByComputedRole("banner"); 550 if (banners.length > 1) 551 domNodes = banners; 552 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 553 }; 554 555 const testForLinkLabels = function() { 556 let links = WebInspectorAudit.Accessibility.getElementsByComputedRole("link"); 557 let domNodes = links.filter((link) => !WebInspectorAudit.Accessibility.getComputedProperties(link).label); 558 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-label", "aria-labelledby", "title"]}; 559 }; 560 561 const testRowGroupRoleForRequiredChildren = function() { 562 const relationships = { 563 rowgroup: ["row"], 564 }; 565 let domNodes = []; 566 let visitedParents = new Set; 567 function hasChildWithRole(node, expectedRoles) { 568 let childNode = node; 569 if (!childNode) 570 return false; 571 572 if (childNode.parentNode) 573 visitedParents.add(childNode.parentNode); 574 575 while (childNode) { 576 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 577 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 578 if (expectedRoles.includes(properties.role)) 579 return true; 580 581 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 582 return true; 583 } 584 childNode = childNode.nextSibling; 585 } 586 return false; 587 } 588 for (let role in relationships) { 589 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 590 if (visitedParents.has(parentNode)) 591 continue; 592 593 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 594 domNodes.push(parentNode); 595 } 596 } 597 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 598 }; 599 600 const testTableRoleForRequiredChildren = function() { 601 const relationships = { 602 table: ["row", "rowgroup"], 603 }; 604 let domNodes = []; 605 let visitedParents = new Set; 606 function hasChildWithRole(node, expectedRoles) { 607 let childNode = node; 608 if (!childNode) 609 return false; 610 611 if (childNode.parentNode) 612 visitedParents.add(childNode.parentNode); 613 614 while (childNode) { 615 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 616 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 617 if (expectedRoles.includes(properties.role)) 618 return true; 619 620 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 621 return true; 622 } 623 childNode = childNode.nextSibling; 624 } 625 return false; 626 } 627 for (let role in relationships) { 628 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 629 if (visitedParents.has(parentNode)) 630 continue; 631 632 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 633 domNodes.push(parentNode); 634 } 635 } 636 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 637 }; 638 639 const testForMultipleLiveRegions = function() { 640 const liveRegionRoles = ["alert", "log", "status", "marquee", "timer"]; 641 let domNodes = []; 642 let liveRegions = liveRegionRoles.reduce((a, b) => { 643 return a.concat(WebInspectorAudit.Accessibility.getElementsByComputedRole(b)); 644 }, []); 645 liveRegions = liveRegions.concat(Array.from(document.querySelectorAll(`[aria-live="polite"], [aria-live="assertive"]`))); 646 if (liveRegions.length > 1) 647 domNodes = liveRegions; 648 return {level: domNodes.length ? "warn" : "pass", domNodes, domAttributes: ["aria-live"]}; 649 }; 650 651 const testListBoxRoleForRequiredChildren = function() { 652 const relationships = { 653 listbox: ["option"], 654 }; 655 let domNodes = []; 656 let visitedParents = new Set; 657 function hasChildWithRole(node, expectedRoles) { 658 let childNode = node; 659 if (!childNode) 660 return false; 661 662 if (childNode.parentNode) 663 visitedParents.add(childNode.parentNode); 664 665 while (childNode) { 666 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 667 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 668 if (expectedRoles.includes(properties.role)) 669 return true; 670 671 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 672 return true; 673 } 674 childNode = childNode.nextSibling; 675 } 676 return false; 677 } 678 for (let role in relationships) { 679 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 680 if (visitedParents.has(parentNode)) 681 continue; 682 683 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 684 domNodes.push(parentNode); 685 } 686 } 687 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 688 }; 689 690 const testImageLabels = function() { 691 let images = WebInspectorAudit.Accessibility.getElementsByComputedRole("img"); 692 let domNodes = images.filter((image) => !WebInspectorAudit.Accessibility.getComputedProperties(image).label); 693 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-label", "aria-labelledby", "title", "alt"]}; 694 }; 695 696 const testForAriaHiddenFalse = function() { 697 let domNodes = Array.from(document.querySelectorAll(`[aria-hidden="false"]`)); 698 return {level: domNodes.length ? "warn" : "pass", domNodes, domAttributes: ["aria-hidden"]}; 699 }; 700 701 const testTreeRoleForRequiredChildren = function() { 702 const relationships = { 703 tree: ["treeitem", "group"], 704 }; 705 let domNodes = []; 706 let visitedParents = new Set; 707 function hasChildWithRole(node, expectedRoles) { 708 let childNode = node; 709 if (!childNode) 710 return false; 711 712 if (childNode.parentNode) 713 visitedParents.add(childNode.parentNode); 714 715 while (childNode) { 716 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 717 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 718 if (expectedRoles.includes(properties.role)) 719 return true; 720 721 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 722 return true; 723 } 724 childNode = childNode.nextSibling; 725 } 726 return false; 727 } 728 for (let role in relationships) { 729 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 730 if (visitedParents.has(parentNode)) 731 continue; 732 733 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 734 domNodes.push(parentNode); 735 } 736 } 737 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 738 }; 739 740 const testRadioGroupRoleForRequiredChildren = function() { 741 const relationships = { 742 radiogroup: ["radio"], 743 }; 744 let domNodes = []; 745 let visitedParents = new Set; 746 function hasChildWithRole(node, expectedRoles) { 747 let childNode = node; 748 if (!childNode) 749 return false; 750 751 if (childNode.parentNode) 752 visitedParents.add(childNode.parentNode); 753 754 while (childNode) { 755 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 756 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 757 if (expectedRoles.includes(properties.role)) 758 return true; 759 760 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 761 return true; 762 } 763 childNode = childNode.nextSibling; 764 } 765 return false; 766 } 767 for (let role in relationships) { 768 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 769 if (visitedParents.has(parentNode)) 770 continue; 771 772 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 773 domNodes.push(parentNode); 774 } 775 } 776 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 777 }; 778 779 const testFeedRoleForRequiredChildren = function() { 780 const relationships = { 781 feed: ["article"], 782 }; 783 let domNodes = []; 784 let visitedParents = new Set; 785 function hasChildWithRole(node, expectedRoles) { 786 let childNode = node; 787 if (!childNode) 788 return false; 789 790 if (childNode.parentNode) 791 visitedParents.add(childNode.parentNode); 792 793 while (childNode) { 794 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 795 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 796 if (expectedRoles.includes(properties.role)) 797 return true; 798 799 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 800 return true; 801 } 802 childNode = childNode.nextSibling; 803 } 804 return false; 805 } 806 for (let role in relationships) { 807 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 808 if (visitedParents.has(parentNode)) 809 continue; 810 811 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 812 domNodes.push(parentNode); 813 } 814 } 815 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 816 }; 817 818 const testTabListRoleForRequiredChildren = function() { 819 const relationships = { 820 tablist: ["tab"], 821 }; 822 let domNodes = []; 823 let visitedParents = new Set; 824 function hasChildWithRole(node, expectedRoles) { 825 let childNode = node; 826 if (!childNode) 827 return false; 828 829 if (childNode.parentNode) 830 visitedParents.add(childNode.parentNode); 831 832 while (childNode) { 833 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 834 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 835 if (expectedRoles.includes(properties.role)) 836 return true; 837 838 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 839 return true; 840 } 841 childNode = childNode.nextSibling; 842 } 843 return false; 844 } 845 for (let role in relationships) { 846 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 847 if (visitedParents.has(parentNode)) 848 continue; 849 850 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 851 domNodes.push(parentNode); 852 } 853 } 854 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 855 }; 856 857 const testButtonLabels = function() { 858 let buttons = WebInspectorAudit.Accessibility.getElementsByComputedRole("button"); 859 let domNodes = buttons.filter((button) => !WebInspectorAudit.Accessibility.getComputedProperties(button).label); 860 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-label", "aria-labelledby", "title"]}; 861 }; 862 863 const testRowRoleForRequiredChildren = function() { 864 const relationships = { 865 row: ["cell", "gridcell", "columnheader", "rowheader"], 866 }; 867 let domNodes = []; 868 let visitedParents = new Set; 869 function hasChildWithRole(node, expectedRoles) { 870 let childNode = node; 871 if (!childNode) 872 return false; 873 874 if (childNode.parentNode) 875 visitedParents.add(childNode.parentNode); 876 877 while (childNode) { 878 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 879 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 880 if (expectedRoles.includes(properties.role)) 881 return true; 882 883 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 884 return true; 885 } 886 childNode = childNode.nextSibling; 887 } 888 return false; 889 } 890 for (let role in relationships) { 891 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 892 if (visitedParents.has(parentNode)) 893 continue; 894 895 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 896 domNodes.push(parentNode); 897 } 898 } 899 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 900 }; 901 902 const testListRoleForRequiredChildren = function() { 903 const relationships = { 904 list: ["listitem", "group"], 905 }; 906 let domNodes = []; 907 let visitedParents = new Set; 908 function hasChildWithRole(node, expectedRoles) { 909 let childNode = node; 910 if (!childNode) 911 return false; 912 913 if (childNode.parentNode) 914 visitedParents.add(childNode.parentNode); 915 916 while (childNode) { 917 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 918 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 919 if (expectedRoles.includes(properties.role)) 920 return true; 921 922 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 923 return true; 924 } 925 childNode = childNode.nextSibling; 926 } 927 return false; 928 } 929 for (let role in relationships) { 930 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 931 if (visitedParents.has(parentNode)) 932 continue; 933 934 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 935 domNodes.push(parentNode); 936 } 937 } 938 return {level: domNodes.length ? "warn" : "pass", domNodes, domAttributes: ["role"]}; 939 }; 940 941 const testComboBoxRoleForRequiredChildren = function() { 942 const relationships = { 943 combobox: ["textbox", "listbox", "tree", "grid", "dialog"], 944 }; 945 let domNodes = []; 946 let visitedParents = new Set; 947 function hasChildWithRole(node, expectedRoles) { 948 let childNode = node; 949 if (!childNode) 950 return false; 951 952 if (childNode.parentNode) 953 visitedParents.add(childNode.parentNode); 954 955 while (childNode) { 956 let properties = WebInspectorAudit.Accessibility.getComputedProperties(childNode); 957 if (childNode.nodeType === Node.ELEMENT_NODE && properties) { 958 if (expectedRoles.includes(properties.role)) 959 return true; 960 961 if (childNode.hasChildNodes() && hasChildWithRole(childNode.firstChild, expectedRoles)) 962 return true; 963 } 964 childNode = childNode.nextSibling; 965 } 966 return false; 967 } 968 for (let role in relationships) { 969 for (let parentNode of WebInspectorAudit.Accessibility.getElementsByComputedRole(role)) { 970 if (visitedParents.has(parentNode)) 971 continue; 972 973 if (!hasChildWithRole(parentNode.firstChild, relationships[role])) 974 domNodes.push(parentNode); 975 } 976 } 977 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 978 }; 979 980 const testForMultipleMainContentSections = function() { 981 let domNodes = []; 982 let mainContentElements = WebInspectorAudit.Accessibility.getElementsByComputedRole("main"); 983 if (mainContentElements.length > 1) { 984 domNodes = mainContentElements; 985 } 986 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["role"]}; 987 }; 988 989 const testDialogsForLabels = function() { 990 let dialogs = WebInspectorAudit.Accessibility.getElementsByComputedRole("dialog"); 991 let domNodes = dialogs.filter((dialog) => !WebInspectorAudit.Accessibility.getComputedProperties(dialog).label); 992 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-label", "aria-labelledby", "title"]}; 993 }; 994 995 const testForInvalidAriaHiddenValue = function() { 996 let domNodes = Array.from(document.querySelectorAll(`[aria-hidden]:not([aria-hidden="true"], [aria-hidden="false"])`)); 997 return {level: domNodes.length ? "fail" : "pass", domNodes, domAttributes: ["aria-hidden"]}; 998 }; 999 1000 function removeWhitespace(func) { 1001 return WI.AuditTestCase.stringifyFunction(func, 8); 1002 } 344 console.assert(WI.DefaultAudits, "Default audits not loaded."); 345 if (!WI.DefaultAudits) 346 return; 1003 347 1004 348 const defaultTests = [ 1005 349 new WI.AuditTestGroup(WI.UIString("Demo Audit"), [ 1006 350 new WI.AuditTestGroup(WI.UIString("Result Levels"), [ 1007 new WI.AuditTestCase("level-pass", removeWhitespace(levelPass), {description: WI.UIString("This is what the result of a passing test with no data looks like.")}),1008 new WI.AuditTestCase("level-warn", removeWhitespace(levelWarn), {description: WI.UIString("This is what the result of a warning test with no data looks like.")}),1009 new WI.AuditTestCase("level-fail", removeWhitespace(levelFail), {description: WI.UIString("This is what the result of a failing test with no data looks like.")}),1010 new WI.AuditTestCase("level-error", removeWhitespace(levelError), {description: WI.UIString("This is what the result of a test that threw an error with no data looks like.")}),1011 new WI.AuditTestCase("level-unsupported", removeWhitespace(levelUnsupported), {description: WI.UIString("This is what the result of an unsupported test with no data looks like.")}),351 new WI.AuditTestCase("level-pass", WI.DefaultAudits.levelPass.toString(), {description: WI.UIString("This is what the result of a passing test with no data looks like.")}), 352 new WI.AuditTestCase("level-warn", WI.DefaultAudits.levelWarn.toString(), {description: WI.UIString("This is what the result of a warning test with no data looks like.")}), 353 new WI.AuditTestCase("level-fail", WI.DefaultAudits.levelFail.toString(), {description: WI.UIString("This is what the result of a failing test with no data looks like.")}), 354 new WI.AuditTestCase("level-error", WI.DefaultAudits.levelError.toString(), {description: WI.UIString("This is what the result of a test that threw an error with no data looks like.")}), 355 new WI.AuditTestCase("level-unsupported", WI.DefaultAudits.levelUnsupported.toString(), {description: WI.UIString("This is what the result of an unsupported test with no data looks like.")}), 1012 356 ], {description: WI.UIString("These are all of the different test result levels.")}), 1013 357 new WI.AuditTestGroup(WI.UIString("Result Data"), [ 1014 new WI.AuditTestCase("data-domNodes", removeWhitespace(dataDOMNodes), {description: WI.UIString("This is an example of how result DOM nodes are shown. It will pass with the <body> element.")}),1015 new WI.AuditTestCase("data-domAttributes", removeWhitespace(dataDOMAttributes), {description: WI.UIString("This is an example of how result DOM attributes are highlighted on any returned DOM nodes. It will pass with all elements with an id attribute.")}),1016 new WI.AuditTestCase("data-errors", removeWhitespace(dataErrors), {description: WI.UIString("This is an example of how errors are shown. The error was thrown manually, but execution errors will appear in the same way.")}),1017 new WI.AuditTestCase("data-custom", removeWhitespace(dataCustom), {description: WI.UIString("This is an example of how custom result data is shown."), supports: 3}),358 new WI.AuditTestCase("data-domNodes", WI.DefaultAudits.dataDOMNodes.toString(), {description: WI.UIString("This is an example of how result DOM nodes are shown. It will pass with the <body> element.")}), 359 new WI.AuditTestCase("data-domAttributes", WI.DefaultAudits.dataDOMAttributes.toString(), {description: WI.UIString("This is an example of how result DOM attributes are highlighted on any returned DOM nodes. It will pass with all elements with an id attribute.")}), 360 new WI.AuditTestCase("data-errors", WI.DefaultAudits.dataErrors.toString(), {description: WI.UIString("This is an example of how errors are shown. The error was thrown manually, but execution errors will appear in the same way.")}), 361 new WI.AuditTestCase("data-custom", WI.DefaultAudits.dataCustom.toString(), {description: WI.UIString("This is an example of how custom result data is shown."), supports: 3}), 1018 362 ], {description: WI.UIString("These are example tests that demonstrate all of the different types of data that can be returned with the test result.")}), 1019 363 new WI.AuditTestGroup(WI.UIString("Specially Exposed Data"), [ 1020 364 new WI.AuditTestGroup(WI.UIString("Accessibility"), [ 1021 new WI.AuditTestCase("getElementsByComputedRole", removeWhitespace(getElementsByComputedRole), {description: WI.UIString("This is an example test that uses %s to find elements with a computed role of \u0022link\u0022.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getElementsByComputedRole")), supports: 1}),1022 new WI.AuditTestCase("getActiveDescendant", removeWhitespace(getActiveDescendant), {description: WI.UIString("This is an example test that uses %s to find any element that meets criteria for active descendant (\u0022%s\u0022) of the <body> element, if it exists.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getActiveDescendant"), WI.unlocalizedString("aria-activedescendant")), supports: 1}),1023 new WI.AuditTestCase("getChildNodes", removeWhitespace(getChildNodes), {description: WI.UIString("This is an example test that uses %s to find child nodes of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getChildNodes")), supports: 1}),1024 new WI.AuditTestCase("getComputedProperties", removeWhitespace(getComputedProperties), {description: WI.UIString("This is an example test that uses %s to find a variety of accessibility information about the <body> element.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getComputedProperties")), supports: 3}),1025 new WI.AuditTestCase("getControlledNodes", removeWhitespace(getControlledNodes), {description: WI.UIString("This is an example test that uses %s to find all nodes controlled (\u0022%s\u0022) by the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getControlledNodes"), WI.unlocalizedString("aria-controls")), supports: 1}),1026 new WI.AuditTestCase("getFlowedNodes", removeWhitespace(getFlowedNodes), {description: WI.UIString("This is an example test that uses %s to find all nodes flowed to (\u0022%s\u0022) from the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getFlowedNodes"), WI.unlocalizedString("aria-flowto")), supports: 1}),1027 new WI.AuditTestCase("getMouseEventNode", removeWhitespace(getMouseEventNode), {description: WI.UIString("This is an example test that uses %s to find the node that would handle mouse events for the <body> element, if applicable.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getMouseEventNode")), supports: 1}),1028 new WI.AuditTestCase("getOwnedNodes", removeWhitespace(getOwnedNodes), {description: WI.UIString("This is an example test that uses %s to find all nodes owned (\u0022%s\u0022) by the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getOwnedNodes"), WI.unlocalizedString("aria-owns")), supports: 1}),1029 new WI.AuditTestCase("getParentNode", removeWhitespace(getParentNode), {description: WI.UIString("This is an example test that uses %s to find the parent node of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getParentNode")), supports: 1}),1030 new WI.AuditTestCase("getSelectedChildNodes", removeWhitespace(getSelectedChildNodes), {description: WI.UIString("This is an example test that uses %s to find all child nodes that are selected (\u0022%s\u0022) of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getSelectedChildNodes"), WI.unlocalizedString("aria-selected")), supports: 1}),365 new WI.AuditTestCase("getElementsByComputedRole", WI.DefaultAudits.getElementsByComputedRole.toString(), {description: WI.UIString("This is an example test that uses %s to find elements with a computed role of \u0022link\u0022.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getElementsByComputedRole")), supports: 1}), 366 new WI.AuditTestCase("getActiveDescendant", WI.DefaultAudits.getActiveDescendant.toString(), {description: WI.UIString("This is an example test that uses %s to find any element that meets criteria for active descendant (\u0022%s\u0022) of the <body> element, if it exists.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getActiveDescendant"), WI.unlocalizedString("aria-activedescendant")), supports: 1}), 367 new WI.AuditTestCase("getChildNodes", WI.DefaultAudits.getChildNodes.toString(), {description: WI.UIString("This is an example test that uses %s to find child nodes of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getChildNodes")), supports: 1}), 368 new WI.AuditTestCase("getComputedProperties", WI.DefaultAudits.getComputedProperties.toString(), {description: WI.UIString("This is an example test that uses %s to find a variety of accessibility information about the <body> element.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getComputedProperties")), supports: 3}), 369 new WI.AuditTestCase("getControlledNodes", WI.DefaultAudits.getControlledNodes.toString(), {description: WI.UIString("This is an example test that uses %s to find all nodes controlled (\u0022%s\u0022) by the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getControlledNodes"), WI.unlocalizedString("aria-controls")), supports: 1}), 370 new WI.AuditTestCase("getFlowedNodes", WI.DefaultAudits.getFlowedNodes.toString(), {description: WI.UIString("This is an example test that uses %s to find all nodes flowed to (\u0022%s\u0022) from the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getFlowedNodes"), WI.unlocalizedString("aria-flowto")), supports: 1}), 371 new WI.AuditTestCase("getMouseEventNode", WI.DefaultAudits.getMouseEventNode.toString(), {description: WI.UIString("This is an example test that uses %s to find the node that would handle mouse events for the <body> element, if applicable.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getMouseEventNode")), supports: 1}), 372 new WI.AuditTestCase("getOwnedNodes", WI.DefaultAudits.getOwnedNodes.toString(), {description: WI.UIString("This is an example test that uses %s to find all nodes owned (\u0022%s\u0022) by the <body> element, if any exist.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getOwnedNodes"), WI.unlocalizedString("aria-owns")), supports: 1}), 373 new WI.AuditTestCase("getParentNode", WI.DefaultAudits.getParentNode.toString(), {description: WI.UIString("This is an example test that uses %s to find the parent node of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getParentNode")), supports: 1}), 374 new WI.AuditTestCase("getSelectedChildNodes", WI.DefaultAudits.getSelectedChildNodes.toString(), {description: WI.UIString("This is an example test that uses %s to find all child nodes that are selected (\u0022%s\u0022) of the <body> element in the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getSelectedChildNodes"), WI.unlocalizedString("aria-selected")), supports: 1}), 1031 375 ], {description: WI.UIString("These are example tests that demonstrate how to use %s to get information about the accessibility tree.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility")), supports: 1}), 1032 376 new WI.AuditTestGroup(WI.UIString("DOM"), [ 1033 new WI.AuditTestCase("hasEventListeners", removeWhitespace(hasEventListeners), {description: WI.UIString("This is an example test that uses %s to find data indicating whether the <body> element has any event listeners.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.hasEventListeners")), supports: 3}),1034 new WI.AuditTestCase("hasEventListeners-click", removeWhitespace(hasEventListenersClick), {description: WI.UIString("This is an example test that uses %s to find data indicating whether the <body> element has any click event listeners.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.hasEventListenersClick")), supports: 3}),377 new WI.AuditTestCase("hasEventListeners", WI.DefaultAudits.hasEventListeners.toString(), {description: WI.UIString("This is an example test that uses %s to find data indicating whether the <body> element has any event listeners.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.hasEventListeners")), supports: 3}), 378 new WI.AuditTestCase("hasEventListeners-click", WI.DefaultAudits.hasEventListenersClick.toString(), {description: WI.UIString("This is an example test that uses %s to find data indicating whether the <body> element has any click event listeners.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.hasEventListenersClick")), supports: 3}), 1035 379 ], {description: WI.UIString("These are example tests that demonstrate how to use %s to get information about DOM nodes.").format(WI.unlocalizedString("WebInspectorAudit.DOM")), supports: 1}), 1036 380 new WI.AuditTestGroup(WI.UIString("Resources"), [ 1037 new WI.AuditTestCase("getResources", removeWhitespace(getResources), {description: WI.UIString("This is an example test that uses %s to find basic information about each resource.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getResources")), supports: 3}),1038 new WI.AuditTestCase("getResourceContent", removeWhitespace(getResourceContent), {description: WI.UIString("This is an example test that uses %s to find the contents of the main resource.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getResourceContent")), supports: 3}),381 new WI.AuditTestCase("getResources", WI.DefaultAudits.getResources.toString(), {description: WI.UIString("This is an example test that uses %s to find basic information about each resource.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getResources")), supports: 3}), 382 new WI.AuditTestCase("getResourceContent", WI.DefaultAudits.getResourceContent.toString(), {description: WI.UIString("This is an example test that uses %s to find the contents of the main resource.").format(WI.unlocalizedString("WebInspectorAudit.Accessibility.getResourceContent")), supports: 3}), 1039 383 ], {description: WI.UIString("These are example tests that demonstrate how to use %s to get information about loaded resources.").format(WI.unlocalizedString("WebInspectorAudit.Resources")), supports: 2}), 1040 384 ], {description: WI.UIString("These are example tests that demonstrate how to use %s to access information not normally available to JavaScript.").format(WI.unlocalizedString("WebInspectorAudit")), supports: 1}), 1041 new WI.AuditTestCase("unsupported", removeWhitespace(unsupported), {description: WI.UIString("This is an example of a test that will not run because it is unsupported."), supports: Infinity}),385 new WI.AuditTestCase("unsupported", WI.DefaultAudits.unsupported.toString(), {description: WI.UIString("This is an example of a test that will not run because it is unsupported."), supports: Infinity}), 1042 386 ], {description: WI.UIString("These are example tests that demonstrate the functionality and structure of audits.")}), 1043 387 new WI.AuditTestGroup(WI.UIString("Accessibility"), [ 1044 new WI.AuditTestCase("testMenuRoleForRequiredChildren", removeWhitespace(testMenuRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 and \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("menu"), WI.unlocalizedString("menubar")), supports: 1}),1045 new WI.AuditTestCase("testGridRoleForRequiredChildren", removeWhitespace(testGridRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("grid")), supports: 1}),1046 new WI.AuditTestCase("testForAriaLabelledBySpelling", removeWhitespace(testForAriaLabelledBySpelling), {description: WI.UIString("Ensure that \u0022%s\u0022 is spelled correctly.").format(WI.unlocalizedString("aria-labelledby")), supports: 1}),1047 new WI.AuditTestCase("testForMultipleBanners", removeWhitespace(testForMultipleBanners), {description: WI.UIString("Ensure that only one banner is used on the page."), supports: 1}),1048 new WI.AuditTestCase("testForLinkLabels", removeWhitespace(testForLinkLabels), {description: WI.UIString("Ensure that links have accessible labels for assistive technology."), supports: 1}),1049 new WI.AuditTestCase("testRowGroupRoleForRequiredChildren", removeWhitespace(testRowGroupRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("rowgroup")), supports: 1}),1050 new WI.AuditTestCase("testTableRoleForRequiredChildren", removeWhitespace(testTableRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("table")), supports: 1}),1051 new WI.AuditTestCase("testForMultipleLiveRegions", removeWhitespace(testForMultipleLiveRegions), {description: WI.UIString("Ensure that only one live region is used on the page."), supports: 1}),1052 new WI.AuditTestCase("testListBoxRoleForRequiredChildren", removeWhitespace(testListBoxRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("listbox")), supports: 1}),1053 new WI.AuditTestCase("testImageLabels", removeWhitespace(testImageLabels), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have accessible labels for assistive technology.").format(WI.unlocalizedString("img")), supports: 1}),1054 new WI.AuditTestCase("testForAriaHiddenFalse", removeWhitespace(testForAriaHiddenFalse), {description: WI.UIString("Ensure aria-hidden=\u0022%s\u0022 is not used.").format(WI.unlocalizedString("false")), supports: 1}),1055 new WI.AuditTestCase("testTreeRoleForRequiredChildren", removeWhitespace(testTreeRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("tree")), supports: 1}),1056 new WI.AuditTestCase("testRadioGroupRoleForRequiredChildren", removeWhitespace(testRadioGroupRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("radiogroup")), supports: 1}),1057 new WI.AuditTestCase("testFeedRoleForRequiredChildren", removeWhitespace(testFeedRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("feed")), supports: 1}),1058 new WI.AuditTestCase("testTabListRoleForRequiredChildren", removeWhitespace(testTabListRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("tablist")), supports: 1}),1059 new WI.AuditTestCase("testButtonLabels", removeWhitespace(testButtonLabels), {description: WI.UIString("Ensure that buttons have accessible labels for assistive technology."), supports: 1}),1060 new WI.AuditTestCase("testRowRoleForRequiredChildren", removeWhitespace(testRowRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("row")), supports: 1}),1061 new WI.AuditTestCase("testListRoleForRequiredChildren", removeWhitespace(testListRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("list")), supports: 1}),1062 new WI.AuditTestCase("testComboBoxRoleForRequiredChildren", removeWhitespace(testComboBoxRoleForRequiredChildren), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("combobox")), supports: 1}),1063 new WI.AuditTestCase("testForMultipleMainContentSections", removeWhitespace(testForMultipleMainContentSections), {description: WI.UIString("Ensure that only one main content section is used on the page."), supports: 1}),1064 new WI.AuditTestCase("testDialogsForLabels", removeWhitespace(testDialogsForLabels), {description: WI.UIString("Ensure that dialogs have accessible labels for assistive technology."), supports: 1}),1065 new WI.AuditTestCase("testForInvalidAriaHiddenValue", removeWhitespace(testForInvalidAriaHiddenValue), {description: WI.UIString("Ensure that values for \u0022%s\u0022 are valid.").format(WI.unlocalizedString("aria-hidden")), supports: 1})388 new WI.AuditTestCase("testMenuRoleForRequiredChildren", WI.DefaultAudits.testMenuRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 and \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("menu"), WI.unlocalizedString("menubar")), supports: 1}), 389 new WI.AuditTestCase("testGridRoleForRequiredChildren", WI.DefaultAudits.testGridRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("grid")), supports: 1}), 390 new WI.AuditTestCase("testForAriaLabelledBySpelling", WI.DefaultAudits.testForAriaLabelledBySpelling.toString(), {description: WI.UIString("Ensure that \u0022%s\u0022 is spelled correctly.").format(WI.unlocalizedString("aria-labelledby")), supports: 1}), 391 new WI.AuditTestCase("testForMultipleBanners", WI.DefaultAudits.testForMultipleBanners.toString(), {description: WI.UIString("Ensure that only one banner is used on the page."), supports: 1}), 392 new WI.AuditTestCase("testForLinkLabels", WI.DefaultAudits.testForLinkLabels.toString(), {description: WI.UIString("Ensure that links have accessible labels for assistive technology."), supports: 1}), 393 new WI.AuditTestCase("testRowGroupRoleForRequiredChildren", WI.DefaultAudits.testRowGroupRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("rowgroup")), supports: 1}), 394 new WI.AuditTestCase("testTableRoleForRequiredChildren", WI.DefaultAudits.testTableRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("table")), supports: 1}), 395 new WI.AuditTestCase("testForMultipleLiveRegions", WI.DefaultAudits.testForMultipleLiveRegions.toString(), {description: WI.UIString("Ensure that only one live region is used on the page."), supports: 1}), 396 new WI.AuditTestCase("testListBoxRoleForRequiredChildren", WI.DefaultAudits.testListBoxRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("listbox")), supports: 1}), 397 new WI.AuditTestCase("testImageLabels", WI.DefaultAudits.testImageLabels.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have accessible labels for assistive technology.").format(WI.unlocalizedString("img")), supports: 1}), 398 new WI.AuditTestCase("testForAriaHiddenFalse", WI.DefaultAudits.testForAriaHiddenFalse.toString(), {description: WI.UIString("Ensure aria-hidden=\u0022%s\u0022 is not used.").format(WI.unlocalizedString("false")), supports: 1}), 399 new WI.AuditTestCase("testTreeRoleForRequiredChildren", WI.DefaultAudits.testTreeRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("tree")), supports: 1}), 400 new WI.AuditTestCase("testRadioGroupRoleForRequiredChildren", WI.DefaultAudits.testRadioGroupRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("radiogroup")), supports: 1}), 401 new WI.AuditTestCase("testFeedRoleForRequiredChildren", WI.DefaultAudits.testFeedRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("feed")), supports: 1}), 402 new WI.AuditTestCase("testTabListRoleForRequiredChildren", WI.DefaultAudits.testTabListRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("tablist")), supports: 1}), 403 new WI.AuditTestCase("testButtonLabels", WI.DefaultAudits.testButtonLabels.toString(), {description: WI.UIString("Ensure that buttons have accessible labels for assistive technology."), supports: 1}), 404 new WI.AuditTestCase("testRowRoleForRequiredChildren", WI.DefaultAudits.testRowRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("row")), supports: 1}), 405 new WI.AuditTestCase("testListRoleForRequiredChildren", WI.DefaultAudits.testListRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("list")), supports: 1}), 406 new WI.AuditTestCase("testComboBoxRoleForRequiredChildren", WI.DefaultAudits.testComboBoxRoleForRequiredChildren.toString(), {description: WI.UIString("Ensure that elements of role \u0022%s\u0022 have required owned elements in accordance with WAI-ARIA.").format(WI.unlocalizedString("combobox")), supports: 1}), 407 new WI.AuditTestCase("testForMultipleMainContentSections", WI.DefaultAudits.testForMultipleMainContentSections.toString(), {description: WI.UIString("Ensure that only one main content section is used on the page."), supports: 1}), 408 new WI.AuditTestCase("testDialogsForLabels", WI.DefaultAudits.testDialogsForLabels.toString(), {description: WI.UIString("Ensure that dialogs have accessible labels for assistive technology."), supports: 1}), 409 new WI.AuditTestCase("testForInvalidAriaHiddenValue", WI.DefaultAudits.testForInvalidAriaHiddenValue.toString(), {description: WI.UIString("Ensure that values for \u0022%s\u0022 are valid.").format(WI.unlocalizedString("aria-hidden")), supports: 1}) 1066 410 ], {description: WI.UIString("Diagnoses common accessibility problems affecting screen readers and other assistive technology.")}), 1067 411 ]; -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r276476 r276680 942 942 <script src="Debug/DebugContentView.js"></script> 943 943 944 <script src="NonMinified/DefaultAudits.js"></script> 945 944 946 <script src="WebKitAdditions/WebInspectorUI/WebInspectorUIAdditions.js"></script> 945 947 -
trunk/Source/WebInspectorUI/UserInterface/Test.html
r270637 r276680 287 287 <script src="Views/TreeOutline.js"></script> 288 288 289 <script src="NonMinified/DefaultAudits.js"></script> 290 289 291 <script type="text/javascript"> 290 292 WI.sharedApp = new WI.TestAppController;
Note: See TracChangeset
for help on using the changeset viewer.