mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-16 12:17:34 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
7
layout/inspector/tests/bug1202095-2.css
Normal file
7
layout/inspector/tests/bug1202095-2.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Bug 1202095 - parseStyleSheet should not re-load @imports
|
||||
*/
|
||||
|
||||
body {
|
||||
color: chartreuse;
|
||||
}
|
||||
7
layout/inspector/tests/bug1202095.css
Normal file
7
layout/inspector/tests/bug1202095.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Bug 1202095 - parseStyleSheet should not re-load @imports
|
||||
*/
|
||||
|
||||
body {
|
||||
background-color: purple;
|
||||
}
|
||||
23
layout/inspector/tests/bug856317.css
Normal file
23
layout/inspector/tests/bug856317.css
Normal file
File diff suppressed because one or more lines are too long
BIN
layout/inspector/tests/chrome/GentiumPlus-R.woff
Normal file
BIN
layout/inspector/tests/chrome/GentiumPlus-R.woff
Normal file
Binary file not shown.
12
layout/inspector/tests/chrome/chrome.ini
Normal file
12
layout/inspector/tests/chrome/chrome.ini
Normal file
|
|
@ -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]
|
||||
8
layout/inspector/tests/chrome/test_bug467669.css
Normal file
8
layout/inspector/tests/chrome/test_bug467669.css
Normal file
|
|
@ -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;
|
||||
}
|
||||
174
layout/inspector/tests/chrome/test_bug467669.xul
Normal file
174
layout/inspector/tests/chrome/test_bug467669.xul
Normal file
|
|
@ -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 ­ 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, 你好</div>
|
||||
<div id="test4" class="gentium">Hello Gentium Plus!</div>
|
||||
<div id="test5" class="gentium">supercalifragilistic你ex­pi­a­li­do­cious好!</div>
|
||||
<div id="test6" style="font-family:serif">regular and <em>italic</em> text</div>
|
||||
</body>
|
||||
|
||||
</window>
|
||||
8
layout/inspector/tests/chrome/test_bug695639.css
Normal file
8
layout/inspector/tests/chrome/test_bug695639.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@font-face {
|
||||
font-family: gent;
|
||||
src: url(GentiumPlus-R.woff) format("woff");
|
||||
}
|
||||
|
||||
.test {
|
||||
font-family: gent, sans-serif;
|
||||
}
|
||||
80
layout/inspector/tests/chrome/test_bug695639.xul
Normal file
80
layout/inspector/tests/chrome/test_bug695639.xul
Normal file
|
|
@ -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 你好 world</div>
|
||||
</body>
|
||||
|
||||
</window>
|
||||
33
layout/inspector/tests/chrome/test_bug708874.css
Normal file
33
layout/inspector/tests/chrome/test_bug708874.css
Normal file
|
|
@ -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);
|
||||
}
|
||||
296
layout/inspector/tests/chrome/test_bug708874.xul
Normal file
296
layout/inspector/tests/chrome/test_bug708874.xul
Normal file
|
|
@ -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>
|
||||
7
layout/inspector/tests/chrome/test_bug727834.css
Normal file
7
layout/inspector/tests/chrome/test_bug727834.css
Normal file
|
|
@ -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;
|
||||
}
|
||||
88
layout/inspector/tests/chrome/test_bug727834.xul
Normal file
88
layout/inspector/tests/chrome/test_bug727834.xul
Normal file
|
|
@ -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>
|
||||
17
layout/inspector/tests/file_bug522601.html
Normal file
17
layout/inspector/tests/file_bug522601.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=522601
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 522601</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="some content">
|
||||
<h1>Blah</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
layout/inspector/tests/mochitest.ini
Normal file
29
layout/inspector/tests/mochitest.ini
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
bug1202095.css
|
||||
bug1202095-2.css
|
||||
bug856317.css
|
||||
file_bug522601.html
|
||||
|
||||
[test_bug462787.html]
|
||||
[test_bug462789.html]
|
||||
[test_bug522601.xhtml]
|
||||
[test_bug536379.html]
|
||||
[test_bug536379-2.html]
|
||||
[test_bug557726.html]
|
||||
[test_bug609549.xhtml]
|
||||
[test_bug806192.html]
|
||||
[test_bug856317.html]
|
||||
[test_bug877690.html]
|
||||
[test_bug1006595.html]
|
||||
[test_color_to_rgba.html]
|
||||
[test_css_property_is_shorthand.html]
|
||||
[test_css_property_is_valid.html]
|
||||
[test_getCSSPseudoElementNames.html]
|
||||
[test_getRelativeRuleLine.html]
|
||||
[test_get_all_style_sheets.html]
|
||||
[test_is_valid_css_color.html]
|
||||
[test_isinheritableproperty.html]
|
||||
[test_parseStyleSheet.html]
|
||||
[test_parseStyleSheetImport.html]
|
||||
[test_selectormatcheselement.html]
|
||||
118
layout/inspector/tests/test_bug1006595.html
Normal file
118
layout/inspector/tests/test_bug1006595.html
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1006595
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1006595</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1006595 **/
|
||||
function arraysEqual(arr1, arr2, message) {
|
||||
is(arr1.length, arr2.length, message + " length");
|
||||
for (var i = 0; i < arr1.length; ++i) {
|
||||
is(arr1[i], arr2[i], message + " element at index " + i);
|
||||
}
|
||||
}
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var paddingSubProps = utils.getSubpropertiesForCSSProperty("padding");
|
||||
arraysEqual(paddingSubProps,
|
||||
[ "padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left" ],
|
||||
"'padding' subproperties");
|
||||
|
||||
var displaySubProps = utils.getSubpropertiesForCSSProperty("color");
|
||||
arraysEqual(displaySubProps, [ "color" ],
|
||||
"'color' subproperties");
|
||||
|
||||
var varProps = utils.getSubpropertiesForCSSProperty("--foo");
|
||||
arraysEqual(varProps, ["--foo"], "'--foo' subproperties");
|
||||
|
||||
ok(utils.cssPropertyIsShorthand("padding"), "'padding' is a shorthand")
|
||||
ok(!utils.cssPropertyIsShorthand("color"), "'color' is not a shorthand")
|
||||
|
||||
ok(utils.cssPropertySupportsType("padding", utils.TYPE_LENGTH),
|
||||
"'padding' can be a length");
|
||||
ok(!utils.cssPropertySupportsType("padding", utils.TYPE_COLOR),
|
||||
"'padding' can't be a color");
|
||||
|
||||
ok(utils.cssPropertySupportsType("padding", utils.TYPE_PERCENTAGE),
|
||||
"'padding' can be a percentage");
|
||||
ok(!utils.cssPropertySupportsType("color", utils.TYPE_PERCENTAGE),
|
||||
"'color' can't be a percentage");
|
||||
|
||||
ok(utils.cssPropertySupportsType("color", utils.TYPE_COLOR),
|
||||
"'color' can be a color");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_COLOR),
|
||||
"'background' can be a color");
|
||||
ok(!utils.cssPropertySupportsType("background-image", utils.TYPE_COLOR),
|
||||
"'background-image' can't be a color");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_URL),
|
||||
"'background-image' can be a URL");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_URL),
|
||||
"'background' can be a URL");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_URL),
|
||||
"'background-color' can't be a URL");
|
||||
|
||||
// There are no properties claiming to be of TYPE_ANGLE. image-orientation
|
||||
// would be, but it doesn't use table-driven parsing.
|
||||
|
||||
// There are no properties claiming to be of TYPE_FREQUENCY
|
||||
|
||||
ok(utils.cssPropertySupportsType("transition", utils.TYPE_TIME),
|
||||
"'transition' can be a time");
|
||||
ok(utils.cssPropertySupportsType("transition-duration", utils.TYPE_TIME),
|
||||
"'transition-duration' can be a time");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_TIME),
|
||||
"'background-color' can't be a time");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_GRADIENT),
|
||||
"'background-image' can be a gradient");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_GRADIENT),
|
||||
"'background' can be a gradient");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_GRADIENT),
|
||||
"'background-color' can't be a gradient");
|
||||
|
||||
ok(utils.cssPropertySupportsType("transition", utils.TYPE_TIMING_FUNCTION),
|
||||
"'transition' can be a timing function");
|
||||
ok(utils.cssPropertySupportsType("transition-timing-function",
|
||||
utils.TYPE_TIMING_FUNCTION),
|
||||
"'transition-duration' can be a timing function");
|
||||
ok(!utils.cssPropertySupportsType("background-color",
|
||||
utils.TYPE_TIMING_FUNCTION),
|
||||
"'background-color' can't be a timing function");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_IMAGE_RECT),
|
||||
"'background-image' can be an image rect");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_IMAGE_RECT),
|
||||
"'background' can be an image rect");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_IMAGE_RECT),
|
||||
"'background-color' can't be an image rect");
|
||||
|
||||
ok(utils.cssPropertySupportsType("z-index", utils.TYPE_NUMBER),
|
||||
"'z-index' can be a number");
|
||||
ok(utils.cssPropertySupportsType("line-height", utils.TYPE_NUMBER),
|
||||
"'line-height' can be a number");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_NUMBER),
|
||||
"'background-color' can't be a number");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1006595">Mozilla Bug 1006595</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
100
layout/inspector/tests/test_bug462787.html
Normal file
100
layout/inspector/tests/test_bug462787.html
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=462787
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 462787</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462787">Mozilla Bug 462787</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 462787 **/
|
||||
|
||||
function do_test() {
|
||||
const INVALID_POINTER = SpecialPowers.Cr.NS_ERROR_INVALID_POINTER;
|
||||
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
try {
|
||||
utils.getCSSStyleRules(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getRuleLine(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.isIgnorableWhitespace(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getParentForNode(null, true);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getBindingURLs(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getContentState(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.setContentState(null, false);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
94
layout/inspector/tests/test_bug462789.html
Normal file
94
layout/inspector/tests/test_bug462789.html
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=462789
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 462789</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462789">Mozilla Bug 462789</a>
|
||||
<p id="display"><iframe id="bug462789_iframe" src="data:text/html,<html><head><style>*{color:black;}</style></head><body>xxx" style="display: none;"></iframe></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 462789 **/
|
||||
|
||||
function do_test() {
|
||||
const ERROR_INVALID_ARG = 0x80070057;
|
||||
const DOCUMENT_NODE_TYPE = 9;
|
||||
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var iframe = document.getElementById("bug462789_iframe");
|
||||
var docElement = iframe.contentDocument.documentElement;
|
||||
var body = docElement.children[1];
|
||||
var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
|
||||
var text = body.firstChild;
|
||||
|
||||
try {
|
||||
var res = utils.getCSSStyleRules(docElement);
|
||||
is(res, null, "getCSSStyleRules");
|
||||
res = utils.getCSSStyleRules(body);
|
||||
is(res, null, "getCSSStyleRules");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getRuleLine(rule);
|
||||
is(res, 1, "getRuleLine");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.isIgnorableWhitespace(text);
|
||||
is(res, false, "isIgnorableWhitespace");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getParentForNode(docElement, true);
|
||||
is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
|
||||
res = utils.getParentForNode(text, true);
|
||||
is(res.tagName, "BODY", "getParentForNode(text, true)");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getBindingURLs(docElement);
|
||||
ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type");
|
||||
is(res.length, 0, "getBindingURLs array length");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
utils.getContentState(docElement);
|
||||
ok(true, "Should not throw");
|
||||
}
|
||||
catch(e) { ok(false, "Got an exception: " + e); }
|
||||
|
||||
try {
|
||||
utils.setContentState(docElement, false);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, ERROR_INVALID_ARG, "got the expected exception");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
274
layout/inspector/tests/test_bug522601.xhtml
Normal file
274
layout/inspector/tests/test_bug522601.xhtml
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=522601
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 522601</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<bindings xmlns="http://www.mozilla.org/xbl">
|
||||
<binding id="testBinding">
|
||||
<content><div><children/></div><children includes="span"/></content>
|
||||
</binding>
|
||||
</bindings>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=522601">Mozilla Bug 522601</a>
|
||||
<p id="display" style="-moz-binding: url(#testBinding)">
|
||||
<span id="s">This is some text</span>
|
||||
More text
|
||||
<b id="b">Even more <i id="i1">Italic</i>text<i id="i2">And more italic</i></b></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<div id="subdoc">
|
||||
<iframe id="frame1" src="file_bug522601.html">frame text</iframe>
|
||||
</div>
|
||||
<div id="test-shadow">
|
||||
<h2 id="h2">light child</h2>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 522601 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testFunc(walker, func, expectedNode, str) {
|
||||
var oldCurrent = SpecialPowers.unwrap(walker.currentNode);
|
||||
var newNode = SpecialPowers.unwrap(walker[func]());
|
||||
is(newNode, expectedNode, "Unexpected node after " + str);
|
||||
is(SpecialPowers.unwrap(walker.currentNode), newNode ? newNode : oldCurrent,
|
||||
"Unexpected current node after " + str);
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
var walkerSubDocument =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerSubDocument.showAnonymousContent = false;
|
||||
walkerSubDocument.showSubDocuments = true;
|
||||
walkerSubDocument.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument.doctype,
|
||||
"step to sub documents doctype");
|
||||
testFunc(walkerSubDocument, "nextSibling", $("frame1").contentDocument.documentElement,
|
||||
"step to sub documents documentElement");
|
||||
|
||||
walkerSubDocument =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerSubDocument.showAnonymousContent = false;
|
||||
walkerSubDocument.showSubDocuments = true;
|
||||
walkerSubDocument.showDocumentsAsNodes = true;
|
||||
walkerSubDocument.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument,
|
||||
"step to sub document");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument.doctype,
|
||||
"step to sub documents doctype");
|
||||
testFunc(walkerSubDocument, "nextSibling", $("frame1").contentDocument.documentElement,
|
||||
"step to sub documents documentElement");
|
||||
|
||||
walkerSubDocument.currentNode = $("frame1").contentDocument;
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1").contentDocument,
|
||||
"setting currentNode to sub document");
|
||||
testFunc(walkerSubDocument, "nextSibling", null,
|
||||
"nextSibling for sub document is null");
|
||||
|
||||
var walkerFrameChild =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerFrameChild.showAnonymousContent = false;
|
||||
walkerFrameChild.showSubDocuments = false;
|
||||
walkerFrameChild.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerFrameChild.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerFrameChild, "firstChild", $("frame1").firstChild,
|
||||
"step to frames child");
|
||||
|
||||
var walkerNonAnon =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerNonAnon.init($("display"), NodeFilter.SHOW_ALL);
|
||||
walkerNonAnon.showAnonymousContent = false;
|
||||
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("display"), "Unexpected non-anon root");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").previousSibling,
|
||||
"step to some text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s"), "step to span");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").firstChild, "step to span text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").nextSibling, "step to more text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b"), "step to bold");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1"), "step to first italic");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1").firstChild,
|
||||
"step to first italic text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1").nextSibling,
|
||||
"step to more bold text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i2"), "step to second italic");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i2").firstChild,
|
||||
"step to second italic text");
|
||||
testFunc(walkerNonAnon, "nextNode", null, "step past end");
|
||||
testFunc(walkerNonAnon, "parentNode", $("i2"), "step up to second italic");
|
||||
testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text again");
|
||||
testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold again");
|
||||
testFunc(walkerNonAnon, "parentNode", $("display"), "step up to display");
|
||||
testFunc(walkerNonAnon, "parentNode", null, "step up past root");
|
||||
testFunc(walkerNonAnon, "firstChild", $("s").previousSibling,
|
||||
"step firstChild to display first child");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s"),
|
||||
"step nextSibling to span");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s").nextSibling,
|
||||
"step nextSibling to more text");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("b"), "step nextSibling to bold");
|
||||
testFunc(walkerNonAnon, "nextSibling", null, "step nextSibling past end");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s").nextSibling,
|
||||
"step previousSibling to more text");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s"),
|
||||
"step previousSibling to span");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s").previousSibling,
|
||||
"step previousSibling to display first child");
|
||||
testFunc(walkerNonAnon, "previousSibling", null,
|
||||
"step previousSibling past end");
|
||||
|
||||
// Move the walker over to the end
|
||||
while (walkerNonAnon.nextNode()) { /* do nothing */ }
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("i2").firstChild, "unexpected last node");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i2"), "step back to second italic");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1").nextSibling,
|
||||
"step back to more bold text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1").firstChild,
|
||||
"step back to first italic text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1"), "step back to first italic");
|
||||
testFunc(walkerNonAnon, "previousNode", $("b").firstChild,
|
||||
"step back to bold text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("b"), "step back to bold");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").nextSibling, "step back to more text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").firstChild, "step back to span text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s"), "step back to span");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").previousSibling,
|
||||
"step back to some text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("display"),
|
||||
"step back to root");
|
||||
testFunc(walkerNonAnon, "previousNode", null,
|
||||
"step back past root");
|
||||
|
||||
walkerNonAnon.currentNode = $("s");
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), SpecialPowers.unwrap($("s")),
|
||||
"Setting currentNode to span");
|
||||
|
||||
var anonDiv = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("display")))[0];
|
||||
|
||||
try {
|
||||
walkerNonAnon.currentNode = anonDiv;
|
||||
ok(false, "Setting current node to a node that is otherwise unreachable," +
|
||||
" with the current visibility settings should throw");
|
||||
} catch(e) {
|
||||
ok(e.toString().indexOf("NS_ERROR_ILLEGAL_VALUE") > -1, "Setting current node to an anon node should throw" +
|
||||
" NS_ERROR_ILLEGAL_VALUE if showAnonymousContent is set to false");
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), SpecialPowers.unwrap($("s")),
|
||||
"An unsuccessfull set currentNode should leave behind the old state");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s").nextSibling, "nextSibling after set currentNode");
|
||||
}
|
||||
|
||||
var walkerAnon =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerAnon.showAnonymousContent = true;
|
||||
walkerAnon.init($("display"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerAnon.currentNode), $("display"), "Unexpected anon root");
|
||||
testFunc(walkerAnon, "nextNode", anonDiv,
|
||||
"step to anonymous div");
|
||||
testFunc(walkerAnon, "nextNode", $("s").previousSibling,
|
||||
"step to some text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s").nextSibling, "step to more text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("b"), "step to bold (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("b").firstChild, "step to bold text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1"), "step to first italic (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1").firstChild,
|
||||
"step to first italic text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1").nextSibling,
|
||||
"step to more bold text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i2"), "step to second italic (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i2").firstChild,
|
||||
"step to second italic text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s"), "step to span (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s").firstChild, "step to span text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", null, "step past end (anon)");
|
||||
testFunc(walkerAnon, "parentNode", $("s"), "step up to span (anon)");
|
||||
testFunc(walkerAnon, "parentNode", $("display"), "step up to display (anon)");
|
||||
testFunc(walkerAnon, "nextNode", anonDiv, "step to anonymous div again");
|
||||
testFunc(walkerAnon, "parentNode", $("display"),
|
||||
"step up to display again (anon)");
|
||||
testFunc(walkerAnon, "parentNode", null, "step up past root (anon)");
|
||||
testFunc(walkerAnon, "firstChild", anonDiv,
|
||||
"step firstChild to display first child (anon)");
|
||||
testFunc(walkerAnon, "nextSibling", $("s"),
|
||||
"step nextSibling to span (anon)");
|
||||
testFunc(walkerAnon, "nextSibling", null, "step nextSibling past end (anon)");
|
||||
testFunc(walkerAnon, "previousSibling", anonDiv,
|
||||
"step previousSibling to anonymous div");
|
||||
testFunc(walkerAnon, "previousSibling", null, "step previousSibling past end (anon)");
|
||||
|
||||
// Move the walker over to the end
|
||||
while (walkerAnon.nextNode()) { /* do nothing */ }
|
||||
testFunc(walkerAnon, "previousNode", $("s"), "step back to span (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i2").firstChild,
|
||||
"step back to second italic text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i2"), "step back to second italic (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1").nextSibling,
|
||||
"step back to more bold text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1").firstChild,
|
||||
"step back to first italic text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1"), "step back to first italic (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("b").firstChild, "step back to bold text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("b"), "step back to bold (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("s").nextSibling, "step back to more text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("s").previousSibling,
|
||||
"step back to some text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", anonDiv,
|
||||
"step back to anonymous div");
|
||||
testFunc(walkerAnon, "previousNode", $("display"), "step back to root (anon)");
|
||||
testFunc(walkerAnon, "previousNode", null, "step back past root (anon)");
|
||||
|
||||
var shadowdiv = document.querySelector('#test-shadow');
|
||||
var shadowRoot = shadowdiv.createShadowRoot();
|
||||
var h = document.createElement("header");
|
||||
var c = document.createElement("content");
|
||||
c.setAttribute("select", "h2");
|
||||
h.appendChild(c);
|
||||
shadowRoot.appendChild(h);
|
||||
|
||||
var walkerShadow =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerShadow.showAnonymousContent = true;
|
||||
walkerShadow.init($("test-shadow"), NodeFilter.SHOW_ALL);
|
||||
var c1 = walkerShadow.nextNode();
|
||||
var c2 = walkerShadow.nextNode();
|
||||
var c3 = walkerShadow.nextNode();
|
||||
|
||||
walkerShadow.currentNode = c1;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), h,
|
||||
"Unexpected shadow element 1");
|
||||
walkerShadow.currentNode = c2;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), $("h2"),
|
||||
"Unexpected shadow element 2");
|
||||
walkerShadow.currentNode = c3;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), $("h2").firstChild,
|
||||
"Unexpected shadow element 3");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
35
layout/inspector/tests/test_bug536379-2.html
Normal file
35
layout/inspector/tests/test_bug536379-2.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=536379
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 536379</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,@import 'data:text/css,p { color: green }'">
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,@import "data:text/css,@import 'data:text/css,p { color: green }'"">
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 536379 **/
|
||||
|
||||
const CI = SpecialPowers.Ci;
|
||||
const CC = SpecialPowers.Cc;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
|
||||
var firstPRule =
|
||||
rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
firstPRule.style.removeProperty("color");
|
||||
ok(true, "should not crash");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
46
layout/inspector/tests/test_bug536379.html
Normal file
46
layout/inspector/tests/test_bug536379.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=536379
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 536379</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,p { color: green }">
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,p { color: green }">
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 536379 **/
|
||||
|
||||
const CI = SpecialPowers.Ci;
|
||||
const CC = SpecialPowers.Cc;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
|
||||
var firstPRule =
|
||||
rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
firstPRule.style.removeProperty("color");
|
||||
ok(true, "should not crash");
|
||||
|
||||
var links = document.getElementsByTagName("link");
|
||||
is(links.length, 3, "links.length");
|
||||
is(SpecialPowers.unwrap(firstPRule.parentStyleSheet), links[1].sheet, "sheet match for first P rule");
|
||||
var secondPRule =
|
||||
rules.GetElementAt(rules.Count() - 1).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
is(SpecialPowers.unwrap(secondPRule.parentStyleSheet), links[2].sheet, "sheet match for second P rule");
|
||||
is(links[1].href, links[2].href, "links should have same href");
|
||||
isnot(links[1].sheet, links[2].sheet, "links should have different sheets");
|
||||
isnot(firstPRule, secondPRule, "rules should be different");
|
||||
isnot(firstPRule.cssText, secondPRule.cssText, "text should be different since property was removed from one");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
95
layout/inspector/tests/test_bug557726.html
Normal file
95
layout/inspector/tests/test_bug557726.html
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=557726
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 557726</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style id="pseudo-style">
|
||||
#div1 {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#div1:first-letter {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#div1:before {
|
||||
content: '"';
|
||||
}
|
||||
|
||||
#div1:after {
|
||||
content: '"';
|
||||
}
|
||||
|
||||
#div1:after, #div1:before {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557726">Mozilla Bug 557726</a>
|
||||
|
||||
<div id="div1">
|
||||
text with ::before, ::after, and ::first-letter pseudo-elements
|
||||
</div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 557726 **/
|
||||
|
||||
function getSelectors (rules) {
|
||||
var styleElement = document.getElementById("pseudo-style");
|
||||
var selectors = [];
|
||||
for (var i = 0; i < rules.Count(); i++) {
|
||||
var rule = rules.GetElementAt(i).QueryInterface(SpecialPowers.Ci.nsIDOMCSSStyleRule);
|
||||
if (SpecialPowers.unwrap(rule.parentStyleSheet.ownerNode) == styleElement) // no user agent rules
|
||||
selectors.push(rule.selectorText);
|
||||
}
|
||||
return selectors;
|
||||
}
|
||||
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var div = document.getElementById("div1");
|
||||
|
||||
/* empty or missing pseudo-element argument */
|
||||
var selectors = getSelectors(domUtils.getCSSStyleRules(div));
|
||||
is(selectors.length, 1, "psuedo-element argument should be optional");
|
||||
is(selectors[0], "#div1", "should only have the non-pseudo element rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, null));
|
||||
is(selectors.length, 1, "pseudo-element argument can be null");
|
||||
is(selectors[0], "#div1", "should only have the non pseudo-element rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ""));
|
||||
is(selectors.length, 1, "pseudo-element argument can be empty string");
|
||||
is(selectors[0], "#div1", "should only have the non pseudo-element rule");
|
||||
|
||||
|
||||
/* invalid pseudo-element argument */
|
||||
var rules = domUtils.getCSSStyleRules(div, "not a valid pseudo element");
|
||||
is(rules, null, "invalid pseudo-element returns no rules list");
|
||||
|
||||
|
||||
/* valid pseudo-element argument */
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-letter"));
|
||||
is(selectors.length, 1, "pseudo-element argument can be used");
|
||||
is(selectors[0], "#div1::first-letter", "should only have the ::first-letter rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":before"));
|
||||
is(selectors.length, 2, "::before pseudo-element has two matching rules");
|
||||
isnot(selectors.indexOf("#div1::after, #div1::before"), -1, "fetched rule for ::before")
|
||||
isnot(selectors.indexOf("#div1::before"), -1, "fetched rule for ::before")
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-line"));
|
||||
is(selectors.length, 0, "valid pseudo-element but no matching rules");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
67
layout/inspector/tests/test_bug609549.xhtml
Normal file
67
layout/inspector/tests/test_bug609549.xhtml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=609549
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 609549</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<bindings xmlns="http://www.mozilla.org/xbl">
|
||||
<binding id="testBinding">
|
||||
<!-- No linebreaks since this is html and whitespace is preserved. -->
|
||||
<content><div anonid="box-A">x</div><div anonid="box-B"><children includes="span"/></div><div anonid="box-C">x</div><children/></content>
|
||||
</binding>
|
||||
</bindings>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609549">Mozilla Bug 609549</a>
|
||||
<div id="bound" style="-moz-binding: url(#testBinding);"><p id="p">lorem ipsum dolor sit amet</p><span id="sandwiched">sandwiched</span></div>
|
||||
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 609549 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
|
||||
getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode");
|
||||
var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false));
|
||||
|
||||
is(withoutAnons.length, $("bound").childNodes.length,
|
||||
"withoutAnons should be the same length as childNodes");
|
||||
is(withoutAnons[0], $("p"), "didn't get paragraph - without anons");
|
||||
is(withoutAnons[1], $("sandwiched"),
|
||||
"didn't get sandwiched span - without anons");
|
||||
|
||||
var withAnons = domUtils.getChildrenForNode($("bound"), true);
|
||||
|
||||
is(withAnons.length, 4, "bad withAnons.length");
|
||||
is(withAnons[0].getAttribute("anonid"), "box-A",
|
||||
"didn't get anonymous box-A");
|
||||
is(withAnons[1].getAttribute("anonid"), "box-B",
|
||||
"didn't get anonymous box-B");
|
||||
is(withAnons[2].getAttribute("anonid"), "box-C",
|
||||
"didn't get anonymous box-C");
|
||||
is(withAnons[3].id, "p", "didn't get paragraph - with anons");
|
||||
|
||||
var bKids = domUtils.getChildrenForNode(withAnons[1], true);
|
||||
is(bKids.length, 1, "bKids.length is bad");
|
||||
is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"),
|
||||
"didn't get sandwiched span inserted into box-B");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
26
layout/inspector/tests/test_bug806192.html
Normal file
26
layout/inspector/tests/test_bug806192.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=806192
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 806192</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
const utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
try {
|
||||
var res = utils.getBindingURLs({});
|
||||
ok(false, "didn't get error");
|
||||
}
|
||||
catch(e) { ok(true, "got expected exception"); }
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
84
layout/inspector/tests/test_bug856317.html
Normal file
84
layout/inspector/tests/test_bug856317.html
Normal file
File diff suppressed because one or more lines are too long
260
layout/inspector/tests/test_bug877690.html
Normal file
260
layout/inspector/tests/test_bug877690.html
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=877690
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 877690</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 877690 **/
|
||||
|
||||
// Returns true if array contains item. False otherwise. Raises an exception if
|
||||
// array is not an Array object. If the item is found in array, remove item.
|
||||
function contains(array, item) {
|
||||
if (!array.indexOf) {
|
||||
throw new "First argument is not an array";
|
||||
}
|
||||
var index = array.indexOf(item);
|
||||
if (index == -1) {
|
||||
return false;
|
||||
}
|
||||
array.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if values contains all and only the expected values. False otherwise.
|
||||
function testValues(values, expected) {
|
||||
expected.forEach(function (expectedValue) {
|
||||
if (!contains(values, expectedValue)) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return values.length === 0;
|
||||
}
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var getCSSValuesForProperty = function(prop) {
|
||||
return Array.from(utils.getCSSValuesForProperty(prop));
|
||||
}
|
||||
|
||||
// test a property with keywords and colors
|
||||
var prop = "color";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
|
||||
"beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood",
|
||||
"cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor",
|
||||
"cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey",
|
||||
"darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred",
|
||||
"darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey",
|
||||
"darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue",
|
||||
"firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold",
|
||||
"goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey",
|
||||
"lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
|
||||
"mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite",
|
||||
"navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
|
||||
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey", "snow", "springgreen",
|
||||
"steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", "wheat",
|
||||
"white", "whitesmoke", "yellow", "yellowgreen", "rgb", "hsl", "rgba", "hsla" ];
|
||||
ok(testValues(values, expected), "property color's values.");
|
||||
|
||||
// test a shorthand property
|
||||
var prop = "background";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
|
||||
"beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue",
|
||||
"chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor", "cyan", "darkblue",
|
||||
"darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta",
|
||||
"darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue",
|
||||
"darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray",
|
||||
"dimgrey", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue",
|
||||
"lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue",
|
||||
"mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod",
|
||||
"palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum",
|
||||
"powderblue", "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown",
|
||||
"seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise",
|
||||
"violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen", "no-repeat", "repeat",
|
||||
"repeat-x", "repeat-y", "space", "round", "fixed", "scroll", "local", "center", "top", "bottom", "left", "right",
|
||||
"border-box", "padding-box", "content-box", "border-box", "padding-box", "content-box", "text", "contain",
|
||||
"cover", "rgb", "hsl", "rgba", "hsla", "none", "-moz-element", "-moz-image-rect", "url", "linear-gradient",
|
||||
"radial-gradient", "repeating-linear-gradient", "repeating-radial-gradient", "-moz-linear-gradient",
|
||||
"-moz-radial-gradient", "-moz-repeating-linear-gradient", "-moz-repeating-radial-gradient" ];
|
||||
ok(testValues(values, expected), "Shorthand property values.");
|
||||
|
||||
var prop = "border";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "aliceblue",
|
||||
"antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet",
|
||||
"brown", "burlywood", "cadetblue", "calc", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk",
|
||||
"crimson", "currentColor", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki",
|
||||
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "dashed", "deeppink",
|
||||
"deepskyblue", "dimgray", "dimgrey", "dodgerblue", "dotted", "double", "fill", "firebrick", "floralwhite",
|
||||
"forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow",
|
||||
"groove", "hidden", "honeydew", "hotpink", "hsl", "hsla", "indianred", "indigo", "inherit", "inset", "ivory",
|
||||
"khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan",
|
||||
"lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen",
|
||||
"lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow", "lime", "limegreen",
|
||||
"linen", "logical", "magenta", "maroon", "medium", "mediumaquamarine", "mediumblue", "mediumorchid",
|
||||
"mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "none",
|
||||
"oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "outset", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "physical", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "repeat", "rgb", "rgba", "ridge", "rosybrown", "round", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "solid", "space", "springgreen", "steelblue", "stretch", "tan", "teal", "thick", "thin", "thistle", "tomato",
|
||||
"transparent", "turquoise", "-moz-element", "-moz-image-rect", "url", "violet", "wheat", "white", "whitesmoke",
|
||||
"yellow", "yellowgreen", "linear-gradient", "radial-gradient", "repeating-linear-gradient",
|
||||
"repeating-radial-gradient", "-moz-linear-gradient", "-moz-radial-gradient", "-moz-repeating-linear-gradient",
|
||||
"-moz-repeating-radial-gradient" ]
|
||||
ok(testValues(values, expected), "Shorthand property values.");
|
||||
|
||||
// test keywords only
|
||||
var prop = "border-top";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "thin", "medium", "thick", "none", "hidden", "dotted",
|
||||
"dashed", "solid", "double", "groove", "ridge", "inset", "outset",
|
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black",
|
||||
"blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse",
|
||||
"chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor", "cyan", "darkblue", "darkcyan",
|
||||
"darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen",
|
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray",
|
||||
"darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey",
|
||||
"dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey",
|
||||
"lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
|
||||
"mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite",
|
||||
"navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
|
||||
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey", "snow", "springgreen",
|
||||
"steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", "wheat", "white",
|
||||
"whitesmoke", "yellow", "yellowgreen", "calc", "-moz-calc", "rgb", "hsl", "rgba", "hsla" ];
|
||||
ok(testValues(values, expected), "property border-top's values.");
|
||||
|
||||
// tests no keywords or colors
|
||||
var prop = "padding-bottom";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "calc", "-moz-calc" ];
|
||||
ok(testValues(values, expected), "property padding-bottom's values.");
|
||||
|
||||
// test proprety
|
||||
var prop = "display";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "none", "inline", "block", "inline-block", "list-item",
|
||||
"table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row",
|
||||
"table-column-group", "table-column", "table-cell", "table-caption", "-moz-box", "-moz-inline-box",
|
||||
"-moz-grid", "-moz-inline-grid", "-moz-grid-group", "-moz-grid-line", "-moz-stack", "-moz-inline-stack",
|
||||
"-moz-deck", "-moz-popup", "-moz-groupbox",
|
||||
"flex", "inline-flex", "-webkit-box", "-webkit-inline-box",
|
||||
"-webkit-flex", "-webkit-inline-flex",
|
||||
"grid", "inline-grid",
|
||||
"ruby", "ruby-base", "ruby-base-container", "ruby-text", "ruby-text-container",
|
||||
"contents" ];
|
||||
ok(testValues(values, expected), "property display's values.");
|
||||
|
||||
// test property
|
||||
var prop = "float";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "none", "left", "right", "inline-start", "inline-end" ];
|
||||
ok(testValues(values, expected), "property float's values.");
|
||||
|
||||
// Test property with "auto"
|
||||
var prop = "margin";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "auto", "calc", "inherit" ];
|
||||
ok(testValues(values, expected), "property margin's values.");
|
||||
|
||||
// Test property with "normal"
|
||||
var prop = "font-style";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "italic", "normal", "oblique" ];
|
||||
ok(testValues(values, expected), "property font-style's values.");
|
||||
|
||||
// Test property with "cubic-bezier" and "step".
|
||||
var prop = "-moz-transition";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "all", "unset", "cubic-bezier", "ease", "ease-in", "ease-in-out",
|
||||
"ease-out", "inherit", "linear", "none", "step-end", "step-start",
|
||||
"steps" ];
|
||||
ok(testValues(values, expected), "property -moz-transition's values.");
|
||||
|
||||
// test invalid property
|
||||
var prop = "invalidProperty";
|
||||
try {
|
||||
getCSSValuesForProperty(prop);
|
||||
ok(false, "invalid property should throw an exception");
|
||||
}
|
||||
catch(e) {
|
||||
// test passed
|
||||
}
|
||||
|
||||
// test border-image propery, for bug 973345
|
||||
var prop = "border-image";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "aliceblue",
|
||||
"antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet",
|
||||
"brown", "burlywood", "cadetblue", "calc", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk",
|
||||
"crimson", "currentColor", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki",
|
||||
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "dashed", "deeppink",
|
||||
"deepskyblue", "dimgray", "dimgrey", "dodgerblue", "dotted", "double", "fill", "firebrick", "floralwhite",
|
||||
"forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow",
|
||||
"groove", "hidden", "honeydew", "hotpink", "hsl", "hsla", "indianred", "indigo", "inherit", "inset", "ivory",
|
||||
"khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan",
|
||||
"lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen",
|
||||
"lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow", "lime", "limegreen",
|
||||
"linen", "logical", "magenta", "maroon", "medium", "mediumaquamarine", "mediumblue", "mediumorchid",
|
||||
"mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "none",
|
||||
"oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "outset", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "physical", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "repeat", "rgb", "rgba", "ridge", "rosybrown", "round", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "solid", "springgreen", "steelblue", "stretch", "tan", "teal", "thick", "thin", "thistle", "tomato",
|
||||
"transparent", "turquoise", "-moz-element", "-moz-image-rect", "url", "violet", "wheat", "white", "whitesmoke",
|
||||
"yellow", "yellowgreen", "linear-gradient", "radial-gradient", "repeating-linear-gradient",
|
||||
"repeating-radial-gradient", "-moz-linear-gradient", "-moz-radial-gradient", "-moz-repeating-linear-gradient",
|
||||
"-moz-repeating-radial-gradient" ]
|
||||
ok(testValues(values, expected), "property border-image's values.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=877690">Mozilla Bug 877690</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
55
layout/inspector/tests/test_color_to_rgba.html
Normal file
55
layout/inspector/tests/test_color_to_rgba.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::ColorToRGBA</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
testColor("red", {r:255, g:0, b:0, a:1});
|
||||
testColor("#f00", {r:255, g:0, b:0, a:1});
|
||||
testColor("#ff0000", {r:255, g:0, b:0, a:1});
|
||||
testColor("ff0000", null);
|
||||
testColor("rgb(255,0,0)", {r:255, g:0, b:0, a:1});
|
||||
testColor("rgba(255,0,0)", {r:255, g:0, b:0, a:1});
|
||||
testColor("rgb(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
|
||||
testColor("rgba(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
|
||||
testColor("rgb(50%,75%,60%)", {r:128, g:191, b:153, a:1});
|
||||
testColor("rgba(50%,75%,60%)", {r:128, g:191, b:153, a:1});
|
||||
testColor("rgb(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
|
||||
testColor("rgba(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
|
||||
testColor("hsl(320,30%,10%)", {r:33, g:17, b:28, a:1});
|
||||
testColor("hsla(320,30%,10%)", {r:33, g:17, b:28, a:1});
|
||||
testColor("hsl(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
|
||||
testColor("hsla(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
|
||||
|
||||
function testColor(color, expected) {
|
||||
let rgb = utils.colorToRGBA(color);
|
||||
|
||||
if (rgb === null) {
|
||||
ok(expected === null, "color: " + color + " returns null");
|
||||
return;
|
||||
}
|
||||
|
||||
let {r, g, b, a} = rgb;
|
||||
|
||||
is(r, expected.r, "color: " + color + ", red component is converted correctly");
|
||||
is(g, expected.g, "color: " + color + ", green component is converted correctly");
|
||||
is(b, expected.b, "color: " + color + ", blue component is converted correctly");
|
||||
is(Math.round(a * 10) / 10, expected.a, "color: " + color + ", alpha component is a converted correctly");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::ColorToRGBA</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
51
layout/inspector/tests/test_css_property_is_shorthand.html
Normal file
51
layout/inspector/tests/test_css_property_is_shorthand.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::CssPropertyIsShorthand</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{
|
||||
property: "color",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "background",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "--anything",
|
||||
expected: false
|
||||
}
|
||||
];
|
||||
|
||||
for (let {property, expected} of tests) {
|
||||
let result = utils.cssPropertyIsShorthand(property);
|
||||
is(result, expected, "checking whether " + property + " is shorthand");
|
||||
}
|
||||
|
||||
let sawException = false;
|
||||
try {
|
||||
let result = utils.cssPropertyIsShorthand("nosuchproperty");
|
||||
} catch (e) {
|
||||
sawException = true;
|
||||
}
|
||||
ok(sawException, "checking whether nosuchproperty throws");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::CssPropertyIsShorthand</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
105
layout/inspector/tests/test_css_property_is_valid.html
Normal file
105
layout/inspector/tests/test_css_property_is_valid.html
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::CssPropertyIsValid</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{
|
||||
property: "color",
|
||||
value: "red",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "display",
|
||||
value: "none",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "display",
|
||||
value: "red",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "displayx",
|
||||
value: "none",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px solid blue",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1 solid blue",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px underline blue",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px solid",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue !important",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue ! important",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue !impoxxxrtant",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "red; background:green;",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "content",
|
||||
value: "\"hello\"",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "var(--some-kind-of-green)",
|
||||
expected: true
|
||||
}
|
||||
];
|
||||
|
||||
for (let {property, value, expected} of tests) {
|
||||
let valid = utils.cssPropertyIsValid(property, value);
|
||||
|
||||
if (expected) {
|
||||
ok(valid, property + ":" + value + " is valid");
|
||||
} else {
|
||||
ok(!valid, property + ":" + value + " is not valid");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::CssPropertyIsValid</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
59
layout/inspector/tests/test_getCSSPseudoElementNames.html
Normal file
59
layout/inspector/tests/test_getCSSPseudoElementNames.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::getCSSPseudoElementNames</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let expected = new Set([
|
||||
":after",
|
||||
":before",
|
||||
":backdrop",
|
||||
":first-letter",
|
||||
":first-line",
|
||||
":placeholder",
|
||||
":-moz-color-swatch",
|
||||
":-moz-focus-inner",
|
||||
":-moz-focus-outer",
|
||||
":-moz-list-bullet",
|
||||
":-moz-list-number",
|
||||
":-moz-math-anonymous",
|
||||
":-moz-meter-bar",
|
||||
":-moz-placeholder",
|
||||
":-moz-progress-bar",
|
||||
":-moz-range-progress",
|
||||
":-moz-range-thumb",
|
||||
":-moz-range-track",
|
||||
":-moz-selection",
|
||||
]);
|
||||
|
||||
let names = utils.getCSSPseudoElementNames();
|
||||
for (let name of names) {
|
||||
ok(expected.has(name), name + " is included");
|
||||
expected.delete(name);
|
||||
}
|
||||
|
||||
if (expected.size > 0) {
|
||||
todo_is(expected.size, 0,
|
||||
"ideally all pseudo-element names would be listed in this test");
|
||||
for (let extra of expected) {
|
||||
info("extra element: " + extra);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::getCSSPseudoElementNames</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
69
layout/inspector/tests/test_getRelativeRuleLine.html
Normal file
69
layout/inspector/tests/test_getRelativeRuleLine.html
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::getRelativeRuleLine</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
@supports (not (whatever: 72 zq)) {
|
||||
#test {
|
||||
background-color: #f0c;
|
||||
}
|
||||
}
|
||||
|
||||
#test {
|
||||
color: #f0c;
|
||||
}
|
||||
</style>
|
||||
<style>#test { color: red; }</style>
|
||||
<style>
|
||||
@invalidatkeyword {
|
||||
}
|
||||
|
||||
#test {
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{ sheetNo: 0, ruleNo: 0, lineNo: 1, columnNo: 1 },
|
||||
{ sheetNo: 1, ruleNo: 0, lineNo: 2, columnNo: 15 },
|
||||
{ sheetNo: 1, ruleNo: 1, lineNo: 8, columnNo: 5 },
|
||||
{ sheetNo: 2, ruleNo: 0, lineNo: 1, columnNo: 1 },
|
||||
{ sheetNo: 2, ruleNo: 1, lineNo: 0, columnNo: 1 },
|
||||
{ sheetNo: 3, ruleNo: 0, lineNo: 5, columnNo: 6 },
|
||||
];
|
||||
|
||||
function doTest() {
|
||||
document.styleSheets[2].insertRule("body{}", 1);
|
||||
for (let test of tests) {
|
||||
let sheet = document.styleSheets[test.sheetNo];
|
||||
let rule = sheet.cssRules[test.ruleNo];
|
||||
let line = utils.getRelativeRuleLine(rule);
|
||||
let column = utils.getRuleColumn(rule);
|
||||
info("testing sheet " + test.sheetNo + ", rule " + test.ruleNo);
|
||||
is(line, test.lineNo, "line number is correct");
|
||||
is(column, test.columnNo, "column number is correct");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::getRelativeRuleLine</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
44
layout/inspector/tests/test_get_all_style_sheets.html
Normal file
44
layout/inspector/tests/test_get_all_style_sheets.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=734861
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 734861</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 734861 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
var res = utils.getAllStyleSheets(document);
|
||||
|
||||
var foundUA = false;
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].href === "resource://gre-resources/ua.css") {
|
||||
foundUA = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(foundUA, "UA sheet should be returned with all the other sheets.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="runTest();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=734861">Mozilla Bug 734861</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
91
layout/inspector/tests/test_is_valid_css_color.html
Normal file
91
layout/inspector/tests/test_is_valid_css_color.html
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::isValidCSSColor</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
// Color names
|
||||
let colors = utils.getCSSValuesForProperty("color");
|
||||
let notColor = ["hsl", "hsla", "inherit", "initial", "rgb", "rgba",
|
||||
"unset", "transparent", "currentColor"];
|
||||
for (let color of colors) {
|
||||
if (notColor.indexOf(color) !== -1) {
|
||||
continue;
|
||||
}
|
||||
ok(utils.isValidCSSColor(color), color + " is a valid color");
|
||||
ok(!utils.isValidCSSColor("xxx" + color), "xxx" + color + " is not a valid color");
|
||||
}
|
||||
|
||||
// rgb(a)
|
||||
for (let i = 0; i <= 265; i++) {
|
||||
ok(utils.isValidCSSColor("rgb(" + i + ",0,0)"), "rgb(" + i + ",0,0) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0," + i + ",0)"), "rgb(0," + i + ",0) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0,0," + i + ")"), "rgb(0,0," + i + ") is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(" + i + ",0,0,0.2)"), "rgba(" + i + ",0,0,0.2) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0," + i + ",0,0.5)"), "rgba(0," + i + ",0,0.5) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0,0," + i + ",0.7)"), "rgba(0,0," + i + ",0.7) is a valid color");
|
||||
|
||||
ok(!utils.isValidCSSColor("rgbxxx(" + i + ",0,0)"), "rgbxxx(" + i + ",0,0) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbxxx(0," + i + ",0)"), "rgbxxx(0," + i + ",0) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbxxx(0,0," + i + ")"), "rgbxxx(0,0," + i + ") is not a valid color");
|
||||
}
|
||||
|
||||
// rgb(a) (%)
|
||||
for (let i = 0; i <= 110; i++) {
|
||||
ok(utils.isValidCSSColor("rgb(" + i + "%,0%,0%)"), "rgb(" + i + "%,0%,0%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0%," + i + "%,0%)"), "rgb(0%," + i + "%,0%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0%,0%," + i + "%)"), "rgb(0%,0%," + i + "%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(" + i + "%,0%,0%,0.2)"), "rgba(" + i + "%,0%,0%,0.2) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0%," + i + "%,0%,0.5)"), "rgba(0%," + i + "%,0%,0.5) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0%,0%," + i + "%,0.7)"), "rgba(0%,0%," + i + "%,0.7) is a valid color");
|
||||
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(" + i + "%,0%,0%,0.2)"), "rgbaxxx(" + i + "%,0%,0%,0.2) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(0%," + i + "%,0%,0.5)"), "rgbaxxx(0%," + i + "%,0%,0.5) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(0%,0%," + i + "%,0.7)"), "rgbaxxx(0%,0%," + i + "%,0.7) is not a valid color");
|
||||
}
|
||||
|
||||
// hsl(a)
|
||||
for (let i = 0; i <= 370; i++) {
|
||||
ok(utils.isValidCSSColor("hsl(" + i + ",30%,10%)"), "rgb(" + i + ",30%,10%) is a valid color");
|
||||
ok(utils.isValidCSSColor("hsla(" + i + ",60%,70%,0.2)"), "rgba(" + i + ",60%,70%,0.2) is a valid color");
|
||||
}
|
||||
for (let i = 0; i <= 110; i++) {
|
||||
ok(utils.isValidCSSColor("hsl(100," + i + "%,20%)"), "hsl(100," + i + "%,20%) is a valid color");
|
||||
ok(utils.isValidCSSColor("hsla(100,20%," + i + "%,0.6)"), "hsla(100,20%," + i + "%,0.6) is a valid color");
|
||||
}
|
||||
|
||||
// hex
|
||||
for (let i = 0; i <= 255; i++) {
|
||||
let hex = (i).toString(16);
|
||||
if (hex.length === 1) {
|
||||
hex = 0 + hex;
|
||||
}
|
||||
ok(utils.isValidCSSColor("#" + hex + "7777"), "#" + hex + "7777 is a valid color");
|
||||
ok(utils.isValidCSSColor("#77" + hex + "77"), "#77" + hex + "77 is a valid color");
|
||||
ok(utils.isValidCSSColor("#7777" + hex), "#7777" + hex + " is a valid color");
|
||||
}
|
||||
ok(!utils.isValidCSSColor("#kkkkkk"), "#kkkkkk is not a valid color");
|
||||
|
||||
// short hex
|
||||
for (let i = 0; i <= 16; i++) {
|
||||
let hex = (i).toString(16);
|
||||
ok(utils.isValidCSSColor("#" + hex + hex + hex), "#" + hex + hex + hex + " is a valid color");
|
||||
}
|
||||
ok(!utils.isValidCSSColor("#ggg"), "#ggg is not a valid color");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::isValidCSSColor</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
38
layout/inspector/tests/test_isinheritableproperty.html
Normal file
38
layout/inspector/tests/test_isinheritableproperty.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=699592
|
||||
-->
|
||||
<head>
|
||||
<title>Test for nsIDOMUtils::isInheritedProperty</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
is(utils.isInheritedProperty("font-size"), true, "font-size is inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("min-width"), false, "min-width is not inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("font"), true, "shorthand font property is inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("border"), false, "shorthand border property not inherited.");
|
||||
is(utils.isInheritedProperty("garbage"), false, "Unknown property isn't inherited.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
34
layout/inspector/tests/test_parseStyleSheet.html
Normal file
34
layout/inspector/tests/test_parseStyleSheet.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1195978
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1195978</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
body {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var sheet = document.styleSheets[1];
|
||||
is(domUtils.getRelativeRuleLine(sheet.cssRules[0]), 2,
|
||||
"initial relative rule line");
|
||||
is(domUtils.getRuleLine(sheet.cssRules[0]), 11,
|
||||
"initial rule line");
|
||||
|
||||
domUtils.parseStyleSheet(sheet, "\nbody {\n color: blue;\n}\n");
|
||||
is(domUtils.getRelativeRuleLine(sheet.cssRules[0]), 2,
|
||||
"relative rule line after reparsing");
|
||||
is(domUtils.getRuleLine(sheet.cssRules[0]), 11,
|
||||
"relative rule line after reparsing");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
83
layout/inspector/tests/test_parseStyleSheetImport.html
Normal file
83
layout/inspector/tests/test_parseStyleSheetImport.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1202095
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1202095</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
@import url('bug1202095.css');
|
||||
@import url('bug1202095-2.css');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
function do_test() {
|
||||
var sheet = document.styleSheets[1];
|
||||
var importRule = sheet.cssRules[0];
|
||||
is(importRule.type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"initial sheet has @import rule");
|
||||
|
||||
var importedSheet = importRule.styleSheet;
|
||||
importedSheet.deleteRule(0);
|
||||
is(importedSheet.cssRules.length, 0, "imported sheet now has no rules");
|
||||
|
||||
// "suffixed" refers to the "-2".
|
||||
var suffixedSheet = sheet.cssRules[1].styleSheet;
|
||||
domUtils.parseStyleSheet(suffixedSheet, "");
|
||||
is(suffixedSheet.cssRules.length, 0, "second imported sheet now has no rules");
|
||||
|
||||
// Re-parse the style sheet, preserving the imports.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
|
||||
"@import url('bug1202095-2.css');");
|
||||
is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"re-parsed sheet has @import rule");
|
||||
is(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"imported sheet has not changed");
|
||||
is(sheet.cssRules[1].styleSheet, suffixedSheet,
|
||||
"second imported sheet has not changed");
|
||||
|
||||
// Re-parse the style sheet, preserving both imports, but changing
|
||||
// the order.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095-2.css');" +
|
||||
"@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].styleSheet, suffixedSheet,
|
||||
"reordering preserved suffixed style sheet");
|
||||
is(sheet.cssRules[1].styleSheet, importedSheet,
|
||||
"reordering preserved unsuffixed style sheet");
|
||||
|
||||
// Re-parse the style sheet, removing the imports.
|
||||
domUtils.parseStyleSheet(sheet, "");
|
||||
is(sheet.cssRules.length, 0, "style sheet now has no rules");
|
||||
|
||||
// Re-parse the style sheet, adding one import back. This should
|
||||
// not allow reuse.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"re-re-re-parsed sheet has @import rule");
|
||||
isnot(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"imported sheet has changed now");
|
||||
|
||||
// Re-parse the style sheet, importing the same URL twice.
|
||||
// The style sheet should be reused once, but not two times.
|
||||
importedSheet = sheet.cssRules[0].styleSheet;
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
|
||||
"@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"first imported sheet is reused");
|
||||
isnot(sheet.cssRules[1].styleSheet, importedSheet,
|
||||
"second imported sheet is reused");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
90
layout/inspector/tests/test_selectormatcheselement.html
Normal file
90
layout/inspector/tests/test_selectormatcheselement.html
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1037519
|
||||
-->
|
||||
<head>
|
||||
<title>Test for nsIDOMUtils::selectorMatchesElement</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style type="text/css">
|
||||
#foo,
|
||||
#bar,
|
||||
#foo::before {
|
||||
color: red;
|
||||
}
|
||||
#foo::before,
|
||||
#bar::before {
|
||||
content: 'foo-before';
|
||||
color: green;
|
||||
}
|
||||
#foo::after,
|
||||
#bar::after {
|
||||
content: 'foo-after';
|
||||
color: blue;
|
||||
}
|
||||
#foo::first-line,
|
||||
#bar::first-line {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#foo::first-letter,
|
||||
#bar::first-letter {
|
||||
font-variant: small-caps;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="foo">foo content</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var element = document.querySelector("#foo");
|
||||
|
||||
var elementRules = utils.getCSSStyleRules(element);
|
||||
var elementRule = elementRules.GetElementAt(elementRules.Count() - 1);
|
||||
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0), true,
|
||||
"Matches #foo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 1), false,
|
||||
"Doesn't match #bar");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0, ":bogus"), false,
|
||||
"Doesn't match #foo with a bogus pseudo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 2, ":bogus"), false,
|
||||
"Doesn't match #foo::before with bogus pseudo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0, ":after"), false,
|
||||
"Does match #foo::before with the :after pseudo");
|
||||
|
||||
checkPseudo(":before");
|
||||
checkPseudo(":after");
|
||||
checkPseudo(":first-letter");
|
||||
checkPseudo(":first-line");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
||||
function checkPseudo(pseudo) {
|
||||
var rules = utils.getCSSStyleRules(element, pseudo);
|
||||
var rule = rules.GetElementAt(rules.Count() - 1);
|
||||
|
||||
is (utils.selectorMatchesElement(element, rule, 0), false,
|
||||
"Doesn't match without " + pseudo);
|
||||
is (utils.selectorMatchesElement(element, rule, 1), false,
|
||||
"Doesn't match without " + pseudo);
|
||||
|
||||
is (utils.selectorMatchesElement(element, rule, 0, pseudo), true,
|
||||
"Matches on #foo" + pseudo);
|
||||
is (utils.selectorMatchesElement(element, rule, 1, pseudo), false,
|
||||
"Doesn't match on #bar" + pseudo);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue