|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=806506 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for ShadowRoot styles with multiple ShadowRoot on host.</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <div class="tall" id="bodydiv"></div> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a> |
|
14 <script> |
|
15 // Create ShadowRoot. |
|
16 var elem = document.createElement("div"); |
|
17 var firstRoot = elem.createShadowRoot(); |
|
18 var secondRoot = elem.createShadowRoot(); |
|
19 var thirdRoot = elem.createShadowRoot(); |
|
20 |
|
21 // A style element that will be appended into the ShadowRoot. |
|
22 var firstStyle = document.createElement("style"); |
|
23 firstRoot.appendChild(firstStyle); |
|
24 is(firstRoot.styleSheets.length, 1, "firstStyle should be the only style in firstRoot."); |
|
25 is(firstRoot.styleSheets[0].ownerNode, firstStyle, "firstStyle should in the ShadowRoot styleSheets."); |
|
26 |
|
27 var secondStyle = document.createElement("style"); |
|
28 secondRoot.appendChild(secondStyle); |
|
29 is(secondRoot.styleSheets.length, 1, "secondStyle should be the only style in secondRoot."); |
|
30 is(secondRoot.styleSheets[0].ownerNode, secondStyle, "secondStyle should in the ShadowRoot styleSheets."); |
|
31 |
|
32 var thirdStyle = document.createElement("style"); |
|
33 thirdRoot.appendChild(thirdStyle); |
|
34 is(thirdRoot.styleSheets.length, 1, "thirdStyle should be the only style in thirdRoot."); |
|
35 is(thirdRoot.styleSheets[0].ownerNode, thirdStyle, "thirdStyle should in the ShadowRoot styleSheets."); |
|
36 |
|
37 // Check the stylesheet counts again to make sure that none of the style sheets leaked into the older ShadowRoots. |
|
38 is(firstRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot."); |
|
39 is(secondRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot."); |
|
40 |
|
41 // Remove styles and make sure they are removed from the correct ShadowRoot. |
|
42 firstRoot.removeChild(firstStyle); |
|
43 is(firstRoot.styleSheets.length, 0, "firstRoot should no longer have any styles."); |
|
44 |
|
45 thirdRoot.removeChild(thirdStyle); |
|
46 is(thirdRoot.styleSheets.length, 0, "thirdRoot should no longer have any styles."); |
|
47 |
|
48 secondRoot.removeChild(secondStyle); |
|
49 is(secondRoot.styleSheets.length, 0, "secondRoot should no longer have any styles."); |
|
50 |
|
51 </script> |
|
52 </body> |
|
53 </html> |
|
54 |