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
5 policies and contribution forms [3].
7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
9 [3] http://www.w3.org/2004/10/27-testcases
13 <title>Shadow DOM Test: A_05_01_01</title>
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-retargeting">
16 <meta name="assert" content="Event Retargeting:test that event.target is retargeted when event crosses shadow boundary and vice versa">
17 <script src="../../../../../resources/testharness.js"></script>
18 <script src="../../../../../resources/testharnessreport.js"></script>
19 <script src="../../testcommon.js"></script>
20 <link rel="stylesheet" href="../../../../../resources/testharness.css">
25 var A_05_01_01_T1 = async_test('A_05_01_01_T1');
27 A_05_01_01_T1.step(function () {
28 var iframe = document.createElement('iframe');
29 iframe.src = '../../resources/blank.html';
30 document.body.appendChild(iframe);
32 iframe.onload = A_05_01_01_T1.step_func(function () {
35 var d = iframe.contentDocument;
36 var div = d.createElement('div');
37 d.body.appendChild(div);
39 var s = div.createShadowRoot();
41 var div2 = d.createElement('div');
44 var inp = d.createElement('input');
45 inp.setAttribute('type', 'text');
46 inp.setAttribute('id', 'inpid');
47 div2.appendChild(inp);
49 div2.addEventListener('click', A_05_01_01_T1.step_func(function (event) {
50 assert_equals(event.target.tagName, 'INPUT', 'Information about target of the event that ' +
51 'doesn\'t cross the shadow boundaries should not be adjusted');
54 var event = d.createEvent('HTMLEvents');
55 event.initEvent ("click", true, false);
56 inp.dispatchEvent(event);
58 iframe.parentNode.removeChild(iframe);
66 var A_05_01_01_T2 = async_test('A_05_01_01_T2');
68 A_05_01_01_T2.step(function () {
69 var iframe = document.createElement('iframe');
70 iframe.src = '../../resources/blank.html';
71 document.body.appendChild(iframe);
73 iframe.onload = A_05_01_01_T2.step_func(function () {
76 var d = iframe.contentDocument;
78 var div = d.createElement('div');
79 d.body.appendChild(div);
81 var s = div.createShadowRoot();
83 var div2 = d.createElement('div');
86 var inp = d.createElement('input');
87 inp.setAttribute('type', 'text');
88 inp.setAttribute('id', 'inpid');
89 div2.appendChild(inp);
91 div.addEventListener('click', A_05_01_01_T2.step_func(function (event) {
92 assert_equals(event.target.tagName, 'DIV', 'Information about event target crossing ' +
93 'the shadow boundaries should be adjusted');
96 var event = d.createEvent('HTMLEvents');
97 event.initEvent ("click", true, false);
98 inp.dispatchEvent(event);
100 iframe.parentNode.removeChild(iframe);
102 A_05_01_01_T2.done();