OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Distributed under both the W3C Test Suite License [1] and the W3C | 3 Distributed under both the W3C Test Suite License [1] and the W3C |
4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the | 4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
5 policies and contribution forms [3]. | 5 policies and contribution forms [3]. |
6 | 6 |
7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license | 7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license | 8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
9 [3] http://www.w3.org/2004/10/27-testcases | 9 [3] http://www.w3.org/2004/10/27-testcases |
10 --> | 10 --> |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 <title>Shadow DOM Test: A_05_05_03</title> | 13 <title>Shadow DOM Test: A_05_05_03</title> |
14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> | 14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#event-d
ispatch"> | 15 <link rel="help" href="https://w3c.github.io/webcomponents/spec/shadow/#event-pa
th-trimming"> |
16 <meta name="assert" content="Event Dispatch: If the relatedTarget and target are
the same for a given node, its the event listeners must not be invoked."> | 16 <meta name="assert" content="Event Path Trimming: In cases where both relatedTar
get and target of a trusted event are part of the same shadow tree, the conformi
ng UAs must stop events at the shadow root to avoid the appearance of spurious m
ouseover and mouseout events firing from the same node."> |
17 <script src="../../../../../resources/testharness.js"></script> | 17 <script src="../../../../../resources/testharness.js"></script> |
18 <script src="../../../../../resources/testharnessreport.js"></script> | 18 <script src="../../../../../resources/testharnessreport.js"></script> |
19 <script src="../../testcommon.js"></script> | 19 <script src="../../testcommon.js"></script> |
20 <link rel="stylesheet" href="../../../../../resources/testharness.css"> | 20 <link rel="stylesheet" href="../../../../../resources/testharness.css"> |
21 </head> | 21 </head> |
22 <body> | 22 <body> |
23 <div id="log"></div> | 23 <div id="log"></div> |
24 <script> | 24 <script> |
25 var A_05_05_03_T01 = async_test('A_05_05_03_T01'); | 25 var A_05_05_03_T01 = async_test('A_05_05_03_T01'); |
26 | 26 |
27 A_05_05_03_T01.step(unit(function (ctx) { | 27 A_05_05_03_T01.step(unit(function (ctx) { |
28 | 28 |
29 var d = newRenderedHTMLDocument(ctx); | 29 var d = newRenderedHTMLDocument(ctx); |
30 | 30 |
31 var host = d.createElement('div'); | 31 var host = d.createElement('div'); |
32 host.setAttribute('style', 'height:50%; width:100%'); | |
33 host.setAttribute('id', 'host'); | 32 host.setAttribute('id', 'host'); |
34 d.body.appendChild(host); | 33 d.body.appendChild(host); |
35 | 34 |
36 //Shadow root to play with | 35 //Shadow root to play with |
37 var s = host.createShadowRoot(); | 36 var s = host.createShadowRoot(); |
| 37 s.id = 'shadow'; |
38 | 38 |
39 var div1 = d.createElement('div'); | 39 var input1 = d.createElement('input'); |
40 div1.setAttribute('style', 'height:100%; width:100%'); | 40 input1.setAttribute('id', 'input1'); |
41 div1.setAttribute('id', 'div1'); | 41 s.appendChild(input1); |
42 s.appendChild(div1); | |
43 | 42 |
44 s.addEventListener('mouseover', A_05_05_03_T01.step_func(function(event) { | 43 var input2 = d.createElement('input'); |
45 » assert_true(false, 'Event listeners shouldn\'t be invoked if target and
relatedTarget ' + | 44 input2.setAttribute('id', 'input2'); |
46 » » » 'are the same'); | 45 s.appendChild(input2); |
| 46 |
| 47 input1.addEventListener('focusin', A_05_05_03_T01.step_func(function(event)
{ |
| 48 assert_equals(event.deepPath.length, 7); |
| 49 assert_equals(event.deepPath[0].id, 'input1'); |
| 50 assert_equals(event.deepPath[1].id, 'shadow'); |
| 51 assert_equals(event.deepPath[2].id, 'host'); |
| 52 assert_equals(event.deepPath[3].tagName, 'BODY'); |
| 53 assert_equals(event.deepPath[4].tagName, 'HTML'); |
| 54 assert_equals(event.deepPath[5], d); |
| 55 assert_equals(event.deepPath[6], ctx.iframes[0].contentWindow); |
47 }), false); | 56 }), false); |
48 | 57 |
| 58 input2.addEventListener('focusin', A_05_05_03_T01.step_func(function(event)
{ |
| 59 assert_equals(event.deepPath.length, 2); |
| 60 assert_equals(event.deepPath[0].id, 'input2'); |
| 61 assert_equals(event.deepPath[1].id, 'shadow'); |
| 62 A_05_05_03_T01.done(); |
| 63 }), false); |
49 | 64 |
50 var evt = document.createEvent("MouseEvents"); | 65 // Expected event path for #input1: |
51 evt.initMouseEvent("mouseover", true, false, window, | 66 // <input>, #shadow-root, <div>, <body>, <html>, #document, window |
52 0, 10, 10, 10, 10, false, false, false, false, 0, div1); | 67 input1.focus(); |
53 | 68 |
54 div1.dispatchEvent(evt); | 69 // Causes a "focusin" event, from #input1 to #input2 |
55 | 70 // In this case, original relatedTarget is #input1, and original target |
56 A_05_05_03_T01.done(); | 71 // is #input2. |
| 72 // It should be viewed outside the shadow as "target == relatedTarget" |
| 73 // after event retargeting, therefore, event.deepPath above the shadow |
| 74 // host will be trimmed. |
| 75 // Expected event path for #input2: |
| 76 // <input>, #shadow-root |
| 77 input2.focus(); |
57 })); | 78 })); |
58 </script> | 79 </script> |
59 </body> | 80 </body> |
60 </html> | 81 </html> |
OLD | NEW |