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 src="resources/shadow-dom.js"></script> | 4 <script src="resources/shadow-dom.js"></script> |
5 <img id="img" src="../../images/resources/test-load.jpg"> | 5 <img id="img" src="../../images/resources/test-load.jpg" onload="loadScopeTest() " onerror="imgLoadTest()"> |
kochi
2016/01/28 07:01:12
There's still a chance that these handlers are nev
yuzuchan
2016/02/01 08:42:48
Done.
| |
6 <div id="sandbox"> | 6 <div id="sandbox"> |
7 <div id = "host"> | 7 <div id = "host" onload="loadStopTest()" onerror="errorBubbleTest()"> |
8 <template> | 8 <template> |
9 <img id="target" src="../../images/resources/test-load.jpg"> | 9 <img id="target" onload="loadStopTest()" onerror="errorBubbleTest()" > |
10 </template> | 10 </template> |
11 </div> | 11 </div> |
12 </div> | 12 </div> |
13 <script> | 13 <script> |
14 setup({ explicit_done: true }); | |
15 var e; | 14 var e; |
16 test(function() { | 15 test(function() { |
17 e = new Event('test'); | 16 e = new Event('test'); |
18 assert_equals(e.scoped, false); | 17 assert_equals(e.scoped, false); |
19 }, "A new event's scoped value should be set to false by default."); | 18 }, 'A new events scoped value should be set to false by default.'); |
kochi
2016/01/28 07:01:12
FYI - you can quote a single quote in a string lik
yuzuchan
2016/02/01 08:42:48
Done.
| |
20 | 19 |
21 test(function() { | 20 test(function() { |
22 e = new Event('test', { scoped: true }); | 21 e = new Event('test', { scoped: true }); |
23 assert_equals(e.scoped, true); | 22 assert_equals(e.scoped, true); |
24 }, 'Users should be able to set a scoped value.'); | 23 }, 'Users should be able to set a scoped value.'); |
25 | 24 |
26 img.onload = function(e) { | 25 function loadScopeTest() { |
27 test(function() { | 26 test(function() { |
28 assert_equals(e.scoped, true); | 27 assert_equals(event.scoped, true); |
kochi
2016/01/28 07:01:12
Where is this |event| coming from?
s/loadScopedTe
yuzuchan
2016/02/01 08:42:49
Done.
| |
29 }, "UA load event's scoped should be set to true"); | 28 }, 'UA load events scoped should be set to true.'); |
30 }; | 29 } |
30 | |
31 function imgLoadTest() { | |
32 test(function() { | |
33 assert_true(false); | |
34 }, 'Image should be loaded.'); | |
35 } | |
31 | 36 |
32 var resultNonTrusted = []; | 37 var resultNonTrusted = []; |
33 | 38 |
34 function addEventListeners(nodes) | 39 function loadStopTest() { |
35 { | 40 if (event.currentTarget.id == 'host'){ |
36 for (var i = 0; i < nodes.length; ++i) { | 41 test(function() { |
37 var node = getNodeInTreeOfTrees(nodes[i]); | 42 assert_true(false); |
38 node.addEventListener('load', recordEvent, false); | 43 }, 'Load event should be stopped if created by UAs.'); |
39 node.addEventListener('error', recordEvent, false); | 44 } else { |
45 test(function() { | |
kochi
2016/01/28 07:01:12
I don't think this test addresses original concern
yuzuchan
2016/02/01 08:42:49
Done.
| |
46 assert_equals(event.currentTarget.id, 'target'); | |
47 }, 'Event fired in the right place.'); | |
40 } | 48 } |
41 } | 49 } |
42 | 50 |
43 function recordEvent(event) | 51 function errorBubbleTest() { |
44 { | 52 test(function() { |
45 if (event.type == 'load') { | 53 if (event.isTrusted) |
46 if (event.currentTarget.id == 'host'){ | 54 assert_true(false); |
47 test(function() { | 55 }, 'Image should be loaded.'); |
48 assert_true(false); | 56 resultNonTrusted.push(event.currentTarget.id); |
49 }, "Load event should be stopped if created by UAs."); | 57 if (resultNonTrusted.length == 2) { |
50 } else { | 58 test(function() { |
51 test(function() { | 59 assert_array_equals(resultNonTrusted, ['target', 'host']); |
52 assert_equals(event.currentTarget.id, 'target'); | 60 }, 'Only certain trusted events should stop in bubbling.'); |
53 }, "Event fired in the right place."); | |
54 } | |
55 } | |
56 if (event.type == 'error') { | |
57 resultNonTrusted.push(event.currentTarget.id); | |
58 if (resultNonTrusted.length == 2) { | |
59 test(function() { | |
60 assert_array_equals(resultNonTrusted, ['target', 'host']); | |
61 }, "Only certain trusted events should stop in bubbling."); | |
62 done(); | |
63 } | |
64 } | 61 } |
65 } | 62 } |
66 | 63 |
67 var sandbox = document.getElementById('sandbox'); | 64 var sandbox = document.getElementById('sandbox'); |
68 convertTemplatesToShadowRootsWithin(sandbox); | 65 convertTemplatesToShadowRootsWithin(sandbox); |
69 var targetImg = getNodeInTreeOfTrees('host/target'); | 66 var targetImg = getNodeInTreeOfTrees('host/target'); |
70 addEventListeners(['host', 'host/target']); | |
71 | 67 |
72 targetImg.setAttribute('src', '../../images/resources/lenna.jpg'); | 68 targetImg.setAttribute('src', '../../images/resources/lenna.jpg'); |
73 var userError = new Event('error'); | 69 var userError = new Event('error'); |
74 targetImg.dispatchEvent(userError); | 70 targetImg.dispatchEvent(userError); |
75 | 71 |
76 </script> | 72 </script> |
OLD | NEW |