| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Shadow DOM: Event path and Event.composedPath() (with related target)</ti
tle> | 2 <title>Shadow DOM: Event path and Event.composedPath() (with related target)</ti
tle> |
| 3 <meta name="author" title="Hayato Ito" href="mailto:hayato@google.com"> | 3 <meta name="author" title="Hayato Ito" href="mailto:hayato@google.com"> |
| 4 <script src="/resources/testharness.js"></script> | 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> | 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="resources/shadow-dom.js"></script> | 6 <script src="resources/shadow-dom.js"></script> |
| 7 | 7 |
| 8 <div id="test1"> | 8 <div id="test1"> |
| 9 <div id="target"></div> | 9 <div id="target"></div> |
| 10 <div id="related"></div> | 10 <div id="related"></div> |
| 11 </div> | 11 </div> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 test(() => { | 14 test(() => { |
| 15 let n = createTestTree(test1); | 15 let n = createTestTree(test1); |
| 16 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.related })); | 16 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.related })); |
| 17 let path = ['target', 'test1']; | 17 let path = ['target', 'test1']; |
| 18 assert_event_path_equals(log, [['target', 'target', 'related', path], | 18 assert_event_path_equals(log, [['target', 'target', 'related', path], |
| 19 ['test1', 'target', 'related', path]]); | 19 ['test1', 'target', 'related', path]]); |
| 20 }, 'Event path for an event with a relatedTarget. relatedTarget != target.'); | 20 }, 'Event path for an event with a relatedTarget. relatedTarget != target.'); |
| 21 </script> | 21 </script> |
| 22 | 22 |
| 23 <script> | 23 <script> |
| 24 test(() => { | 24 test(() => { |
| 25 let n = createTestTree(test1); | 25 let n = createTestTree(test1); |
| 26 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.target })); | 26 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.target })); |
| 27 let path = ['target', 'test1']; | 27 let path = ['target', 'test1']; |
| 28 assert_event_path_equals(log, [['target', 'target', 'target', path], | 28 assert_event_path_equals(log, [['target', 'target', 'target', path], |
| 29 ['test1', 'target', 'target', path]]); | 29 ['test1', 'target', 'target', path]]); |
| 30 }, 'Event path for an event with a relatedTarget. Event shoul be dispatched if 1
) target and relatedTarget are same, and 2) they are not in a shadow tree.'); | 30 }, 'Event path for an event with a relatedTarget. Event should be dispatched eve
n when target and relatedTarget are same.'); |
| 31 </script> | 31 </script> |
| 32 | 32 |
| 33 <div id="test2"> | 33 <div id="test2"> |
| 34 <div id="host"> | 34 <div id="host"> |
| 35 <template id="sr" data-mode="open"> | 35 <template id="sr" data-mode="open"> |
| 36 <div id="target"></div> | 36 <div id="target"></div> |
| 37 <div id="related"></div> | 37 <div id="related"></div> |
| 38 </template> | 38 </template> |
| 39 </div> | 39 </div> |
| 40 </div> | 40 </div> |
| 41 | 41 |
| 42 <script> | 42 <script> |
| 43 test(() => { | 43 test(() => { |
| 44 let n = createTestTree(test2); | 44 let n = createTestTree(test2); |
| 45 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.related })); | 45 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.related })); |
| 46 let path = ['target', 'sr']; | 46 let path = ['target', 'sr']; |
| 47 assert_event_path_equals(log, [['target', 'target', 'related', path], | 47 assert_event_path_equals(log, [['target', 'target', 'related', path], |
| 48 ['sr', 'target', 'related', path]]); | 48 ['sr', 'target', 'related', path]]); |
| 49 }, 'Event path for an event with a relatedTarget. Event should stop at the shado
w root'); | 49 }, 'Event path for an event with a relatedTarget. Event should stop at the shado
w root'); |
| 50 | 50 |
| 51 test(() => { | 51 test(() => { |
| 52 let n = createTestTree(test2); | 52 let n = createTestTree(test2); |
| 53 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.target })); | 53 let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbl
es: true, composed: true, relatedTarget: n.target })); |
| 54 assert_event_path_equals(log, []); | 54 let path = ['target', 'sr']; |
| 55 }, 'Event path for an event with a relatedTarget. Event should not be dispatched
if 1) target and relatedTarget are same, and 2) both are in a shadow tree.'); | 55 assert_event_path_equals(log, [['target', 'target', 'target', path], |
| 56 ['sr', 'target', 'target', path]]); |
| 57 }, 'Event path for an event with a relatedTarget which is identical to target. E
vent should be dispatched and should stop at the shadow root.'); |
| 56 </script> | 58 </script> |
| 57 | 59 |
| 58 <div id="test3_1"> | 60 <div id="test3_1"> |
| 59 <div id="host1"> | 61 <div id="host1"> |
| 60 <template id="sr1" data-mode="open"> | 62 <template id="sr1" data-mode="open"> |
| 61 <div id="target1"></div> | 63 <div id="target1"></div> |
| 62 </template> | 64 </template> |
| 63 </div> | 65 </div> |
| 64 </div> | 66 </div> |
| 65 | 67 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 let path = ['target', 'sr2', 'host2', 'sr1']; | 129 let path = ['target', 'sr2', 'host2', 'sr1']; |
| 128 assert_event_path_equals(log, [['target', 'target', 'host1', path], | 130 assert_event_path_equals(log, [['target', 'target', 'host1', path], |
| 129 ['sr2', 'target', 'host1', path], | 131 ['sr2', 'target', 'host1', path], |
| 130 ['host2', 'host2', 'host1', path], | 132 ['host2', 'host2', 'host1', path], |
| 131 ['sr1', 'host2', 'host1', path]]); | 133 ['sr1', 'host2', 'host1', path]]); |
| 132 }, 'Event path for an event with a relatedTarget. relaterTarget is a shadow-incl
uding ancestor of target.'); | 134 }, 'Event path for an event with a relatedTarget. relaterTarget is a shadow-incl
uding ancestor of target.'); |
| 133 | 135 |
| 134 test(() => { | 136 test(() => { |
| 135 let n = createTestTree(test4); | 137 let n = createTestTree(test4); |
| 136 let log = dispatchEventWithLog(n, n.host1, new FocusEvent('my-focus', { bubble
s: true, composed: true, relatedTarget: n.target })); | 138 let log = dispatchEventWithLog(n, n.host1, new FocusEvent('my-focus', { bubble
s: true, composed: true, relatedTarget: n.target })); |
| 137 assert_event_path_equals(log, []); | 139 let path = ['host1', 'test4']; |
| 140 assert_event_path_equals(log, [['host1', 'host1', 'host1', path], |
| 141 ['test4', 'host1', 'host1', path]]); |
| 138 }, 'Event path for an event with a relatedTarget. target is a shadow-including a
ncestor of relatedTarget.'); | 142 }, 'Event path for an event with a relatedTarget. target is a shadow-including a
ncestor of relatedTarget.'); |
| 139 </script> | 143 </script> |
| 140 | 144 |
| 141 <div id="test5"> | 145 <div id="test5"> |
| 142 <div id="host"> | 146 <div id="host"> |
| 143 <template id="sr" data-mode="open"> | 147 <template id="sr" data-mode="open"> |
| 144 <slot id="slot"></slot> | 148 <slot id="slot"></slot> |
| 145 <div id="related"></div> | 149 <div id="related"></div> |
| 146 </template> | 150 </template> |
| 147 <div id="target"></div> | 151 <div id="target"></div> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 ['slot1', 'host3', 'host2', path], | 251 ['slot1', 'host3', 'host2', path], |
| 248 ['d1' , 'host3', 'host2', path], | 252 ['d1' , 'host3', 'host2', path], |
| 249 ['slot2', 'host3', 'related2', path], | 253 ['slot2', 'host3', 'related2', path], |
| 250 ['sr2', 'host3', 'related2', path], | 254 ['sr2', 'host3', 'related2', path], |
| 251 ['host2', 'host3', 'host2', path], | 255 ['host2', 'host3', 'host2', path], |
| 252 ['sr1', 'host3', 'host2', path], | 256 ['sr1', 'host3', 'host2', path], |
| 253 ['host1', 'host3', 'host1', path], | 257 ['host1', 'host3', 'host1', path], |
| 254 ['sr0', 'host3', 'host1' , path]]); | 258 ['sr0', 'host3', 'host1' , path]]); |
| 255 }, 'Event path for an event with a relatedTarget. Event should be dispatched at
every slots. relatedTarget should be correctly retargeted.'); | 259 }, 'Event path for an event with a relatedTarget. Event should be dispatched at
every slots. relatedTarget should be correctly retargeted.'); |
| 256 </script> | 260 </script> |
| OLD | NEW |