зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1035091 part 2: disable @-moz-document in author sheets. r=heycam
--HG-- rename : layout/style/test/test_condition_text.html => layout/style/test/chrome/moz_document_condition_text.css rename : layout/style/test/test_rule_serialization.html => layout/style/test/chrome/moz_document_serialization.css rename : layout/style/test/test_condition_text.html => layout/style/test/chrome/test_moz_document_condition_text.html rename : layout/style/test/chrome/test_moz_document_rules.html => layout/style/test/chrome/test_moz_document_matching.html rename : layout/style/test/test_bug511909.html => layout/style/test/chrome/test_moz_document_nesting.html rename : layout/style/test/test_rule_serialization.html => layout/style/test/chrome/test_moz_document_serialization.html extra : rebase_source : 9d97f4cfe5e5e3bbda1d1b7910db44faf33d14c1
This commit is contained in:
Родитель
a48ac7cfae
Коммит
7912db5bd1
|
@ -169,3 +169,4 @@ PEExpectedVariableNameEOF=identifier for variable name
|
|||
PEExpectedVariableName=Expected identifier for variable name but found '%1$S'.
|
||||
PEExpectedVariableFallback=Expected variable reference fallback after ','.
|
||||
PEExpectedVariableCommaOrCloseParen=Expected ',' or ')' after variable name in variable reference but found '%1$S'.
|
||||
PEMozDocumentRuleNotAllowed=@-moz-document rules may only be used in user style sheets.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=520182
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=520189
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 520182</title>
|
||||
<title>Test for Bug 520189</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
@ -79,7 +79,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520182
|
|||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 520182 **/
|
||||
/** Test for Bug 520189 **/
|
||||
|
||||
const dataPayload = "foo<iframe src=\"data:text/html,bar\"></iframe>baz";
|
||||
const jsPayload = "foo<iframe src=\"javascript:void('bar');\"></iframe>baz";
|
||||
|
@ -421,13 +421,21 @@ var tests = [
|
|||
isIFrame: true,
|
||||
payload: invalidStyle8Payload,
|
||||
rootElement() { return document.getElementById("ss").contentDocument.documentElement; },
|
||||
checkResult(html) { is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
// The sanitizer currently doesn't discard unrecognized rules when
|
||||
// that would make the sheet completely empty (see bug 1177546).
|
||||
// This is harmless, since @-moz-document is inoperative in author
|
||||
// style sheets (see bug 1035091).
|
||||
checkResult(html) { todo_is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
},
|
||||
{
|
||||
id: "tt",
|
||||
payload: invalidStyle8Payload,
|
||||
rootElement() { return document.getElementById("tt"); },
|
||||
checkResult(html) { is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
// The sanitizer currently doesn't discard unrecognized rules when
|
||||
// that would make the sheet completely empty (see bug 1177546).
|
||||
// This is harmless, since @-moz-document is inoperative in author
|
||||
// style sheets (see bug 1035091).
|
||||
checkResult(html) { todo_is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
},
|
||||
{
|
||||
id: "uu",
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
== scoped-style-media.html scoped-style-media-ref.html
|
||||
== scoped-style-namespace.html scoped-style-namespace-ref.html
|
||||
== scoped-style-charset.html scoped-style-charset-ref.html
|
||||
== scoped-style-document.html scoped-style-document-ref.html
|
||||
HTTP(..) == scoped-style-font-face.html scoped-style-font-face-ref.html
|
||||
== scoped-style-keyframes.html scoped-style-keyframes-ref.html
|
||||
== scoped-style-supports.html scoped-style-supports-ref.html
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>First</p>
|
||||
<p style="color: blue">Second</p>
|
||||
<p>Third</p>
|
||||
</body>
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>First</p>
|
||||
<p>
|
||||
<style scoped>
|
||||
@-moz-document regexp("^.*scoped-style-document\\.html$") {
|
||||
p { color: blue }
|
||||
}
|
||||
</style>
|
||||
Second
|
||||
</p>
|
||||
<p>Third</p>
|
||||
</body>
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>CSS Test: A nested @supports rule with valid syntax and a passing condition must apply rules inside it</title>
|
||||
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-document" />
|
||||
<meta name="flags" content="" />
|
||||
<meta name="assert" content="An outer @document rule with an inner @supports rule must apply the rules inside the @supports only if both the @supports and @document conditions pass."/>
|
||||
<link rel="match" href="support/pass.xht" />
|
||||
<style type="text/css"><![CDATA[
|
||||
@-moz-document url-prefix("") {
|
||||
@supports (color: green) {
|
||||
html { background-color: green }
|
||||
}
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>CSS Test: A nested @supports rule with valid syntax and a passing condition must apply rules inside it</title>
|
||||
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
|
||||
<meta name="flags" content="" />
|
||||
<meta name="assert" content="An inner @document rule with an outer @supports rule must apply the rules inside the @document only if both the @supports and @document conditions pass."/>
|
||||
<link rel="match" href="support/pass.xht" />
|
||||
<style type="text/css"><![CDATA[
|
||||
@supports (color: green) {
|
||||
@-moz-document url-prefix("") {
|
||||
html { background-color: green }
|
||||
}
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -24,8 +24,6 @@
|
|||
== css-supports-024.xht support/pass.xht
|
||||
== css-supports-025.xht support/pass.xht
|
||||
== css-supports-026.xht support/pass.xht
|
||||
== css-supports-027.xht support/pass.xht
|
||||
== css-supports-028.xht support/pass.xht
|
||||
== css-supports-029.xht support/pass.xht
|
||||
== css-supports-030.xht support/pass.xht
|
||||
== css-supports-031.xht support/pass.xht
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
@import # { }
|
||||
@namespace # { }
|
||||
@media # { }
|
||||
@-moz-document # { }
|
||||
@font-face # { }
|
||||
@page # { }
|
||||
@-non-mozilla # { }
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
|
||||
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
|
||||
<script>
|
||||
// Force a unique inner for the second linked sheet
|
||||
document.styleSheets[1].cssRules[0];
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
|
|
@ -49,9 +49,7 @@ load 478321-1.xhtml
|
|||
load 512851-1.xhtml
|
||||
load 539613-1.xhtml
|
||||
load 588627-1.html
|
||||
skip load long-url-list-stack-overflow.html # skipped due to being slow (bug 477490)
|
||||
load 495269-1.html
|
||||
load 495269-2.html
|
||||
load 498036-1.html
|
||||
load 509155-1.html
|
||||
load 509156-1.html
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style id="s"></style>
|
||||
<script type="text/javascript">
|
||||
|
||||
// Duplicates the string 2^n times
|
||||
function exp(s, n)
|
||||
{
|
||||
for (var i = 0; i < n; ++i)
|
||||
s += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
var stylesheet = "@-moz-document url(http://www.w3.org/)" + exp(", url-prefix(file:///)", 20) + " { }";
|
||||
document.getElementById("s").textContent = stylesheet;
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div></div>
|
||||
</body>
|
||||
</html>
|
|
@ -2999,8 +2999,14 @@ CSSParserImpl::ParseAtRule(RuleAppendFunc aAppendFunc,
|
|||
newSection = eCSSSection_General;
|
||||
|
||||
} else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-document")) {
|
||||
if (UserRulesEnabled()) {
|
||||
parseFunc = &CSSParserImpl::ParseMozDocumentRule;
|
||||
newSection = eCSSSection_General;
|
||||
} else {
|
||||
REPORT_UNEXPECTED_TOKEN(PEMozDocumentRuleNotAllowed);
|
||||
OUTPUT_ERROR();
|
||||
return SkipAtRule(aInAtRule);
|
||||
}
|
||||
|
||||
} else if (mToken.mIdent.LowerCaseEqualsLiteral("font-face")) {
|
||||
parseFunc = &CSSParserImpl::ParseFontFaceRule;
|
||||
|
|
|
@ -8,6 +8,9 @@ support-files =
|
|||
hover_helper.html
|
||||
match.png
|
||||
mismatch.png
|
||||
moz_document_condition_text.css
|
||||
moz_document_nesting.css
|
||||
moz_document_serialization.css
|
||||
|
||||
[test_addSheet.html]
|
||||
[test_additional_sheets.html]
|
||||
|
@ -18,4 +21,9 @@ support-files =
|
|||
[test_bug535806.xul]
|
||||
[test_hover.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_moz_document_rules.html]
|
||||
[test_moz_document_condition_text.html]
|
||||
[test_moz_document_crashes.html]
|
||||
[test_moz_document_matching.html]
|
||||
[test_moz_document_nesting.html]
|
||||
[test_moz_document_serialization.html]
|
||||
[test_moz_document_usability.html]
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/* Bug 814907 (@-moz-document cases) */
|
||||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
|
@ -0,0 +1,89 @@
|
|||
/* formerly test_bug511909.html */
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
#pink {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
#green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#blue {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#d {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
#m {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
#dm {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#md {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* syntax error - recover at end of @media block */
|
||||
@media print { @-moz-document regexp("not_this_url") , }
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
/* syntax error - recover at end of @-moz-document block */
|
||||
@-moz-document regexp("not_this_url") { @media , }
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
#me {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* formerly reftests/w3c-css/submitted/conditional3/css-supports-027.xht */
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@supports (color: green) {
|
||||
#mf { color: green }
|
||||
}
|
||||
}
|
||||
|
||||
/* formerly reftests/w3c-css/submitted/conditional3/css-supports-028.xht */
|
||||
@supports (color: pink) {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#mg { color: pink }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
|
@ -0,0 +1,61 @@
|
|||
<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Test for Bug 814907 (@-moz-document cases)</title>
|
||||
<!-- Split from test_condition_text.html.
|
||||
This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script type="application/javascript" src="/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/content/tests/SimpleTest/test.css"/>
|
||||
</head><body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=814907">Mozilla Bug 814907</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_condition_text.css", null, document.baseURIObject);
|
||||
|
||||
var sheet =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService)
|
||||
.preloadSheet(sheetURI, Components.interfaces.nsIStyleSheetService.USER_SHEET);
|
||||
|
||||
windowUtils.addSheet(sheet, windowUtils.USER_SHEET);
|
||||
|
||||
addLoadEvent(function () {
|
||||
var conditions = [
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"domain(\"example.com\")",
|
||||
"domain(\"example.com\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
];
|
||||
|
||||
is(sheet.cssRules.length, conditions.length);
|
||||
|
||||
for (var i = 0; i < sheet.cssRules.length; i++) {
|
||||
var rule = sheet.cssRules[i];
|
||||
is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
|
||||
if (rule.type == CSSRule.MEDIA_RULE) {
|
||||
is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,53 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@-moz-document crash tests</title>
|
||||
<!-- This test was formerly known as
|
||||
crashtests/long-url-list-stack-overflow.html and
|
||||
crashtests/495269-2.html.
|
||||
|
||||
This is a chrome mochitest because @-moz-document can only be
|
||||
used from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
</head><body>
|
||||
<script>
|
||||
// Duplicates the string 2^n times
|
||||
function exp(s, n)
|
||||
{
|
||||
for (var i = 0; i < n; ++i)
|
||||
s += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var ios =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var sss =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService);
|
||||
|
||||
var style = "@-moz-document url(http://www.w3.org/)" + exp(", url-prefix(file:///)", 20) + " { }";
|
||||
var url1 = ios.newURI("data:text/css," + style, null, null)
|
||||
|
||||
// should not crash at this point
|
||||
windowUtils.loadSheet(url1, windowUtils.USER_SHEET);
|
||||
ok(true, "long-url-list-stack-overflow: no crash");
|
||||
|
||||
var url2 = ios.newURI("data:text/css,@-moz-document domain(example.com) {}';", null, null);
|
||||
|
||||
var sheet1 = sss.preloadSheet(url2, sss.USER_SHEET);
|
||||
var sheet2 = sss.preloadSheet(url2, sss.USER_SHEET);
|
||||
windowUtils.addSheet(sheet1, windowUtils.USER_SHEET);
|
||||
windowUtils.addSheet(sheet2, windowUtils.USER_SHEET);
|
||||
|
||||
// Force a unique inner for the second linked sheet; should not crash
|
||||
sheet2.cssRules[0];
|
||||
ok(true, "495269-2: no crash");
|
||||
</script>
|
||||
</body></html>
|
|
@ -0,0 +1,120 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@media and @-moz-document testcases</title>
|
||||
<!-- This test was formerly known as test_bug511909.html.
|
||||
This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
</head><body>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_nesting.css", null, document.baseURIObject);
|
||||
|
||||
windowUtils.loadSheet(sheetURI, windowUtils.USER_SHEET);
|
||||
|
||||
addLoadEvent(function() {
|
||||
var pink = getComputedStyle(document.getElementById("pink"), "");
|
||||
var green = getComputedStyle(document.getElementById("green"), "");
|
||||
var blue = getComputedStyle(document.getElementById("blue"), "");
|
||||
|
||||
var cs1 = getComputedStyle(document.getElementById("d"), "");
|
||||
var cs2 = getComputedStyle(document.getElementById("m"), "");
|
||||
var cs3 = getComputedStyle(document.getElementById("dm"), "");
|
||||
var cs4 = getComputedStyle(document.getElementById("md"), "");
|
||||
var cs5 = getComputedStyle(document.getElementById("mx"), "");
|
||||
var cs6 = getComputedStyle(document.getElementById("mxx"), "");
|
||||
var cs7 = getComputedStyle(document.getElementById("me"), "");
|
||||
var cs8 = getComputedStyle(document.getElementById("mf"), "");
|
||||
var cs9 = getComputedStyle(document.getElementById("mg"), "");
|
||||
|
||||
is(cs1.color, pink.color, "@-moz-document applies");
|
||||
is(cs2.color, green.color, "@media applies");
|
||||
is(cs3.color, blue.color, "@media nested in @-moz-document applies");
|
||||
is(cs4.color, green.color, "@-moz-document nested in @media applies");
|
||||
is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled");
|
||||
is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled");
|
||||
is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
|
||||
is(cs8.color, green.color, "@supports nested in @-moz-document applies");
|
||||
is(cs9.color, pink.color, "@-moz-document nested in @supports applies");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
|
||||
<pre>default style
|
||||
</pre>
|
||||
<a id="pink">This line should be pink</a><br>
|
||||
<a id="green">This line should be green</a><br>
|
||||
<a id="blue">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {...}
|
||||
</pre>
|
||||
<a id="d">This line should be pink</a><br>
|
||||
|
||||
<pre>@media screen {...}
|
||||
</pre>
|
||||
<a id="m">This line should be green</a><br>
|
||||
|
||||
<pre>@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="dm">This line should be blue</a><br>
|
||||
|
||||
<pre>@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mx">This line should be pink</a><br></div>
|
||||
|
||||
<pre>@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mxx">This line should be blue</a><br>
|
||||
|
||||
<pre>@media screen {
|
||||
@-moz-document {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="md">This line should be green</a><br>
|
||||
|
||||
<pre>@media screen {
|
||||
@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="me">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {
|
||||
@supports { ... }
|
||||
}
|
||||
</pre>
|
||||
<a id="mf">This line should be green</a><br>
|
||||
|
||||
<pre>@supports {
|
||||
@-moz-document { ... }
|
||||
}
|
||||
</pre>
|
||||
<a id="mg">This line should be pink</a><br>
|
||||
|
||||
</body></html>
|
|
@ -0,0 +1,50 @@
|
|||
<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Test for reserialization of @-moz-document rules</title>
|
||||
<!-- This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script type="application/javascript" src="/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/content/tests/SimpleTest/test.css"/>
|
||||
|
||||
</head><body>
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_serialization.css", null, document.baseURIObject);
|
||||
|
||||
var sheet =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService)
|
||||
.preloadSheet(sheetURI, Components.interfaces.nsIStyleSheetService.USER_SHEET);
|
||||
|
||||
windowUtils.addSheet(sheet, windowUtils.USER_SHEET);
|
||||
|
||||
var rules = [
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url-prefix("http://www.example.com/") {\n}',
|
||||
'@-moz-document url-prefix("http://www.example.com/") {\n}',
|
||||
'@-moz-document domain("example.com") {\n}',
|
||||
'@-moz-document domain("example.com") {\n}',
|
||||
'@-moz-document regexp("http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/") {\n}',
|
||||
'@-moz-document regexp("http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/") {\n}',
|
||||
];
|
||||
|
||||
addLoadEvent(function () {
|
||||
is(sheet.cssRules.length, rules.length, "number of rules");
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
is(sheet.cssRules[i].cssText, rules[i], "serialization for rule " + i);
|
||||
}
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,56 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@-moz-document usability test (Bug 1035091)</title>
|
||||
<!-- Per https://bugzilla.mozilla.org/show_bug.cgi?id=1035091
|
||||
@-moz-document rules can only be used in user and UA style sheets
|
||||
until further notice. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
<style>
|
||||
#green { color: green }
|
||||
#author { color: green }
|
||||
#user { color: red }
|
||||
#agent { color: red }
|
||||
</style>
|
||||
</head><body>
|
||||
|
||||
<p id="green">All text should be green.</p>
|
||||
<p id="author">All text should be green.</p>
|
||||
<p id="user">All text should be green.</p>
|
||||
<p id="agent">All text should be green.</p>
|
||||
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var wu =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var ios =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
function makeSheet(whom, color) {
|
||||
return ios.newURI(
|
||||
"data:text/css,@-moz-document regexp('.*test_moz_document.*') {" +
|
||||
"%23" + whom + " { color: " + color + "!important } }",
|
||||
null, null);
|
||||
}
|
||||
wu.loadSheet(makeSheet("author", "red"), wu.AUTHOR_SHEET);
|
||||
wu.loadSheet(makeSheet("user", "green"), wu.USER_SHEET);
|
||||
wu.loadSheet(makeSheet("agent", "green"), wu.AGENT_SHEET);
|
||||
|
||||
addLoadEvent(function () {
|
||||
var green = getComputedStyle(document.getElementById("green"), "").color;
|
||||
var author = getComputedStyle(document.getElementById("author"), "").color;
|
||||
var user = getComputedStyle(document.getElementById("user"), "").color;
|
||||
var agent = getComputedStyle(document.getElementById("agent"), "").color;
|
||||
|
||||
is(author, green, "@-moz-document should not be honored in author sheets");
|
||||
is(user, green, "@-moz-document should be honored in user sheets");
|
||||
is(agent, green, "@-moz-document should be honored in agent sheets");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body></html>
|
|
@ -93,7 +93,6 @@ support-files = bug453896_iframe.html
|
|||
[test_bug470769.html]
|
||||
[test_bug499655.html]
|
||||
[test_bug499655.xhtml]
|
||||
[test_bug511909.html]
|
||||
[test_bug517224.html]
|
||||
support-files = bug517224.sjs
|
||||
[test_bug524175.html]
|
||||
|
@ -220,7 +219,6 @@ support-files = redundant_font_download.sjs
|
|||
[test_root_node_display.html]
|
||||
[test_rule_insertion.html]
|
||||
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(monospace and serif text have sufficiently different widths) b2g-desktop(monospace and serif text have sufficiently different widths)
|
||||
[test_rule_serialization.html]
|
||||
[test_rules_out_of_sheets.html]
|
||||
[test_selectors.html]
|
||||
skip-if = (toolkit == 'gonk' && debug) || toolkit == 'android' #bug 775227 #debug-only failure; timed out
|
||||
|
|
|
@ -1,205 +0,0 @@
|
|||
<html><!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=511909
|
||||
--><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>@media and @-moz-document testcases</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
|
||||
<style type="text/css">
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
#pink {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
#green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#blue {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
#d {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
#m {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
#dm {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- should parse -->
|
||||
<style type="text/css">
|
||||
|
||||
@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- should parse -->
|
||||
<style type="text/css">
|
||||
|
||||
@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
#md {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
#me {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511909">Mozilla Bug 511909</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
var pink = getComputedStyle(document.getElementById("pink"), "");
|
||||
var green = getComputedStyle(document.getElementById("green"), "");
|
||||
var blue = getComputedStyle(document.getElementById("blue"), "");
|
||||
|
||||
var cs1 = getComputedStyle(document.getElementById("d"), "");
|
||||
var cs2 = getComputedStyle(document.getElementById("m"), "");
|
||||
var cs3 = getComputedStyle(document.getElementById("dm"), "");
|
||||
var cs4 = getComputedStyle(document.getElementById("md"), "");
|
||||
var cs5 = getComputedStyle(document.getElementById("mx"), "");
|
||||
var cs6 = getComputedStyle(document.getElementById("mxx"), "");
|
||||
var cs7 = getComputedStyle(document.getElementById("me"), "");
|
||||
|
||||
is(cs1.color, pink.color, "@-moz-document applies");
|
||||
is(cs2.color, green.color, "@media applies");
|
||||
is(cs3.color, blue.color, "@media nested in @-moz-document applies");
|
||||
is(cs4.color, green.color, "@-moz-document nested in @media applies");
|
||||
is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled");
|
||||
is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled");
|
||||
is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
<div>
|
||||
<pre>default style
|
||||
</pre>
|
||||
<a id="pink">This line should be pink</a><br>
|
||||
|
||||
<a id="green">This line should be green</a><br>
|
||||
|
||||
<a id="blue">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {...}
|
||||
</pre>
|
||||
<a id="d">This line should be pink</a><br>
|
||||
<pre>@media screen {...}
|
||||
</pre>
|
||||
<a id="m">This line should be green</a><br>
|
||||
<pre>@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="dm">This line should be blue</a><br>
|
||||
<pre>@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mx">This line should be pink</a><br></div>
|
||||
<pre>@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mxx">This line should be blue</a><br>
|
||||
<pre>@media screen {
|
||||
@-moz-documen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="md">This line should be green</a><br>
|
||||
<pre>@media screen {
|
||||
@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="me">This line should be blue</a><br>
|
||||
|
||||
|
||||
</body></html>
|
|
@ -8,16 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907
|
|||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style id="style">
|
||||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
||||
|
||||
@media all {}
|
||||
@media only color {}
|
||||
@media (color ) {}
|
||||
|
@ -42,24 +32,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907
|
|||
|
||||
/** Test for Bug 814907 **/
|
||||
|
||||
function runTest()
|
||||
{
|
||||
// re-parse the style sheet with the pref turned on
|
||||
var style = document.getElementById("style");
|
||||
style.textContent += " ";
|
||||
|
||||
var sheet = style.sheet;
|
||||
|
||||
var conditions = [
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"domain(\"example.com\")",
|
||||
"domain(\"example.com\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"all",
|
||||
"only color",
|
||||
"(color)",
|
||||
|
@ -81,12 +59,6 @@ function runTest()
|
|||
is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -183,16 +183,6 @@ const tests = [
|
|||
ref: "@namespace 'http://foo.example.com/';",
|
||||
tst: "@namespace 'http://foo.example.com/"
|
||||
},
|
||||
{
|
||||
name: "@-moz-document 1",
|
||||
ref: "@-moz-document domain('example.com') {}",
|
||||
tst: "@-moz-document domain('example.com') {"
|
||||
},
|
||||
{
|
||||
name: "@-moz-document 2",
|
||||
ref: "@-moz-document domain('example.com') { p {} }",
|
||||
tst: "@-moz-document domain('example.com') { p {"
|
||||
}
|
||||
];
|
||||
|
||||
const basestyle = ("table {\n"+
|
||||
|
|
|
@ -69,7 +69,6 @@ var cjkDecimalWidth = controlCJKDecimal.getBoundingClientRect().width;
|
|||
// [at-rule type, passing condition, failing condition]
|
||||
var outerRuleInfo = [
|
||||
["@media", "all", "not all"],
|
||||
["@-moz-document", "url-prefix('')", "url-prefix('zzz')"],
|
||||
["@supports", "(color: green)", "(unknown: unknown)"]
|
||||
];
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug </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" id="style"></style>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var rules = [
|
||||
{ rule: "@-moz-document url(http://www.example.com/) {}" },
|
||||
{ rule: "@-moz-document url('http://www.example.com/') {}" },
|
||||
{ rule: '@-moz-document url("http://www.example.com/") {}' },
|
||||
{ rule: "@-moz-document url-prefix('http://www.example.com/') {}" },
|
||||
{ rule: '@-moz-document url-prefix("http://www.example.com/") {}' },
|
||||
{ rule: "@-moz-document domain('example.com') {}" },
|
||||
{ rule: '@-moz-document domain("example.com") {}' },
|
||||
{ rule: "@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}" },
|
||||
{ rule: '@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}' },
|
||||
];
|
||||
|
||||
var style = document.getElementById("style");
|
||||
var style_text = document.createTextNode("");
|
||||
style.appendChild(style_text);
|
||||
|
||||
for (var i in rules) {
|
||||
var obj = rules[i];
|
||||
var rule = obj.rule;
|
||||
|
||||
style_text.data = rule;
|
||||
is(style.sheet.cssRules.length, 1, "should have one rule");
|
||||
var ser1 = style.sheet.cssRules[0].cssText;
|
||||
if ("is_canonical" in obj) {
|
||||
is(ser1, rule, "rule '" + rule + "' should serialize to itself");
|
||||
}
|
||||
|
||||
style_text.data = ser1;
|
||||
is(style.sheet.cssRules.length, 1, "should have one rule");
|
||||
var ser2 = style.sheet.cssRules[0].cssText;
|
||||
is(ser2, ser1,
|
||||
"parse+serialize for rule '" + rule + "' should be idempotent");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче