Bug 1851097 - Remove layout.css.moz-document.content.enabled pref r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D187349
This commit is contained in:
Gregory Pappas 2023-09-15 18:08:14 +00:00
parent b80b17d4d2
commit 4083653f6a
15 changed files with 144 additions and 237 deletions

View file

@ -99,7 +99,7 @@ const invalidStyle4Payload = "foo<span style=\"@import 'xxx.css';\">bar</span>ba
const invalidStyle5Payload = "foo<span style=\"@font-face{font-family:xxx;src:'xxx.ttf';}\">bar</span>baz"; const invalidStyle5Payload = "foo<span style=\"@font-face{font-family:xxx;src:'xxx.ttf';}\">bar</span>baz";
const invalidStyle6Payload = "foo<span style=\"@namespace xxx url(http://example.com/);\">bar</span>baz"; const invalidStyle6Payload = "foo<span style=\"@namespace xxx url(http://example.com/);\">bar</span>baz";
const invalidStyle7Payload = "<html><head><title>xxx</title></head><body>foo</body></html>"; const invalidStyle7Payload = "<html><head><title>xxx</title></head><body>foo</body></html>";
const invalidStyle8Payload = "foo<style>@-moz-document url(http://example.com/) {};</style>baz"; const invalidStyle8Payload = "foo<style>@-moz-document url-prefix() {};</style>baz";
const invalidStyle9Payload = "foo<style>@-moz-keyframes bar {};</style>baz"; const invalidStyle9Payload = "foo<style>@-moz-keyframes bar {};</style>baz";
const nestedStylePayload = "foo<style>#bar1{-moz-binding:url('data:text/xml,<?xml version=&quot;1.0&quot;><binding xmlns=&quot;http://www.mozilla.org/xbl&quot; id=&quot;binding-1&quot;/>');<style></style>#bar2{-moz-binding:url('data:text/xml,<?xml version=&quot;1.0&quot;><binding xmlns=&quot;http://www.mozilla.org/xbl&quot; id=&quot;binding-2&quot;/>');</style>baz"; const nestedStylePayload = "foo<style>#bar1{-moz-binding:url('data:text/xml,<?xml version=&quot;1.0&quot;><binding xmlns=&quot;http://www.mozilla.org/xbl&quot; id=&quot;binding-1&quot;/>');<style></style>#bar2{-moz-binding:url('data:text/xml,<?xml version=&quot;1.0&quot;><binding xmlns=&quot;http://www.mozilla.org/xbl&quot; id=&quot;binding-2&quot;/>');</style>baz";
const validImgSrc1Payload = "foo<img src=\"data:image/png,bar\">baz"; const validImgSrc1Payload = "foo<img src=\"data:image/png,bar\">baz";
@ -610,9 +610,7 @@ function runTest(test) {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
SpecialPowers.pushPrefEnv( doNextTest();
{ "set": [["layout.css.moz-document.content.enabled", true]]},
doNextTest);
}); });
</script> </script>
</pre> </pre>

View file

@ -1,7 +0,0 @@
<!doctype html>
<style>
@-moz-document url-prefix() {
div { color: green; }
}
</style>
<div>Should be green</div>

View file

@ -1790,8 +1790,6 @@ pref(browser.display.use_document_fonts,0) == 1022481-1.html 1022481-1-ref.html
fuzzy(0-1,0-126000) == 1022612-1.html 1022612-1-ref.html fuzzy(0-1,0-126000) == 1022612-1.html 1022612-1-ref.html
skip-if(Android&&emulator) == 1024473-1.html 1024473-1-ref.html skip-if(Android&&emulator) == 1024473-1.html 1024473-1-ref.html
fuzzy(0-1,0-24000) == 1025914-1.html 1025914-1-ref.html fuzzy(0-1,0-24000) == 1025914-1.html 1025914-1-ref.html
pref(layout.css.moz-document.content.enabled,true) == 1035091.html 1035091-ref.html
pref(layout.css.moz-document.content.enabled,false) == 1035091-2.html 1035091-ref.html
== 1042104-1.html 1042104-1-ref.html == 1042104-1.html 1042104-1-ref.html
== 1043537-1.html 1043537-1-ref.html == 1043537-1.html 1043537-1-ref.html
== 1044198-1.html 1044198-1-ref.html == 1044198-1.html 1044198-1-ref.html

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<link rel="stylesheet" href="data:text/css,@-moz-document regexp('.*') {div { color: green; }}">
<link rel="stylesheet" href="data:text/css,@-moz-document regexp('.*') {div { color: green; }}">
<div>This should be green</div>
<script>
onload = function() {
var links = document.getElementsByTagName("link");
links[0].sheet.cssRules[0].cssRules[0].style.color = "red";
}
</script>

View file

@ -1,6 +1,5 @@
== counter-style-rule-clone.html glyphs-ref.html # passes trivially == counter-style-rule-clone.html glyphs-ref.html # passes trivially
# because "Dynamic change on @counter-style not yet supported" # because "Dynamic change on @counter-style not yet supported"
pref(layout.css.moz-document.content.enabled,true) == document-rule-clone.html shouldbegreen-ref.html
== media-rule-clone.html shouldbegreen-ref.html == media-rule-clone.html shouldbegreen-ref.html
== insert-after-clone.html shouldbegreen-ref.html == insert-after-clone.html shouldbegreen-ref.html
== style-rule-clone.html shouldbegreen-ref.html == style-rule-clone.html shouldbegreen-ref.html

View file

@ -12,6 +12,8 @@ support-files = [
["test_bug1157097.html"] ["test_bug1157097.html"]
["test_bug511909.html"]
["test_bug1346623.html"] ["test_bug1346623.html"]
["test_bug1371453.html"] ["test_bug1371453.html"]
@ -38,6 +40,8 @@ skip-if = ["true"] # bug 1346353
["test_moz_document_rules.html"] ["test_moz_document_rules.html"]
["test_moz_document_serialization.html"]
["test_scrollbar_inline_size.html"] ["test_scrollbar_inline_size.html"]
["test_stylesheet_clone_import_rule.html"] ["test_stylesheet_clone_import_rule.html"]

View file

@ -4,12 +4,12 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>@media and @-moz-document testcases</title> <title>@media and @-moz-document testcases</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<style type="text/css"> <style type="text/css">
a { a {
font-weight: bold; font-weight: bold;
} }
#pink { #pink {
color: pink; color: pink;
@ -112,36 +112,32 @@ pre {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
SpecialPowers.pushPrefEnv( // Ensure all the sheets are re-parsed, so that the pref applies.
{ "set": [["layout.css.moz-document.content.enabled", true ]]}, for (const sheet of Array.from(document.querySelectorAll('style'))) {
function() { sheet.textContent += "/* dummy */";
// Ensure all the sheets are re-parsed, so that the pref applies. }
for (const sheet of Array.from(document.querySelectorAll('style'))) {
sheet.textContent += "/* dummy */";
}
var pink = getComputedStyle(document.getElementById("pink"), ""); var pink = getComputedStyle(document.getElementById("pink"), "");
var green = getComputedStyle(document.getElementById("green"), ""); var green = getComputedStyle(document.getElementById("green"), "");
var blue = getComputedStyle(document.getElementById("blue"), ""); var blue = getComputedStyle(document.getElementById("blue"), "");
var cs1 = getComputedStyle(document.getElementById("d"), ""); var cs1 = getComputedStyle(document.getElementById("d"), "");
var cs2 = getComputedStyle(document.getElementById("m"), ""); var cs2 = getComputedStyle(document.getElementById("m"), "");
var cs3 = getComputedStyle(document.getElementById("dm"), ""); var cs3 = getComputedStyle(document.getElementById("dm"), "");
var cs4 = getComputedStyle(document.getElementById("md"), ""); var cs4 = getComputedStyle(document.getElementById("md"), "");
var cs5 = getComputedStyle(document.getElementById("mx"), ""); var cs5 = getComputedStyle(document.getElementById("mx"), "");
var cs6 = getComputedStyle(document.getElementById("mxx"), ""); var cs6 = getComputedStyle(document.getElementById("mxx"), "");
var cs7 = getComputedStyle(document.getElementById("me"), ""); var cs7 = getComputedStyle(document.getElementById("me"), "");
is(cs1.color, pink.color, "@-moz-document applies"); is(cs1.color, pink.color, "@-moz-document applies");
is(cs2.color, green.color, "@media applies"); is(cs2.color, green.color, "@media applies");
is(cs3.color, blue.color, "@media nested in @-moz-document applies"); is(cs3.color, blue.color, "@media nested in @-moz-document applies");
is(cs4.color, green.color, "@-moz-document nested in @media 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(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(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(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
SimpleTest.finish(); SimpleTest.finish();
}) });
});
</script> </script>
<div> <div>
<pre>default style <pre>default style

View file

@ -0,0 +1,58 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=
-->
<head>
<title>Test for Bug </title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/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}/") {}' },
];
SimpleTest.waitForExplicitFinish();
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");
}
SimpleTest.finish();
</script>
</pre>
</body>
</html>

View file

@ -161,7 +161,6 @@ skip-if = true # Bug 701060
[test_bug470769.html] [test_bug470769.html]
[test_bug499655.html] [test_bug499655.html]
[test_bug499655.xhtml] [test_bug499655.xhtml]
[test_bug511909.html]
[test_bug517224.html] [test_bug517224.html]
support-files = bug517224.sjs support-files = bug517224.sjs
[test_bug524175.html] [test_bug524175.html]
@ -364,7 +363,6 @@ support-files = redundant_font_download.sjs
[test_revert.html] [test_revert.html]
[test_root_node_display.html] [test_root_node_display.html]
[test_rule_insertion.html] [test_rule_insertion.html]
[test_rule_serialization.html]
[test_rules_out_of_sheets.html] [test_rules_out_of_sheets.html]
[test_selectors.html] [test_selectors.html]
[test_setPropertyWithNull.html] [test_setPropertyWithNull.html]

View file

@ -8,23 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907
<script src="/tests/SimpleTest/SimpleTest.js"></script> <script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style id="style"> <style id="style">
@-moz-document media-document(video) {}
@-moz-document media-document(image) {}
@-moz-document media-document(plugin) {}
@-moz-document media-document(all) {}
@-moz-document plain-text-document() {}
@-moz-document unobservable-document() {}
@-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 all {}
@media only color {} @media only color {}
@media (color ) {} @media (color ) {}
@ -58,21 +41,6 @@ function runTest()
var sheet = style.sheet; var sheet = style.sheet;
var conditions = [ var conditions = [
"media-document(video)",
"media-document(image)",
"media-document(plugin)",
"media-document(all)",
"plain-text-document()",
"unobservable-document()",
"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", "all",
"only color", "only color",
"(color)", "(color)",
@ -99,9 +67,7 @@ function runTest()
} }
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv( runTest();
{ "set": [["layout.css.moz-document.content.enabled", true]]},
runTest);
</script> </script>
</pre> </pre>
</body> </body>

View file

@ -182,16 +182,6 @@ const tests = [
name: "@namespace 2e", name: "@namespace 2e",
ref: "@namespace 'http://foo.example.com/';", ref: "@namespace 'http://foo.example.com/';",
tst: "@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 {"
} }
]; ];
@ -215,67 +205,62 @@ const basestyle = ("table {\n"+
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
window.onload = function() { window.onload = function() {
SpecialPowers.pushPrefEnv( const frame = document.getElementById("display");
{ "set": [["layout.css.moz-document.content.enabled", true]]}, var curTest = 0;
function() {
const frame = document.getElementById("display");
var curTest = 0;
const prepareTest = function() { const prepareTest = function() {
var cd = frame.contentDocument; var cd = frame.contentDocument;
cd.open(); cd.open();
cd.write('<!DOCTYPE HTML><html><head>' + cd.write('<!DOCTYPE HTML><html><head>' +
'<style>\n' + basestyle + '</style>\n' + '<style>\n' + basestyle + '</style>\n' +
'<style>\n' + tests[curTest].ref + '</style>\n' + '<style>\n' + tests[curTest].ref + '</style>\n' +
'<style>\n' + tests[curTest].tst + '</style>\n' + '<style>\n' + tests[curTest].tst + '</style>\n' +
'</head><body>\n' + '</head><body>\n' +
'<table><tr><td id="r"><td id="t"></table>' + '<table><tr><td id="r"><td id="t"></table>' +
'</body></html>'); '</body></html>');
cd.close(); cd.close();
}; };
const checkTest = function() { const checkTest = function() {
var cd = frame.contentDocument; var cd = frame.contentDocument;
var _is = tests[curTest].todo ? todo_is : is; var _is = tests[curTest].todo ? todo_is : is;
var _ok = tests[curTest].todo ? todo : ok; var _ok = tests[curTest].todo ? todo : ok;
if (cd.styleSheets[1].cssRules.length == 1 && if (cd.styleSheets[1].cssRules.length == 1 &&
cd.styleSheets[2].cssRules.length == 1) { cd.styleSheets[2].cssRules.length == 1) {
// If we have a .prop for this test, the .cssText of the reference // If we have a .prop for this test, the .cssText of the reference
// and test rules will differ in the selector. Change #t to #r // and test rules will differ in the selector. Change #t to #r
// in the test rule. // in the test rule.
var ref_canon = cd.styleSheets[1].cssRules[0].cssText; var ref_canon = cd.styleSheets[1].cssRules[0].cssText;
var tst_canon = cd.styleSheets[2].cssRules[0].cssText; var tst_canon = cd.styleSheets[2].cssRules[0].cssText;
tst_canon = tst_canon.replace(/(#|%23)t\b/, "$1r"); tst_canon = tst_canon.replace(/(#|%23)t\b/, "$1r");
_is(tst_canon, ref_canon, _is(tst_canon, ref_canon,
tests[curTest].name + " (canonicalized rule)"); tests[curTest].name + " (canonicalized rule)");
} else { } else {
_ok(false, tests[curTest].name + " (rule missing)"); _ok(false, tests[curTest].name + " (rule missing)");
}
if (tests[curTest].prop) {
var prop = tests[curTest].prop;
var pseudo = tests[curTest].pseudo;
var refElt = cd.getElementById("r");
var tstElt = cd.getElementById("t");
var refStyle = cd.defaultView.getComputedStyle(refElt, pseudo);
var tstStyle = cd.defaultView.getComputedStyle(tstElt, pseudo);
_is(tstStyle.getPropertyValue(prop),
refStyle.getPropertyValue(prop),
tests[curTest].name + " (computed style)");
}
curTest++;
if (curTest < tests.length) {
prepareTest();
} else {
SimpleTest.finish();
}
};
frame.onload = function(){setTimeout(checkTest, 0);};
prepareTest();
} }
) if (tests[curTest].prop) {
var prop = tests[curTest].prop;
var pseudo = tests[curTest].pseudo;
var refElt = cd.getElementById("r");
var tstElt = cd.getElementById("t");
var refStyle = cd.defaultView.getComputedStyle(refElt, pseudo);
var tstStyle = cd.defaultView.getComputedStyle(tstElt, pseudo);
_is(tstStyle.getPropertyValue(prop),
refStyle.getPropertyValue(prop),
tests[curTest].name + " (computed style)");
}
curTest++;
if (curTest < tests.length) {
prepareTest();
} else {
SimpleTest.finish();
}
};
frame.onload = function(){setTimeout(checkTest, 0);};
prepareTest();
}; };
</script> </script>
</pre> </pre>

View file

@ -69,7 +69,6 @@ var cjkDecimalWidth = controlCJKDecimal.getBoundingClientRect().width;
// [at-rule type, passing condition, failing condition] // [at-rule type, passing condition, failing condition]
var outerRuleInfo = [ var outerRuleInfo = [
["@media", "all", "not all"], ["@media", "all", "not all"],
["@-moz-document", "url-prefix('')", "url-prefix('zzz')"],
["@supports", "(color: green)", "(unknown: unknown)"] ["@supports", "(color: green)", "(unknown: unknown)"]
]; ];
@ -235,10 +234,7 @@ function runTest()
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv( runTest();
{ "set": [["layout.css.moz-document.content.enabled", true ]]},
runTest,
);
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=
-->
<head>
<title>Test for Bug </title>
<script 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}/") {}' },
];
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv(
{ "set": [["layout.css.moz-document.content.enabled", true ]]},
function() {
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");
}
SimpleTest.finish();
}
)
</script>
</pre>
</body>
</html>

View file

@ -8572,13 +8572,6 @@
mirror: always mirror: always
rust: true rust: true
# Pref to control whether @-moz-document rules are enabled in content pages.
- name: layout.css.moz-document.content.enabled
type: RelaxedAtomicBool
value: false
mirror: always
rust: true
# Is -moz-osx-font-smoothing enabled? (Only supported in OSX builds) # Is -moz-osx-font-smoothing enabled? (Only supported in OSX builds)
- name: layout.css.osx-font-smoothing.enabled - name: layout.css.osx-font-smoothing.enabled
type: bool type: bool

View file

@ -283,10 +283,6 @@ impl DocumentCondition {
return true; return true;
} }
if static_prefs::pref!("layout.css.moz-document.content.enabled") {
return true;
}
// Allow a single url-prefix() for compatibility. // Allow a single url-prefix() for compatibility.
// //
// See bug 1446470 and dependencies. // See bug 1446470 and dependencies.