Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<?xml version="1.0"?>
<!--
vim: set ts=2 et sw=2 tw=80:
Any copyright is dedicated to the Public Domain.
-->
<?xml-stylesheet type="text/css" href="test_bug727834.css"?>
        onload="RunTests();">
  <script type="application/javascript"><![CDATA[
function RunTests() {
  SimpleTest.waitForExplicitFinish();
  let body = document.querySelector("body");
  let testSheet = document.styleSheets[2];
  let rule = document.styleSheets[2].cssRules[0];
  is(testSheet.cssRules.length, 1,
     "style sheet has 1 rule");
  is(rule.style.paddingTop, "100px",
     "original first rule has padding-top 100px");
  is(window.getComputedStyle(body).paddingTop, "100px",
     "original first rule applies");
  InspectorUtils.parseStyleSheet(testSheet,
    "@import url(test_bug727834.css); body{background: red;}");
  is(testSheet.cssRules.length, 2,
     "style sheet now has 2 rules");
  is(window.getComputedStyle(body).backgroundColor, "rgb(255, 0, 0)",
     "background is now red");
  let exceptionName;
  try {
    rule.style.paddingLeft = "100px";
  } catch (ex) {
    exceptionName = ex.name;
  } finally {
    is(exceptionName, "NS_ERROR_NOT_AVAILABLE",
       "original rule is not available for modification anymore");
  }
  is(window.getComputedStyle(body).paddingLeft, "0px",
     "original rule does not apply to document");
  rule = testSheet.cssRules[0];
  is(rule.parentStyleSheet, testSheet,
     "rule's parent style sheet is not null");
  InspectorUtils.parseStyleSheet(testSheet,
    "body{background: lime;}");
  is(testSheet.cssRules.length, 1,
     "style sheet now has 1 rule");
  is(window.getComputedStyle(body).backgroundColor, "rgb(0, 255, 0)",
     "background is now lime");
  is(rule.parentStyleSheet, null,
     "detached rule's parent style sheet is null");
  SimpleTest.executeSoon(function () {
    InspectorUtils.parseStyleSheet(testSheet,
      "@import url(test_bug727834.css); body{background: blue;}");
    is(testSheet.cssRules.length, 2,
       "style sheet now has 2 rules");
    is(window.getComputedStyle(body).backgroundColor, "rgb(0, 0, 255)",
       "background is now blue");
    is(testSheet.cssRules[0].parentStyleSheet, testSheet,
       "parent style sheet is the test sheet");
    SimpleTest.finish();
  });
}
  ]]></script>
    </a>
  </body>
</window>