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].
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
13 <title>Shadow DOM Test: Invariants after distribution</title>
14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
15 <link rel="author" title="Yuta Kitamura" href="mailto:yutak@google.com">
16 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#lower-boundary-encapsulation">
17 <meta name="assert" content="Lower-boundary encapsulation: The distribution does not affect the state of the document tree or shadow trees">
18 <script src="../../../../../resources/testharness.js"></script>
19 <script src="../../../../../resources/testharnessreport.js"></script>
20 <script src="../../testcommon.js"></script>
21 <link rel="stylesheet" href="../../../../../resources/testharness.css">
26 var distributionTest = async_test(
27 'Distribution should not affect the state of the document trees and ' +
30 distributionTest.step(function () {
31 var shadowHost = document.createElement('ul');
32 shadowHost.innerHTML =
33 '<li class="first">host 1</li>' +
34 '<li class="second">host 2</li>';
35 shadowHost.style.visibility = 'hidden';
36 document.body.appendChild(shadowHost);
37 var host1 = shadowHost.querySelector('.first');
38 var host2 = shadowHost.querySelector('.second');
40 var shadowRoot = shadowHost.createShadowRoot();
41 shadowRoot.innerHTML =
42 '<li class="first">shadow 1</li>' +
43 '<content select=".second"></content>' +
44 '<li class="second">shadow 2</li>';
45 var shadow1 = shadowRoot.querySelector('.first');
46 var shadow2 = shadowRoot.querySelector('.second');
47 var content = shadowRoot.querySelector('content');
49 // Let the rendering happen.
50 window.setTimeout(distributionTest.step_func(function () {
51 assert_equals(host1.textContent, 'host 1');
52 assert_equals(host2.textContent, 'host 2');
53 assert_equals(shadow1.textContent, 'shadow 1');
54 assert_equals(shadow2.textContent, 'shadow 2');
55 assert_equals(content.textContent, '');
57 assert_equals(shadowHost.children.length, 2);
58 assert_equals(shadowHost.children[0], host1);
59 assert_equals(shadowHost.children[1], host2);
60 assert_equals(shadowRoot.children.length, 3);
61 assert_equals(shadowRoot.children[0], shadow1);
62 assert_equals(shadowRoot.children[1], content);
63 assert_equals(shadowRoot.children[2], shadow2);
65 assert_equals(host1.tagName, 'LI');
66 assert_equals(shadow1.tagName, 'LI');
67 assert_equals(content.tagName, 'CONTENT');
69 document.body.removeChild(shadowHost);
70 distributionTest.done();