Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / shadow-dom / shadow-trees / hosting-multiple-shadow-trees / test-002.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_04_05_02</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/#multiple-shadow-subtrees">
16 <meta name="assert" content="Hosting Multiple Shadow Subtrees:If multiple shadow insertion points exist in a shadow DOM subtree, only the first, in tree order, is recognized">
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_04_05_02_T1 = async_test('A_04_05_02_T01');
26
27 A_04_05_02_T1.step(function () {
28     var iframe = document.createElement('iframe');
29     iframe.src = '../../resources/bobs_page.html';
30     document.body.appendChild(iframe);
31
32     iframe.onload = A_04_05_02_T1.step_func(function () {
33         try {
34             var d = iframe.contentDocument;
35             var ul = d.querySelector('ul.stories');
36
37             //make the oldest shadow subtree
38             var s1 = ul.createShadowRoot();
39             var subdiv1 = d.createElement('div');
40             subdiv1.innerHTML = '<ul><content select="#li1"></content></ul>';
41             s1.appendChild(subdiv1);
42
43             //make an old shadow subtree
44             var s2 = ul.createShadowRoot();
45             var subdiv2 = d.createElement('div');
46             subdiv2.innerHTML = '<ul><content select=".shadow"></content></ul>';
47             s2.appendChild(subdiv2);
48
49             //make the youngest shadow subtree
50             var s3 = ul.createShadowRoot();
51             var subdiv3 = d.createElement('div');
52             subdiv3.innerHTML = '<ul><content select=".shadow2"></content></ul>';
53             s3.appendChild(subdiv3);
54
55             //add a shadow insertion point for the old tree
56             s3.appendChild(d.createElement('shadow'));
57             //add another shadow insertion point for the older tree.
58             //Shouldn't match
59             s3.appendChild(d.createElement('shadow'));
60
61
62             //The order of DOM elements should be the following:
63             //li4, li3, li6 visible. Other elements invisible
64             assert_true(d.querySelector('#li4').offsetTop > 0,
65                 'Only the younger tree should take part in the distribution');
66             assert_true(d.querySelector('#li3').offsetTop > d.querySelector('#li4').offsetTop,
67                         'Point 1: Older tree should take part in the distribution');
68             assert_true(d.querySelector('#li6').offsetTop > d.querySelector('#li3').offsetTop,
69                         'Point 2: Older tree should take part in the distribution');
70
71             assert_equals(d.querySelector('#li1').offsetTop, 0,
72                 'The oldest tree shouldn\'t take part in the distribution');
73             assert_equals(d.querySelector('#li2').offsetTop, 0,
74                 'Point 3: Elements that don\'t mach insertion point criteria participate in distribution');
75             assert_equals(d.querySelector('#li5').offsetTop, 0,
76                 'Point 4: Elements that don\'t mach insertion point criteria participate in distribution');
77
78         } finally {
79             iframe.parentNode.removeChild(iframe);
80         }
81         A_04_05_02_T1.done();
82     });
83 });
84 </script>
85 </body>
86 </html>