OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../../resources/testharness.js"></script> | |
3 <script src="../../../resources/testharnessreport.js"></script> | |
4 <script src="resources/shadow-dom.js"></script> | |
5 <img id="img" src="../../images/resources/test-load.jpg"> | |
6 <div id="sandbox"> | |
7 <div id = "host"> | |
8 <template> | |
9 <img id="target" src="../../images/resources/test-load.jpg"> | |
10 </template> | |
11 </div> | |
12 </div> | |
13 <script> | |
14 setup({ explicit_done: true }); | |
15 var e; | |
16 test(function() { | |
17 e = new Event('test'); | |
18 assert_equals(e.scoped, false); | |
19 }, "A new event's scoped value should be set to false by default."); | |
20 | |
21 test(function() { | |
22 e = new Event('test', { scoped: true }); | |
23 assert_equals(e.scoped, true); | |
24 }, 'Users should be able to set a scoped value.'); | |
25 | |
26 img.onload = function (e) { | |
hayato
2016/01/15 03:59:52
Nit: Remove a space between "function" and "(e)".
yuzuchan
2016/01/15 05:32:27
Done.
| |
27 test(function () { | |
hayato
2016/01/15 03:59:52
Nit: "function ()" => "function()"
yuzuchan
2016/01/15 05:32:27
Done.
| |
28 assert_equals(e.scoped, true); | |
29 }, "UA load event's scoped should be set to true"); | |
30 }; | |
31 | |
32 var resultTrusted = []; | |
33 var resultNonTrusted = []; | |
34 | |
35 function addEventListeners(nodes) | |
36 { | |
37 for (var i = 0; i < nodes.length; ++i) { | |
38 var node = getNodeInTreeOfTrees(nodes[i]); | |
39 node.addEventListener('load', recordEvent, false); | |
40 node.addEventListener('error', recordEvent, false); | |
41 } | |
42 } | |
43 var eventCount = 0; | |
44 function recordEvent(event) | |
45 { | |
46 if (event.type == 'load'){ | |
hayato
2016/01/15 03:59:52
Nit. One space is required. between ")" and "{"
yuzuchan
2016/01/15 05:32:27
Done.
yuzuchan
2016/01/15 05:32:27
Done.
yuzuchan
2016/01/15 05:32:27
Done.
| |
47 if(event.currentTarget){ | |
hayato
2016/01/15 03:59:52
I guess event.currentTarget is always non-null.
Ca
hayato
2016/01/15 03:59:52
Ditto. One space is required. ") {"
yuzuchan
2016/01/15 05:32:27
Done.
yuzuchan
2016/01/15 05:32:27
Done.
| |
48 resultTrusted.push(event.currentTarget.id); | |
49 } | |
50 }else if (event.type == 'error'){ | |
hayato
2016/01/15 03:59:52
Ditto:
- "} else if"
- ") {"
yuzuchan
2016/01/15 05:32:27
Done.
| |
51 if(event.currentTarget){ | |
52 resultNonTrusted.push(event.currentTarget.id); | |
53 } | |
54 } | |
55 eventCount++; | |
56 if (eventCount == 3) { | |
hayato
2016/01/15 03:59:52
This is assuming that "load" event happens before
yuzuchan
2016/01/15 05:32:27
Very true. Fixed in Patch 3. Done.
On 2016/01/15
| |
57 test(function () { | |
hayato
2016/01/15 03:59:52
Nit: "function ()" => "function()"
yuzuchan
2016/01/15 05:32:27
Done.
| |
58 assert_array_equals(resultTrusted,['target']); | |
hayato
2016/01/15 03:59:52
Nit: One space is required after ","
yuzuchan
2016/01/15 05:32:27
Done.
| |
59 assert_array_equals(resultNonTrusted, ['target', 'host']); | |
60 }, "Only certain trusted events like load should stop in bubbling."); | |
61 done(); | |
62 } | |
63 } | |
64 var sandbox = document.getElementById('sandbox'); | |
65 convertTemplatesToShadowRootsWithin(sandbox); | |
66 var targetImg = getNodeInTreeOfTrees('host/target'); | |
67 addEventListeners(['host', 'host/target']); | |
68 | |
69 targetImg.setAttribute('src', '../../images/resources/lenna.jpg'); | |
70 var userError = new Event('error'); | |
71 targetImg.dispatchEvent(userError); | |
72 | |
73 </script> | |
OLD | NEW |