dom/tests/mochitest/webcomponents/test_shadowroot_style_multiple_shadow.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/webcomponents/test_shadowroot_style_multiple_shadow.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=806506
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for ShadowRoot styles with multiple ShadowRoot on host.</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<div class="tall" id="bodydiv"></div>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a>
    1.17 +<script>
    1.18 +// Create ShadowRoot.
    1.19 +var elem = document.createElement("div");
    1.20 +var firstRoot = elem.createShadowRoot();
    1.21 +var secondRoot = elem.createShadowRoot();
    1.22 +var thirdRoot = elem.createShadowRoot();
    1.23 +
    1.24 +// A style element that will be appended into the ShadowRoot.
    1.25 +var firstStyle = document.createElement("style");
    1.26 +firstRoot.appendChild(firstStyle);
    1.27 +is(firstRoot.styleSheets.length, 1, "firstStyle should be the only style in firstRoot.");
    1.28 +is(firstRoot.styleSheets[0].ownerNode, firstStyle, "firstStyle should in the ShadowRoot styleSheets.");
    1.29 +
    1.30 +var secondStyle = document.createElement("style");
    1.31 +secondRoot.appendChild(secondStyle);
    1.32 +is(secondRoot.styleSheets.length, 1, "secondStyle should be the only style in secondRoot.");
    1.33 +is(secondRoot.styleSheets[0].ownerNode, secondStyle, "secondStyle should in the ShadowRoot styleSheets.");
    1.34 +
    1.35 +var thirdStyle = document.createElement("style");
    1.36 +thirdRoot.appendChild(thirdStyle);
    1.37 +is(thirdRoot.styleSheets.length, 1, "thirdStyle should be the only style in thirdRoot.");
    1.38 +is(thirdRoot.styleSheets[0].ownerNode, thirdStyle, "thirdStyle should in the ShadowRoot styleSheets.");
    1.39 +
    1.40 +// Check the stylesheet counts again to make sure that none of the style sheets leaked into the older ShadowRoots.
    1.41 +is(firstRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot.");
    1.42 +is(secondRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot.");
    1.43 +
    1.44 +// Remove styles and make sure they are removed from the correct ShadowRoot.
    1.45 +firstRoot.removeChild(firstStyle);
    1.46 +is(firstRoot.styleSheets.length, 0, "firstRoot should no longer have any styles.");
    1.47 +
    1.48 +thirdRoot.removeChild(thirdStyle);
    1.49 +is(thirdRoot.styleSheets.length, 0, "thirdRoot should no longer have any styles.");
    1.50 +
    1.51 +secondRoot.removeChild(secondStyle);
    1.52 +is(secondRoot.styleSheets.length, 0, "secondRoot should no longer have any styles.");
    1.53 +
    1.54 +</script>
    1.55 +</body>
    1.56 +</html>
    1.57 +

mercurial