summaryrefslogtreecommitdiffstats
path: root/layout/inspector/tests/chrome/test_bug727834.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /layout/inspector/tests/chrome/test_bug727834.xhtml
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/inspector/tests/chrome/test_bug727834.xhtml')
-rw-r--r--layout/inspector/tests/chrome/test_bug727834.xhtml86
1 files changed, 86 insertions, 0 deletions
diff --git a/layout/inspector/tests/chrome/test_bug727834.xhtml b/layout/inspector/tests/chrome/test_bug727834.xhtml
new file mode 100644
index 0000000000..03c72c4cff
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug727834.xhtml
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<!--
+vim: set ts=2 et sw=2 tw=80:
+Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<?xml-stylesheet type="text/css" href="test_bug727834.css"?>
+<window title="Mozilla Bug 727834"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="RunTests();">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript"><![CDATA[
+/** Test for Bug 727834 - Add an API to (re)parse a style sheet in place **/
+
+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>
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=727834">
+ Mozilla Bug 727834 - Add an API to (re)parse a style sheet in place
+ </a>
+ </body>
+</window>