OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 var sameOrigin = 'http://127.0.0.1:8000' |
| 6 var crossOrigin = 'http://localhost:8000' |
| 7 var filePath = '/loading/resources/js-loaded.js' |
| 8 var jsLoaded = false; |
| 9 var loadSuccess = false; |
4 | 10 |
5 <style> | 11 src = crossOrigin + filePath; |
6 .hideAllContainers .container { | 12 document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true"></s
cr' + 'ipt>'); |
7 display: none; | |
8 } | |
9 </style> | |
10 | |
11 <div class="container"> | |
12 <img id="img1" src="resources/cake.png"> | |
13 </div> | |
14 | |
15 <script> | |
16 test(function(t) { | |
17 var axImg1 = accessibilityController.accessibleElementById("img1"); | |
18 assert_equals(axImg1.name, ""); | |
19 }, "img element without alt"); | |
20 </script> | |
21 | |
22 <div class="container"> | |
23 <img id="img2" title="img2-title" src="resources/cake.png"> | |
24 </div> | |
25 | |
26 <script> | |
27 test(function(t) { | |
28 var axImg2 = accessibilityController.accessibleElementById("img2"); | |
29 assert_equals(axImg2.name, "img2-title"); | |
30 assert_equals(axImg2.nameFrom, "attribute"); | |
31 }, "img element without alt, with title"); | |
32 </script> | |
33 | |
34 <div class="container"> | |
35 <img id="img3" title="img3-title" alt="img3-alt" src="resources/cake.png"> | |
36 </div> | |
37 | |
38 <script> | |
39 test(function(t) { | |
40 var axImg3 = accessibilityController.accessibleElementById("img3"); | |
41 assert_equals(axImg3.name, "img3-alt"); | |
42 assert_equals(axImg3.nameFrom, "attribute"); | |
43 }, "img element with title and alt"); | |
44 </script> | |
45 | |
46 <div class="container"> | |
47 <img id="img4" title="img4-title" alt="img4-alt" aria-label="img4-aria-label"
src="resources/cake.png"> | |
48 </div> | |
49 | |
50 <script> | |
51 test(function(t) { | |
52 var axImg4 = accessibilityController.accessibleElementById("img4"); | |
53 assert_equals(axImg4.name, "img4-aria-label"); | |
54 assert_equals(axImg4.nameFrom, "attribute"); | |
55 }, "img element with title and alt"); | |
56 </script> | |
57 | |
58 <div class="container"> | |
59 <img id="img5" title="img5-title" alt="img5-alt" aria-label="img5-aria-label"
aria-labelledby="labelledby5" src="resources/cake.png"> | |
60 <span hidden="true" id="labelledby5">img5-aria-labelledby</span> | |
61 </div> | |
62 | |
63 <script> | |
64 test(function(t) { | |
65 var axImg5 = accessibilityController.accessibleElementById("img5"); | |
66 assert_equals(axImg5.name, "img5-aria-labelledby"); | |
67 assert_equals(axImg5.nameFrom, "relatedElement"); | |
68 }, "img element with title and alt"); | |
69 </script> | 13 </script> |
70 | 14 |
71 <script> | 15 <script> |
72 if (window.testRunner) | 16 test(function () { |
73 document.body.className = "hideAllContainers"; | 17 assert_true(jsLoaded); |
| 18 assert_true(loadSuccess); |
| 19 }, "Blocking of scripts doesn't come into effect since feature is disabled")
; |
| 20 |
74 </script> | 21 </script> |
| 22 <script> |
| 23 if (window.internals) { |
| 24 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrame(true)
; |
| 25 internals.setNetworkStateNotifierTestOnly(true); |
| 26 internals.setNetworkConnectionInfo('cellular2g', 1.0); |
| 27 internals.evictAllResources(); |
| 28 |
| 29 // Reset the state of the singleton network state notifier. |
| 30 window.addEventListener('beforeunload', function() { |
| 31 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrame(f
alse); |
| 32 internals.setNetworkStateNotifierTestOnly(false); |
| 33 }, false); |
| 34 } |
| 35 |
| 36 src = sameOrigin + filePath; |
| 37 jsLoaded = false; |
| 38 loadSuccess = false; |
| 39 document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true"></s
cr' + 'ipt>'); |
| 40 </script> |
| 41 |
| 42 <script> |
| 43 test(function () { |
| 44 assert_true(jsLoaded); |
| 45 assert_true(loadSuccess); |
| 46 }, "Same domain doc.written scripts are not blocked"); |
| 47 </script> |
| 48 |
| 49 <script> |
| 50 var jsLoaded = false; |
| 51 var loadSuccess = false; |
| 52 |
| 53 src = crossOrigin + filePath; |
| 54 document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true"></s
cr' + 'ipt>'); |
| 55 </script> |
| 56 |
| 57 <script> |
| 58 test(function () { |
| 59 assert_true(jsLoaded); |
| 60 assert_true(loadSuccess); |
| 61 }, "cross-origin script not blocked since it is cached"); |
| 62 |
| 63 </script> |
| 64 <script> |
| 65 jsLoaded = false; |
| 66 loadSuccess = false; |
| 67 var loadFailed = false; |
| 68 |
| 69 filePath = '/loading/resources/js-loaded.js?1'; |
| 70 src = crossOrigin + filePath; |
| 71 document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true" onE
rror="loadFailed=true"></scr' + 'ipt>'); |
| 72 </script> |
| 73 |
| 74 <script> |
| 75 test(function () { |
| 76 assert_false(jsLoaded); |
| 77 assert_false(loadSuccess); |
| 78 assert_true(loadFailed); |
| 79 }, "cross origin doc.written scripts are blocked"); |
| 80 </script> |
OLD | NEW |