dom/tests/mochitest/webcomponents/test_shadowroot_inert_element.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_inert_element.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     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 inert elements in ShadowRoot</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 onload="runChecks();">
    1.15 +<div id="grabme"></div>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a>
    1.17 +<script>
    1.18 +
    1.19 +var element = document.getElementById("grabme");
    1.20 +var shadow = element.createShadowRoot();
    1.21 +
    1.22 +// Check that <base> is inert.
    1.23 +shadow.innerHTML = '<base href="http://www.example.org/" />';
    1.24 +isnot(document.baseURI, "http://www.example.org/", "Base element should be inert in ShadowRoot.");
    1.25 +
    1.26 +SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +// Check that <link> is inert.
    1.29 +var numStyleBeforeLoad = document.styleSheets.length;
    1.30 +
    1.31 +shadow.innerHTML = '<link id="shadowlink" rel="stylesheet" type="text/css" href="inert_style.css" /><span id="shadowspan"></span>';
    1.32 +shadow.applyAuthorStyles = true;
    1.33 +var shadowSpan = shadow.getElementById("shadowspan");
    1.34 +var shadowStyle = shadow.getElementById("shadowlink");
    1.35 +
    1.36 +function runChecks() {
    1.37 +  isnot(getComputedStyle(shadowSpan, null).getPropertyValue("padding-top"), "10px", "Link element should be inert.");
    1.38 +  is(document.styleSheets.length, numStyleBeforeLoad, "Document style count should remain the same because the style should not be in the doucment.");
    1.39 +  is(shadow.styleSheets.length, 0, "Inert link should not add style to ShadowRoot.");
    1.40 +  // Remove link to make sure we don't get assertions.
    1.41 +  shadow.removeChild(shadowStyle);
    1.42 +  SimpleTest.finish();
    1.43 +};
    1.44 +
    1.45 +</script>
    1.46 +</body>
    1.47 +</html>

mercurial