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 <div id=host> | 5 <div id=host> |
6 <template id=shadowRoot data-mode=open> | 6 <template id=shadowRoot data-mode=open> |
7 <div id=target></div> | 7 <div id=target></div> |
8 </template> | 8 </template> |
9 </div> | 9 </div> |
10 <script> | 10 <script> |
11 test(() => { | 11 test(() => { |
12 const e = new Event('test'); | 12 const e = new Event('test'); |
13 assert_equals(e.composed, false); | 13 assert_equals(e.composed, false); |
14 }, 'A new events composed value should be set to false by default.'); | 14 }, 'A new events composed value should be set to false by default.'); |
15 | 15 |
16 test(() => { | 16 test(() => { |
17 const e = new Event('test', { composed: true }); | 17 const e = new Event('test', { composed: true }); |
18 assert_equals(e.composed, true); | 18 assert_equals(e.composed, true); |
19 }, 'Users should be able to set a composed value.'); | 19 }, 'Users should be able to set a composed value.'); |
20 | 20 |
21 function assertScoped(event) { | 21 function assertScoped(event) { |
22 let nodes = createTestTree(host); | 22 let nodes = createTestTree(host); |
23 let log = dispatchEventWithLog(nodes, nodes.target, event); | 23 let log = dispatchEventWithLog(nodes, nodes.target, event); |
24 let expectedPath = ['target', 'shadowRoot']; | 24 let expectedPath = ['target', 'shadowRoot']; |
25 assert_event_path_equals(log, | 25 assert_event_path_equals(log, |
26 [['target', null, expectedPath], | 26 [['target', 'target', null, expectedPath], |
27 ['shadowRoot', null, expectedPath]]); | 27 ['shadowRoot', 'target', null, expectedPath]]); |
28 } | 28 } |
29 | 29 |
30 function assertComposed(event) { | 30 function assertComposed(event) { |
31 let nodes = createTestTree(host); | 31 let nodes = createTestTree(host); |
32 let log = dispatchEventWithLog(nodes, nodes.target, event); | 32 let log = dispatchEventWithLog(nodes, nodes.target, event); |
33 let expectedPath = ['target', 'shadowRoot', 'host']; | 33 let expectedPath = ['target', 'shadowRoot', 'host']; |
34 assert_event_path_equals(log, | 34 assert_event_path_equals(log, |
35 [['target', null, expectedPath], | 35 [['target', 'target', null, expectedPath], |
36 ['shadowRoot', null, expectedPath], | 36 ['shadowRoot', 'target', null, expectedPath], |
37 ['host', null, expectedPath]]); | 37 ['host', 'host', null, expectedPath]]); |
38 } | 38 } |
39 | 39 |
40 test(() => { | 40 test(() => { |
41 assertScoped(new Event('test', { bubbles: true })); | 41 assertScoped(new Event('test', { bubbles: true })); |
42 }, 'An event should be scoped by default'); | 42 }, 'An event should be scoped by default'); |
43 | 43 |
44 test(() => { | 44 test(() => { |
45 assertComposed(new Event('test', { bubbles: true, composed: true })); | 45 assertComposed(new Event('test', { bubbles: true, composed: true })); |
46 }, 'An event should not be scoped if composed is specified'); | 46 }, 'An event should not be scoped if composed is specified'); |
47 | 47 |
(...skipping 11 matching lines...) Expand all Loading... |
59 | 59 |
60 test(() => { | 60 test(() => { |
61 assertComposed(new FocusEvent('focus', { bubbles: true, composed: true })); | 61 assertComposed(new FocusEvent('focus', { bubbles: true, composed: true })); |
62 }, 'A synthetic FocusEvent with composed=true should not be scoped'); | 62 }, 'A synthetic FocusEvent with composed=true should not be scoped'); |
63 | 63 |
64 function assertUAComposed(eventType, callback) { | 64 function assertUAComposed(eventType, callback) { |
65 let nodes = createTestTree(host); | 65 let nodes = createTestTree(host); |
66 let log = dispatchUAEventWithLog(nodes, nodes.target, eventType, callback); | 66 let log = dispatchUAEventWithLog(nodes, nodes.target, eventType, callback); |
67 let expectedPath = ['target', 'shadowRoot', 'host']; | 67 let expectedPath = ['target', 'shadowRoot', 'host']; |
68 assert_event_path_equals(log, | 68 assert_event_path_equals(log, |
69 [['target', null, expectedPath], | 69 [['target', 'target', null, expectedPath], |
70 ['shadowRoot', null, expectedPath], | 70 ['shadowRoot', 'target', null, expectedPath], |
71 ['host', null, expectedPath]]); | 71 ['host', 'host', null, expectedPath]]); |
72 } | 72 } |
73 | 73 |
74 test(() => { | 74 test(() => { |
75 assertUAComposed('click', (target) => { target.click(); }); | 75 assertUAComposed('click', (target) => { target.click(); }); |
76 }, 'A UA click event should not be scoped'); | 76 }, 'A UA click event should not be scoped'); |
77 | 77 |
78 // TODO(hayato): Test other UIEvents. | 78 // TODO(hayato): Test other UIEvents. |
79 </script> | 79 </script> |
OLD | NEW |