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 | 5 <div id=host label=host> |
6 <div id="log"></div> | 6 <template label=shadowRoot data-mode=open> |
7 <div id="sandbox"> | 7 <input label="input1"></input> |
kochi
2016/06/03 02:31:47
nit: <input> doesn't need closing tag.
| |
8 <div id="top"> | 8 <input label="input2"></input> |
9 <div id="host"> | 9 </template> |
10 <template> | |
11 <input id="input1"></input> | |
12 <input id="input2"></input> | |
13 </template> | |
14 </div> | |
15 </div> | |
16 </div> | 10 </div> |
17 <script> | 11 <script> |
18 | 12 test(() => { |
19 var sandbox = document.getElementById('sandbox'); | 13 let nodes = createTestTree(host); |
20 convertTemplatesToShadowRootsWithin(sandbox); | 14 let log = dispatchEventWithLog(nodes, nodes['input1'], |
21 | 15 new FocusEvent('test', { bubbles: true, related Target: nodes['input2']})); |
22 var host = document.getElementById('host'); | 16 let expectedPath = ['input1', 'shadowRoot']; |
23 var topDiv = document.getElementById('top'); | 17 assert_event_path_equals(log, |
24 var sr = host.shadowRoot; | 18 [['input1', 'input2', expectedPath], |
25 | 19 ['shadowRoot', 'input2', expectedPath]]); |
26 var input1 = getNodeInComposedTree('host/input1'); | 20 }, 'An event should stop at the common ancestor of target and relatedTarget.'); |
27 var input2 = getNodeInComposedTree('host/input2'); | |
28 | |
29 async_test(function(t) { | |
30 input2.onfocus = function(e) { | |
31 t.step(function() { | |
32 assert_false(e.relatedTargetScoped); | |
33 var expected1 = [input2, sr, host, topDiv, sandbox, document.body, documen t.documentElement, document, window]; | |
34 assert_array_equals(e.path, expected1); | |
35 t.done(); | |
36 }); | |
37 }; | |
38 }, 'Event paths of untrusted events with relatedTargetScoped false do not stop.' ); | |
39 | |
40 async_test(function(t) { | |
41 input1.onfocus = function(e) { | |
42 t.step(function() { | |
43 assert_true(e.relatedTargetScoped); | |
44 var expected2 = [input1, sr]; | |
45 assert_array_equals(e.path, expected2); | |
46 t.done(); | |
47 }); | |
48 }; | |
49 }, 'Event paths of untrusted events with relatedTargetScoped true stop at the co mmon ancestor of the target & the related target.'); | |
50 | |
51 var userFocus1 = new FocusEvent('focus', { relatedTarget: input1 }); | |
52 input2.dispatchEvent(userFocus1); | |
53 | |
54 var userFocus2 = new FocusEvent('focus', { relatedTarget: input2, relatedTargetS coped: true }); | |
55 input1.dispatchEvent(userFocus2); | |
56 </script> | 21 </script> |
OLD | NEW |