Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / shadow / olderShadowRoot-in-shadowelement.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../../resources/js-test.js"></script>
5
6 <div id="container"></div>
7 <pre id="console"></div>
8
9 <script>
10 description('Confirms shadow.olderShadowRoot returns correct ShadowRoot');
11
12 function testCase(f)
13 {
14     host = document.createElement('div');
15     oldestShadowRoot = host.createShadowRoot();
16     youngerShadowRoot = host.createShadowRoot();
17
18     container.appendChild(host);
19
20     f();
21
22     container.innerHTML = "";
23     debug('');
24 }
25
26 testCase(function()
27 {
28     debug('shadow in younger ShadowDOM');
29     shadow = document.createElement('shadow');
30     youngerShadowRoot.appendChild(shadow);
31
32     shouldBe('shadow.olderShadowRoot', 'oldestShadowRoot');
33 });
34
35 testCase(function()
36 {
37     debug('shadow in the oldest ShadowDOM');
38     shadow = document.createElement('shadow');
39     oldestShadowRoot.appendChild(shadow);
40
41     shouldBe('shadow.olderShadowRoot', 'null');
42 });
43
44 testCase(function()
45 {
46     debug('2 active shadows');
47     shadow1 = document.createElement('shadow');
48     shadow2 = document.createElement('shadow');
49     youngerShadowRoot.appendChild(shadow1);
50     youngerShadowRoot.appendChild(shadow2);
51
52     shouldBe('shadow1.olderShadowRoot', 'oldestShadowRoot');
53     shouldBe('shadow2.olderShadowRoot', 'null');
54 });
55
56 testCase(function()
57 {
58     debug('the first shadow is not active');
59     shadow1 = document.createElement('shadow');
60     shadow2 = document.createElement('shadow');
61
62     var content = document.createElement('content');
63     content.appendChild(shadow1);
64
65     youngerShadowRoot.appendChild(content);
66     youngerShadowRoot.appendChild(shadow2);
67
68     shouldBe('shadow1.olderShadowRoot', 'null');
69     shouldBe('shadow2.olderShadowRoot', 'oldestShadowRoot');
70 });
71
72 testCase(function()
73 {
74     debug('nested ShadowDOM case');
75     nestedHost = document.createElement('div');
76     nestedOldestShadowRoot = nestedHost.createShadowRoot();
77     nestedYoungerShadowRoot = nestedHost.createShadowRoot();
78     oldestShadowRoot.appendChild(nestedHost);
79
80     shadow1 = document.createElement('shadow');
81     shadow2 = document.createElement('shadow');
82     nestedOldestShadowRoot.appendChild(shadow1);
83     nestedYoungerShadowRoot.appendChild(shadow2);
84
85     shouldBe('shadow1.olderShadowRoot', 'null');
86     shouldBe('shadow2.olderShadowRoot', 'nestedOldestShadowRoot');
87 });
88
89 testCase(function()
90 {
91     debug('orphan shadow');
92     shadow = document.createElement('shadow');
93     shouldBe('shadow.olderShadowRoot', 'null');
94 });
95
96 testCase(function()
97 {
98     debug('orphan Shadow DOM');
99     shadow = document.createElement('shadow');
100     youngerShadowRoot.appendChild(shadow);
101
102     container.removeChild(host);
103
104     shouldBe('shadow.olderShadowRoot', 'oldestShadowRoot');
105 });
106
107 container.innerHTML = '';
108 </script>
109 </body>
110 </html>