5 /* relative positioning ensures underlying RenderLayer */
11 display: boxed-inline;
16 <script src="../resources/shadow-test-driver.js"></script>
18 function testRemoveContent(callIfDone) {
19 var root = document.createElement('div');
22 root.innerHTML = "<span>LIGHT</span>";
24 // Create shadow tree.
25 var content = createContentWithSelect('span', 'FALLBACK');
26 var sr = root.createShadowRoot();
27 sr.appendChild(createSpanWithText("BEFORE"));
28 sr.appendChild(content);
29 sr.appendChild(createSpanWithText("AFTER"));
31 document.getElementById('actual-container').appendChild(root);
33 var f = (function(root, content, callIfDone) {
35 content.parentNode.removeChild(content);
36 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>AFTER</span></div>";
39 })(root, content, callIfDone);
44 function testRemoveContentToRecalc1(callIfDone) {
45 var root = document.createElement('div');
48 root.innerHTML = "<span class='c1'>LIGHT 1</span><span>LIGHT 2</span>";
50 // Create shadow tree.
51 var content1 = createContentWithSelect('.c1', 'FALLBACK');
52 var content2 = createContentWithSelect('span', 'FALLBACK');
53 var sr = root.createShadowRoot();
54 sr.appendChild(createSpanWithText("BEFORE"));
55 sr.appendChild(content1);
56 sr.appendChild(createSpanWithText("MID"));
57 sr.appendChild(content2);
58 sr.appendChild(createSpanWithText("AFTER"));
60 document.getElementById('actual-container').appendChild(root);
62 var f = (function(root, content1, callIfDone) {
64 content1.parentNode.removeChild(content1);
65 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>MID</span><span>LIGHT 1</span><span>LIGHT 2</span><span>AFTER</span></div>";
68 })(root, content1, callIfDone);
73 function testRemoveContentToRecalc2(callIfDone) {
74 var root = document.createElement('div');
77 root.innerHTML = "<span>LIGHT 1</span><span class='c1'>LIGHT 2</span>";
79 // Create shadow tree.
80 var content1 = createContentWithSelect('.c1', 'FALLBACK');
81 var content2 = createContentWithSelect('span', 'FALLBACK');
82 var sr = root.createShadowRoot();
83 sr.appendChild(createSpanWithText("BEFORE"));
84 sr.appendChild(content1);
85 sr.appendChild(createSpanWithText("MID"));
86 sr.appendChild(content2);
87 sr.appendChild(createSpanWithText("AFTER"));
89 document.getElementById('actual-container').appendChild(root);
91 var f = (function(root, content1, callIfDone) {
93 content1.parentNode.removeChild(content1);
94 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>MID</span><span>LIGHT 1</span><span>LIGHT 2</span><span>AFTER</span></div>";
97 })(root, content1, callIfDone);
102 function testRemoveContentAndRemoveLightChildren(callIfDone) {
103 var root = document.createElement('div');
105 // Create light tree.
106 root.innerHTML = "<span>LIGHT</span>";
108 // Create shadow tree.
109 var content = createContentWithSelect('span');
110 var sr = root.createShadowRoot();
111 sr.appendChild(createSpanWithText("BEFORE"));
112 sr.appendChild(content);
113 sr.appendChild(createSpanWithText("AFTER"));
115 document.getElementById('actual-container').appendChild(root);
117 var f = (function(root, content, callIfDone) {
119 content.parentNode.removeChild(content);
120 removeAllChildren(root);
121 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>AFTER</span></div>";
124 })(root, content, callIfDone);
129 function testAppendContent1(callIfDone) {
130 var root = document.createElement('div');
132 // Create light tree.
133 root.innerHTML = "<span>LIGHT</span>";
135 // Create shadow tree.
136 var sr = root.createShadowRoot();
137 sr.appendChild(createSpanWithText("BEFORE"));
138 sr.appendChild(createSpanWithText("AFTER"));
140 document.getElementById('actual-container').appendChild(root);
142 var f = (function(root, callIfDone) {
144 var content = createContentWithSelect('span', 'FALLBACK');
145 var sr = root.shadowRoot;
146 sr.insertBefore(content, sr.lastChild);
147 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><SPAN>LIGHT</span><span>AFTER</span></div>";
150 })(root, callIfDone);
155 function testAppendContent2(callIfDone) {
156 var root = document.createElement('div');
158 // Create light tree.
159 root.innerHTML = "<span>LIGHT 1</span><span class='c2'>LIGHT 2</span>";
161 // Create shadow tree.
162 var sr = root.createShadowRoot();
163 sr.appendChild(createSpanWithText("BEFORE"));
164 sr.appendChild(createSpanWithText("AFTER"));
166 document.getElementById('actual-container').appendChild(root);
168 var f = (function(root, callIfDone) {
170 var content1 = createContentWithSelect('.c2', 'FALLBACK');
171 var content2 = createContentWithSelect('span', 'FALLBACK');
172 var sr = root.shadowRoot;
173 sr.insertBefore(content1, sr.lastChild);
174 sr.insertBefore(content2, sr.lastChild);
175 document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>LIGHT 2</span><span>LIGHT 1</span><span>AFTER</span></div>";
178 })(root, callIfDone);
183 function testAppendContent3(callIfDone) {
184 var root = document.createElement('div');
186 // Create light tree.
187 root.innerHTML = "<span>LIGHT 1</span><span class='c2'>LIGHT 2</span>";
189 // Create shadow tree.
190 var sr = root.createShadowRoot();
191 var mid = createSpanWithText("MID");
192 sr.appendChild(createSpanWithText("BEFORE"));
194 sr.appendChild(createContentWithSelect('.c2', 'FALLBACK'));
195 sr.appendChild(createSpanWithText("AFTER"));
197 document.getElementById('actual-container').appendChild(root);
199 var f = (function(root, mid, callIfDone) {
201 var content = createContentWithSelect('span', 'FALLBACK');
202 var sr = root.shadowRoot;
203 sr.insertBefore(content, mid);
204 document.getElementById('expect-container').innerHTML =
205 "<div><span>BEFORE</span><span>LIGHT 1</span><span>LIGHT 2</span><span>MID</span><span>FALLBACK</span><span>AFTER</span></div>";
208 })(root, mid, callIfDone);
213 function testChangeOrderOfContent(callIfDone) {
214 var root = document.createElement('div');
216 // Create light tree.
217 root.innerHTML = "<span class='c1'>LIGHT 1</span><span>LIGHT 2</span>";
219 // Create shadow tree.
220 var sr = root.createShadowRoot();
221 var content1 = createContentWithSelect('.c1', 'FALLBACK');
222 var content2 = createContentWithSelect('span', 'FALLBACK');
223 sr.appendChild(createSpanWithText("BEFORE"));
224 sr.appendChild(content1);
225 sr.appendChild(content2);
226 sr.appendChild(createSpanWithText("AFTER"));
228 document.getElementById('actual-container').appendChild(root);
230 var f = (function(root, content1, callIfDone) {
232 var sr = root.shadowRoot;
233 sr.removeChild(content1);
234 sr.insertBefore(content1, sr.lastChild);
235 document.getElementById('expect-container').innerHTML =
236 "<div><span>BEFORE</span><SPAN>LIGHT 1</span><span>LIGHT 2</span><span>FALLBACK</span><span>AFTER</span></div>";
239 })(root, content1, callIfDone);
244 function testMoveLightChildOut(callIfDone) {
245 var root = document.createElement('div');
247 // Create light tree.
248 var n1 = document.createElement('div');
249 n1.setAttribute('id', 'n1');
250 n1.innerHTML = "<span id='light1'>LIGHT 1</span><span>LIGHT 2</span>";
251 var n2 = document.createElement('div');
252 n2.setAttribute('id', 'n2');
254 root.appendChild(n1);
255 root.appendChild(n2);
257 // Create shadow tree in 'n1'
258 var sr = n1.createShadowRoot();
259 var content = createContentWithSelect('span', 'FALLBACK');
260 sr.appendChild(createSpanWithText("BEFORE"));
261 sr.appendChild(content);
262 sr.appendChild(createSpanWithText("AFTER"));
264 document.getElementById('actual-container').appendChild(root);
266 var f = (function(root, n2, callIfDone) {
268 var e = document.getElementById('light1');
269 e.parentNode.removeChild(e);
272 document.getElementById('expect-container').innerHTML =
273 "<div><div><span>BEFORE</span><span>LIGHT 2</span><span>AFTER</span></div><div><span>LIGHT 1</span></div></div>"
276 })(root, n2, callIfDone);
281 function testInsertBeforeFallback(callIfDone) {
282 document.getElementById('expect-container').innerHTML =
283 "<div><span>BEFORE</span><span>HOGE</span><span>FALLBACK</span><span>AFTER</span></div>";
285 var target = document.createElement('div');
286 document.getElementById('actual-container').appendChild(target);
288 var span1 = document.createElement('span');
289 var root = span1.createShadowRoot();
290 root.appendChild(createContentWithText("FALLBACK"));
292 target.appendChild(createSpanWithText('BEFORE'));
293 target.appendChild(span1);
294 target.appendChild(createSpanWithText('AFTER'));
296 var f = (function(target, span1, callIfDone) { return function() {
297 target.insertBefore(createSpanWithText('HOGE'), span1);
299 };})(target, span1, callIfDone);
306 testRemoveContentToRecalc1,
307 testRemoveContentToRecalc2,
308 testRemoveContentAndRemoveLightChildren,
312 testChangeOrderOfContent,
313 testMoveLightChildOut,
314 testInsertBeforeFallback
319 <body onload="doTest(testFuncs)">
321 <div id="actual-container" class="container"></div>
322 <div id="expect-container" class="container"></div>
323 <pre id="console"></pre>