1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1269155
-->
<head>
<title>Test for Bug 1269155</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1269155">Mozilla Bug 1269155</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 1269155 **/
var host = document.querySelector('#content');
var root = host.createShadowRoot();
var header1 = document.createElement('h1');
header1.textContent = 'Shadow Header1';
var paragraph1 = document.createElement('p');
paragraph1.textContent = 'shadow text paragraph1';
root.appendChild(header1);
root.appendChild(paragraph1);
var root2 = paragraph1.createShadowRoot();
var header2 = document.createElement('h2');
header2.textContent = 'Shadow Header2';
var paragraph2 = document.createElement('p');
paragraph2.textContent = 'shadow text paragraph2';
root2.appendChild(header2);
root2.appendChild(paragraph2);
var frag = document.createDocumentFragment();
var paragraph3 = document.createElement('p');
paragraph3.textContent = 'fragment paragraph3';
frag.appendChild(paragraph3);
var root3 = paragraph3.createShadowRoot();
var header4 = document.createElement('h2');
header4.textContent = 'Shadow Header3';
var paragraph4 = document.createElement('p');
paragraph4.textContent = 'shadow text paragraph4';
root3.appendChild(header4);
root3.appendChild(paragraph4);
//shadow dom without compose
is(root.getRootNode(), root, "root.getRootNode() should be root.");
is(root2.getRootNode(), root2, "root2.getRootNode() should be root.");
is(root3.getRootNode(), root3, "root3.getRootNode() should be root.");
is(header1.getRootNode(), root, "header1.getRootNode() should be root.");
is(header2.getRootNode(), root2, "header1.getRootNode() should be root2.");
is(header4.getRootNode(), root3, "header1.getRootNode() should be root3.");
//shadow dom with compose
is(root.getRootNode({ composed: true }), document, "root.getRootNode() with composed flag should be document.");
is(root2.getRootNode({ composed: true }), document, "root2.getRootNode() with composed flag should be document.");
is(root3.getRootNode({ composed: true }), frag, "root3.getRootNode() with composed flag should be frag.");
is(header1.getRootNode({ composed: true }) , document, "header1.getRootNode() with composed flag should be document.");
is(header2.getRootNode({ composed: true }) , document, "header2.getRootNode() with composed flag should be document.");
is(header4.getRootNode({ composed: true }) , frag, "head4.getRootNode() with composed flag should be frag.");
//dom without compose
is(host.getRootNode(), document, "host.getRootNode() should be document.");
is(header1.getRootNode(), root, "header1.getRootNode() should be root.");
is(paragraph1.getRootNode(), root, "paragraph1.getRootNode() should be root.");
is(frag.getRootNode(), frag, "frag.getRootNode() should be frag.");
//dom with compose
is(host.getRootNode({ composed: true }) , document, "host.getRootNode() with composed flag should be document.");
is(header1.getRootNode({ composed: true }) , document, "header1.getRootNode() with composed flag should be document.");
is(paragraph1.getRootNode({ composed: true }) , document, "paragraph1.getRootNode() with composed flag should be document.");
is(frag.getRootNode({ composed: true }) , frag, "frag.getRootNode() with composed flag should be frag.");
</script>
</pre>
</body>
</html>
|