summaryrefslogtreecommitdiffstats
path: root/layout/inspector/tests/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'layout/inspector/tests/chrome')
-rw-r--r--layout/inspector/tests/chrome/GentiumPlus-R.woffbin0 -> 660480 bytes
-rw-r--r--layout/inspector/tests/chrome/chrome.ini12
-rw-r--r--layout/inspector/tests/chrome/test_bug467669.css8
-rw-r--r--layout/inspector/tests/chrome/test_bug467669.xul174
-rw-r--r--layout/inspector/tests/chrome/test_bug695639.css8
-rw-r--r--layout/inspector/tests/chrome/test_bug695639.xul80
-rw-r--r--layout/inspector/tests/chrome/test_bug708874.css33
-rw-r--r--layout/inspector/tests/chrome/test_bug708874.xul296
-rw-r--r--layout/inspector/tests/chrome/test_bug727834.css7
-rw-r--r--layout/inspector/tests/chrome/test_bug727834.xul88
10 files changed, 706 insertions, 0 deletions
diff --git a/layout/inspector/tests/chrome/GentiumPlus-R.woff b/layout/inspector/tests/chrome/GentiumPlus-R.woff
new file mode 100644
index 000000000..ebefd081a
--- /dev/null
+++ b/layout/inspector/tests/chrome/GentiumPlus-R.woff
Binary files differ
diff --git a/layout/inspector/tests/chrome/chrome.ini b/layout/inspector/tests/chrome/chrome.ini
new file mode 100644
index 000000000..ef4b74bda
--- /dev/null
+++ b/layout/inspector/tests/chrome/chrome.ini
@@ -0,0 +1,12 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files = GentiumPlus-R.woff
+
+[test_bug467669.css]
+[test_bug467669.xul]
+[test_bug695639.css]
+[test_bug695639.xul]
+[test_bug708874.css]
+[test_bug708874.xul]
+[test_bug727834.css]
+[test_bug727834.xul]
diff --git a/layout/inspector/tests/chrome/test_bug467669.css b/layout/inspector/tests/chrome/test_bug467669.css
new file mode 100644
index 000000000..fb050bf31
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug467669.css
@@ -0,0 +1,8 @@
+@font-face {
+ font-family: font-face-test-family;
+ src: url(bad/font/name.ttf), url(GentiumPlus-R.woff) format("woff");
+}
+
+.gentium {
+ font-family: font-face-test-family;
+}
diff --git a/layout/inspector/tests/chrome/test_bug467669.xul b/layout/inspector/tests/chrome/test_bug467669.xul
new file mode 100644
index 000000000..a5ecd32a7
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug467669.xul
@@ -0,0 +1,174 @@
+<?xml version="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_bug467669.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=467669
+-->
+<window title="Mozilla Bug 467669"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="RunTest();">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+ /** Test for Bug 467669 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function RunTest() {
+ const CI = Components.interfaces;
+ const CC = Components.classes;
+
+ const kIsLinux = navigator.platform.indexOf("Linux") == 0;
+ const kIsMac = navigator.platform.indexOf("Mac") == 0;
+ const kIsWin = navigator.platform.indexOf("Win") == 0;
+
+ var domUtils =
+ CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
+
+ var rng = document.createRange();
+ var elem, fonts, f;
+
+ elem = document.getElementById("test1");
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts for simple Latin text");
+ f = fonts.item(0);
+ is(f.rule, null, "rule");
+ is(f.srcIndex, -1, "srcIndex");
+ is(f.localName, "", "local name");
+ is(f.URI, "", "URI");
+ is(f.format, "", "format string");
+ is(f.metadata, "", "metadata");
+// report(elem.id, fonts);
+
+ elem = document.getElementById("test2");
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 3, "number of fonts for mixed serif, sans and monospaced text");
+// report(elem.id, fonts);
+
+ elem = document.getElementById("test3");
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 2, "number of fonts for mixed Latin & Chinese");
+// report(elem.id, fonts);
+
+ // get properties of a @font-face font
+ elem = document.getElementById("test4");
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts in @font-face test");
+ f = fonts.item(0);
+ isnot(f.rule, null, "missing rule");
+ is(f.srcIndex, 1, "srcIndex");
+ is(f.localName, "", "local name");
+ is(f.URI, "chrome://mochitests/content/chrome/layout/inspector/tests/chrome/GentiumPlus-R.woff", "bad URI");
+ is(f.format, "woff", "format");
+ is(/bukva:raz/.test(f.metadata), true, "metadata");
+// report(elem.id, fonts);
+
+ elem = document.getElementById("test5").childNodes[0];
+ // check that string length is as expected, including soft hyphens
+ is(elem.length, 42, "string length with soft hyphens");
+
+ // initial latin substring...
+ rng.setStart(elem, 0);
+ rng.setEnd(elem, 20); // "supercalifragilistic"
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts (Latin-only)");
+ f = fonts.item(0);
+ is(f.name, "Gentium Plus", "font name");
+ is(f.CSSFamilyName, "font-face-test-family", "family name");
+ is(f.fromFontGroup, true, "font matched in font group");
+
+ // extend to include a chinese character
+ rng.setEnd(elem, 21);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 2, "number of fonts (incl Chinese)");
+ if (kIsMac || kIsWin) { // these are only implemented by the Mac & Win font backends
+ var i;
+ for (i = 0; i < fonts.length; ++i) {
+ f = fonts.item(i);
+ if (f.rule) {
+ is(f.fromFontGroup, true, "@font-face font matched in group");
+ is(f.fromLanguagePrefs, false, "not from language prefs");
+ is(f.fromSystemFallback, false, "not from system fallback");
+ } else {
+ is(f.fromFontGroup, false, "not matched in group");
+ is(f.fromLanguagePrefs, true, "from language prefs");
+ is(f.fromSystemFallback, false, "not from system fallback");
+ }
+ }
+ }
+
+ // second half of the string includes &shy; chars to check original/skipped mapping;
+ // select just the final character
+ rng.setStart(elem, elem.length - 1);
+ rng.setEnd(elem, elem.length);
+ is(rng.toString(), "!", "content of range");
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts for last char");
+ f = fonts.item(0);
+ is(f.name, "Gentium Plus", "font name");
+
+ // include the preceding character as well
+ rng.setStart(elem, elem.length - 2);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 2, "number of fonts for last two chars");
+
+ // then trim the final one
+ rng.setEnd(elem, elem.length - 1);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts for Chinese char");
+ f = fonts.item(0);
+ isnot(f.name, "Gentium Plus", "font name for Chinese char");
+
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+// report("test5", fonts);
+
+ elem = document.getElementById("test6");
+ rng.selectNode(elem);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 2, "number of font faces for regular & italic");
+ is(fonts.item(0).CSSFamilyName, fonts.item(1).CSSFamilyName, "same family for regular & italic");
+ isnot(fonts.item(0).name, fonts.item(1).name, "different faces for regular & italic");
+// report(elem.id, fonts);
+
+ SimpleTest.finish();
+}
+
+// just for test-debugging purposes
+function report(e, f) {
+ var fontNames = "";
+ var i;
+ for (i = 0; i < f.length; ++i) {
+ if (i == 0) {
+ fontNames += e + " fonts: "
+ } else {
+ fontNames += ", ";
+ }
+ fontNames += f.item(i).name;
+ }
+ dump(fontNames + "\n");
+}
+
+ ]]>
+ </script>
+
+ <!-- html:body contains elements the test will inspect -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=467669"
+ target="_blank">Mozilla Bug 467669</a>
+ <div id="test1">Hello world</div>
+ <div id="test2" style="font-family:sans-serif"><span style="font-family:serif">Hello</span> <tt>cruel</tt> world</div>
+ <div id="test3">Hello, &#x4F60;&#x597D;</div>
+ <div id="test4" class="gentium">Hello Gentium Plus!</div>
+ <div id="test5" class="gentium">supercalifragilistic&#x4F60;ex&#xAD;pi&#xAD;a&#xAD;li&#xAD;do&#xAD;cious&#x597D;!</div>
+ <div id="test6" style="font-family:serif">regular and <em>italic</em> text</div>
+ </body>
+
+</window>
diff --git a/layout/inspector/tests/chrome/test_bug695639.css b/layout/inspector/tests/chrome/test_bug695639.css
new file mode 100644
index 000000000..549537498
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug695639.css
@@ -0,0 +1,8 @@
+@font-face {
+ font-family: gent;
+ src: url(GentiumPlus-R.woff) format("woff");
+}
+
+.test {
+ font-family: gent, sans-serif;
+}
diff --git a/layout/inspector/tests/chrome/test_bug695639.xul b/layout/inspector/tests/chrome/test_bug695639.xul
new file mode 100644
index 000000000..cc2c879c9
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug695639.xul
@@ -0,0 +1,80 @@
+<?xml version="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_bug695639.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=695639
+-->
+<window title="Mozilla Bug 695639"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="RunTest();">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+ /** Test for Bug 695639 - check that GetFontFacesForText handles wrapped lines properly **/
+
+SimpleTest.waitForExplicitFinish();
+
+function RunTest() {
+ const CI = Components.interfaces;
+ const CC = Components.classes;
+
+ var domUtils =
+ CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
+
+ var rng = document.createRange();
+ var elem, fonts, f;
+
+ elem = document.getElementById("test").childNodes[0];
+ rng.setStart(elem, 0);
+ rng.setEnd(elem, 14);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 2, "number of fonts used for entire text");
+
+ // initial latin substring...
+ rng.setStart(elem, 0);
+ rng.setEnd(elem, 5); // "Hello"
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts (1)");
+ f = fonts.item(0);
+ is(f.name, "Gentium Plus", "font name (1)");
+
+ // the space (where the line wraps) should also be Gentium
+ rng.setStart(elem, 5);
+ rng.setEnd(elem, 6); // space
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts (2)");
+ f = fonts.item(0);
+ is(f.name, "Gentium Plus", "font name (2)");
+
+ // the Chinese text "ni hao" should NOT be in Gentium
+ rng.setStart(elem, 6);
+ rng.setEnd(elem, 8); // two Chinese characters on second line
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts (3)");
+ f = fonts.item(0);
+ isnot(f.name, "Gentium Plus", "font name (3)");
+
+ // space and "world" should be Gentium again
+ rng.setStart(elem, 8);
+ rng.setEnd(elem, 14);
+ fonts = domUtils.getUsedFontFaces(rng);
+ is(fonts.length, 1, "number of fonts (4)");
+ f = fonts.item(0);
+ is(f.name, "Gentium Plus", "font name (4)");
+
+ SimpleTest.finish();
+}
+ ]]>
+ </script>
+
+ <style type="text/css">
+ </style>
+
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=695639"
+ target="_blank">Mozilla Bug 695639</a>
+ <div style="width: 2em;" class="test" id="test">Hello &#x4F60;&#x597D; world</div>
+ </body>
+
+</window>
diff --git a/layout/inspector/tests/chrome/test_bug708874.css b/layout/inspector/tests/chrome/test_bug708874.css
new file mode 100644
index 000000000..539c44538
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug708874.css
@@ -0,0 +1,33 @@
+#test-div {
+ color: rgb(0, 0, 0);
+ font-family: serif;
+ font-weight: 400;
+}
+
+#test-div:hover {
+ color: rgb(10, 0, 0);
+}
+
+#test-div:active {
+ font-family: Arial;
+}
+
+#test-div:focus {
+ font-weight: 800;
+}
+
+#test-button {
+ color: rgb(0, 0, 0);
+}
+
+#test-button:disabled {
+ color: rgb(40, 0, 0);
+}
+
+#test-link:visited {
+ color: rgb(20, 0, 0);
+}
+
+#test-link:link {
+ color: rgb(30, 0, 0);
+}
diff --git a/layout/inspector/tests/chrome/test_bug708874.xul b/layout/inspector/tests/chrome/test_bug708874.xul
new file mode 100644
index 000000000..0896d1eca
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug708874.xul
@@ -0,0 +1,296 @@
+<?xml version="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_bug708874.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=708874
+-->
+<window title="Mozilla Bug 708874"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="RunTests();">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+
+/** Test for Bug 708874 - API for locking pseudo-class state of an element **/
+
+var DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+ .getService(Components.interfaces.inIDOMUtils);
+var DOMWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindowUtils);
+
+var defaultColor = "rgb(0, 0, 0)";
+var disabledColor = "rgb(40, 0, 0)";
+
+function RunTests() {
+ testLockEnabled();
+ testLockDisabled();
+ testVisited();
+ testMultiple();
+ testInvalid();
+ testNotElement();
+}
+
+function testLockEnabled() {
+ var button = document.getElementById("test-button");
+
+ /* starting state is enabled */
+ button.removeAttribute("disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
+ "doesn't have lock at start");
+
+ is(window.getComputedStyle(button).color, defaultColor,
+ "color is default color before locking on");
+
+ is(button.matches(":disabled"), false,
+ "doesn't match selector at start");
+
+ /* lock */
+ DOMUtils.addPseudoClassLock(button, ":disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), true,
+ "hasPseudoClassLock is true after locking");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style applied after adding lock");
+
+ is(button.matches(":disabled"), true,
+ "matches selector after adding lock");
+
+ /* change state to disabled */
+ button.setAttribute("disabled", "disabled");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style still applied after really disabling");
+
+ is(button.matches(":disabled"), true,
+ "matches selector after adding lock");
+
+ /* remove lock */
+ DOMUtils.removePseudoClassLock(button, ":disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
+ "hasPseudoClassLock is false after removing on lock");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style still applied after removing lock");
+
+ is(button.matches(":disabled"), true,
+ "matches selector after removing lock");
+
+ /* change state to enabled */
+ button.removeAttribute("disabled");
+
+ is(window.getComputedStyle(button).color, defaultColor,
+ "back to default style after un-disabling");
+
+ is(button.matches(":disabled"), false,
+ "doesn't match selector after enabling");
+}
+
+
+function testLockDisabled() {
+ var button = document.getElementById("test-button");
+
+ /* starting state is disabled */
+ button.setAttribute("disabled", "disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
+ "doesn't have lock at start");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ "color is :disabled color before locking");
+
+ is(button.matches(":disabled"), true,
+ "matches selector before locking");
+
+ /* lock */
+ DOMUtils.addPseudoClassLock(button, ":disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), true,
+ "hasPseudoClassLock is true after locking");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style still applied after adding on lock");
+
+ is(button.matches(":disabled"), true,
+ "matches selector after locking");
+
+ /* change state to enabled */
+ button.removeAttribute("disabled");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style applied after enabling");
+
+ is(button.matches(":disabled"), true,
+ "matches selector after enabling with lock on");
+
+ /* remove lock */
+ DOMUtils.removePseudoClassLock(button, ":disabled");
+
+ is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
+ "hasPseudoClassLock is false after removing on lock");
+
+ is(window.getComputedStyle(button).color, defaultColor,
+ "default style applied after removing lock");
+
+ is(button.matches(":disabled"), false,
+ "doesn't match selector after unlocking");
+
+ /* change state to disabled */
+ button.setAttribute("disabled", "disabled");
+
+ is(window.getComputedStyle(button).color, disabledColor,
+ ":disabled style applied after disabling after unlocking");
+
+ is(button.matches(":disabled"), true,
+ "matches selector again after disabling");
+}
+
+function testVisited() {
+ var link = document.getElementById("test-link");
+ var visitedColor = "rgb(20, 0, 0)";
+ var unvisitedColor = "rgb(30, 0, 0)";
+
+ /* lock visited */
+ DOMUtils.addPseudoClassLock(link, ":visited");
+
+ is(DOMUtils.hasPseudoClassLock(link, ":visited"), true,
+ "hasPseudoClassLock is true after adding lock");
+
+ var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
+ null, "color");
+ is(color, visitedColor, "color is :visited color after locking");
+
+ /* lock unvisited */
+ DOMUtils.addPseudoClassLock(link, ":link");
+
+ is(DOMUtils.hasPseudoClassLock(link, ":link"), true,
+ "hasPseudoClassLock is true after adding :link lock");
+
+ is(DOMUtils.hasPseudoClassLock(link, ":visited"), false,
+ "hasPseudoClassLock is false for :visited after adding :link lock");
+
+ var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
+ null, "color");
+ is(color, unvisitedColor, "color is :link color after locking :link");
+
+ /* lock visited back on */
+ DOMUtils.addPseudoClassLock(link, ":visited");
+
+ is(DOMUtils.hasPseudoClassLock(link, ":visited"), true,
+ "hasPseudoClassLock is true after adding :visited lock");
+
+ is(DOMUtils.hasPseudoClassLock(link, ":link"), false,
+ "hasPseudoClassLock is false for :link after adding :visited lock");
+
+ var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
+ null, "color");
+ is(color, visitedColor, "color is :visited color after locking back on");
+}
+
+function testMultiple() {
+ var div = document.getElementById("test-div");
+
+ var styles = {
+ ":hover": {
+ property: "color",
+ value: "rgb(10, 0, 0)",
+ defaultValue: "rgb(0, 0, 0)"
+ },
+ ":active": {
+ property: "font-family",
+ value: "Arial",
+ defaultValue: "serif"
+ },
+ ":focus": {
+ property: "font-weight",
+ value: "800",
+ defaultValue: "400"
+ }
+ };
+
+ for (var pseudo in styles) {
+ DOMUtils.addPseudoClassLock(div, pseudo);
+ }
+
+ for (var pseudo in styles) {
+ is(DOMUtils.hasPseudoClassLock(div, pseudo), true,
+ "hasPseudoClassLock is true after locking");
+
+ var style = styles[pseudo];
+ is(window.getComputedStyle(div).getPropertyValue(style.property),
+ style.value, "style for pseudo-class is applied after locking");
+
+ is(div.matches(pseudo), true,
+ "matches selector after locking");
+ }
+
+ DOMUtils.clearPseudoClassLocks(div);
+
+ for (var pseudo in styles) {
+ is(DOMUtils.hasPseudoClassLock(div, pseudo), false,
+ "hasPseudoClassLock is false after clearing");
+
+ is(window.getComputedStyle(div).getPropertyValue(style.property),
+ style.defaultValue, "style is back to default after clearing");
+
+ is(div.matches(pseudo), false,
+ "doesn't match selector after unlocking");
+ }
+}
+
+function testInvalid() {
+ var div = document.getElementById("test-div");
+ var pseudos = ["not a valid pseudo-class", ":ny-link", ":first-child"];
+
+ for (var i = 0; i < pseudos.length; i++) {
+ var pseudo = pseudos[i];
+
+ // basically make sure these don't crash the browser.
+ DOMUtils.addPseudoClassLock(div, pseudo);
+
+ is(DOMUtils.hasPseudoClassLock(div, pseudo), false);
+
+ DOMUtils.removePseudoClassLock(div, pseudo);
+ }
+}
+
+function testNotElement() {
+ for (var value of [null, undefined, {}]) {
+ SimpleTest.doesThrow(() => DOMUtils.hasPseudoClassLock(value, ":hover"),
+ "hasPseudoClassLock should throw for " + value);
+ SimpleTest.doesThrow(() => DOMUtils.addPseudoClassLock(value, ":hover"),
+ "addPseudoClassLock should throw for " + value);
+ SimpleTest.doesThrow(() => DOMUtils.removePseudoClassLock(value, ":hover"),
+ "removePseudoClassLock should throw for " + value);
+ SimpleTest.doesThrow(() => DOMUtils.clearPseudoClassLocks(value),
+ "clearPseudoClassLocks should throw for " + value);
+ }
+}
+ ]]>
+ </script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=708874"
+ target="_blank">Mozilla Bug 708874</a>
+
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=708874">
+ Mozilla Bug 708874 - API for locking pseudo-class state of an element
+ </a>
+
+ <a id="test-link" href="http://notavisitedwebsite.com">
+ test link
+ </a>
+
+ <div id="test-div">
+ test div
+ </div>
+
+ <button id="test-button">
+ test button
+ </button>
+ </body>
+
+</window>
diff --git a/layout/inspector/tests/chrome/test_bug727834.css b/layout/inspector/tests/chrome/test_bug727834.css
new file mode 100644
index 000000000..f21f7a54c
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug727834.css
@@ -0,0 +1,7 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+body {
+ padding-top: 100px;
+}
diff --git a/layout/inspector/tests/chrome/test_bug727834.xul b/layout/inspector/tests/chrome/test_bug727834.xul
new file mode 100644
index 000000000..dde8e1b03
--- /dev/null
+++ b/layout/inspector/tests/chrome/test_bug727834.xul
@@ -0,0 +1,88 @@
+<?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 type="application/javascript" 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 DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+ .getService(Components.interfaces.inIDOMUtils);
+ 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");
+
+ DOMUtils.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");
+
+ DOMUtils.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 () {
+ DOMUtils.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>