Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / shadow-dom / events / event-retargeting / test-001.html
1 <!DOCTYPE html>
2 <!-- 
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].
6
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
10  -->
11 <html>
12 <head>
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">
21 </head>
22 <body>
23 <div id="log"></div>
24 <script>
25 var A_05_01_01_T1 = async_test('A_05_01_01_T1');
26
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);
31
32     iframe.onload = A_05_01_01_T1.step_func(function () {
33
34     try {
35         var d = iframe.contentDocument;
36         var div = d.createElement('div');
37         d.body.appendChild(div);
38
39         var s = div.createShadowRoot();
40
41         var div2 = d.createElement('div');
42         s.appendChild(div2);
43
44         var inp = d.createElement('input');
45         inp.setAttribute('type', 'text');
46         inp.setAttribute('id', 'inpid');
47         div2.appendChild(inp);
48
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');
52         }), false);
53
54         var event = d.createEvent('HTMLEvents');
55         event.initEvent ("click", true, false);
56         inp.dispatchEvent(event);
57     } finally {
58         iframe.parentNode.removeChild(iframe);
59     }
60     A_05_01_01_T1.done();
61     });
62 });
63
64
65
66 var A_05_01_01_T2 = async_test('A_05_01_01_T2');
67
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);
72
73     iframe.onload = A_05_01_01_T2.step_func(function () {
74
75     try {
76         var d = iframe.contentDocument;
77
78         var div = d.createElement('div');
79         d.body.appendChild(div);
80
81         var s = div.createShadowRoot();
82
83         var div2 = d.createElement('div');
84         s.appendChild(div2);
85
86         var inp = d.createElement('input');
87         inp.setAttribute('type', 'text');
88         inp.setAttribute('id', 'inpid');
89         div2.appendChild(inp);
90
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');
94         }), false);
95
96         var event = d.createEvent('HTMLEvents');
97         event.initEvent ("click", true, false);
98         inp.dispatchEvent(event);
99     } finally {
100         iframe.parentNode.removeChild(iframe);
101     }
102     A_05_01_01_T2.done();
103     });
104 });
105 </script>
106 </body>
107 </html>