Bug 1430014 - Part 4: Skip failing/unnecessary tests when the old style system is not present. r?xidorn
MozReview-Commit-ID: 9xuJXkI4W7E
--- a/layout/style/test/browser_newtab_share_rule_processors.js
+++ b/layout/style/test/browser_newtab_share_rule_processors.js
@@ -15,24 +15,29 @@ function test() {
theBrowser.addEventListener("load", listener, true);
}
function doTest() {
theBrowser.removeEventListener("load", listener, true);
var winUtils = theBrowser.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
- // The initial set of agent-level sheets should have a rule processor that's
- // also being used by another document.
- ok(winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AGENT_SHEET),
- "agent sheet rule processor is used by multiple style sets");
- // Document-level sheets currently never get shared rule processors.
- ok(!winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AUTHOR_SHEET),
- "author sheet rule processor is not used by multiple style sets");
- // Adding a unique style sheet to the agent level will cause it to have a
- // rule processor that is unique.
- theBrowser.contentWindow.wrappedJSObject.addAgentSheet();
- ok(!winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AGENT_SHEET),
- "agent sheet rule processor is not used by multiple style sets after " +
- "having a unique sheet added to it");
+ if (winUtils.isStyledByServo) {
+ todo(false, "should update this test to check that Servo is also " +
+ "correctly sharing CascadeData");
+ } else {
+ // The initial set of agent-level sheets should have a rule processor that's
+ // also being used by another document.
+ ok(winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AGENT_SHEET),
+ "agent sheet rule processor is used by multiple style sets");
+ // Document-level sheets currently never get shared rule processors.
+ ok(!winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AUTHOR_SHEET),
+ "author sheet rule processor is not used by multiple style sets");
+ // Adding a unique style sheet to the agent level will cause it to have a
+ // rule processor that is unique.
+ theBrowser.contentWindow.wrappedJSObject.addAgentSheet();
+ ok(!winUtils.hasRuleProcessorUsedByMultipleStyleSets(Ci.nsIStyleSheetService.AGENT_SHEET),
+ "agent sheet rule processor is not used by multiple style sets after " +
+ "having a unique sheet added to it");
+ }
gBrowser.removeTab(theTab);
finish();
}
--- a/layout/style/test/gtest/StyloParsingBench.cpp
+++ b/layout/style/test/gtest/StyloParsingBench.cpp
@@ -45,16 +45,18 @@ static void ServoParsingBench() {
}
}
MOZ_GTEST_BENCH(Stylo, Servo_StyleSheet_FromUTF8Bytes_Bench, ServoParsingBench);
#endif
+#ifdef MOZ_OLD_STYLE
+
static void GeckoParsingBench() {
// Don’t use NS_LITERAL_STRING to work around
// "fatal error C1091: compiler limit: string exceeds 65535 bytes in length"
// https://msdn.microsoft.com/en-us/library/f27ch0t1.aspx
NS_ConvertUTF8toUTF16 css(NS_LITERAL_CSTRING(EXAMPLE_STYLESHEET));
RefPtr<nsIURI> uri = NullPrincipalURI::Create();
for (int i = 0; i < PARSING_REPETITIONS; i++) {
@@ -63,16 +65,18 @@ static void GeckoParsingBench() {
stylesheet->SetURIs(uri, uri, uri);
stylesheet->SetComplete();
ASSERT_EQ(stylesheet->ReparseSheet(css), NS_OK);
}
}
MOZ_GTEST_BENCH(Stylo, Gecko_nsCSSParser_ParseSheet_Bench, GeckoParsingBench);
+#endif
+
#ifdef MOZ_STYLO
static void ServoSetPropertyByIdBench(const nsACString& css) {
RefPtr<RawServoDeclarationBlock> block = Servo_DeclarationBlock_CreateEmpty().Consume();
RefPtr<URLExtraData> data = new URLExtraData(
NullPrincipalURI::Create(), nullptr, NullPrincipal::Create());
--- a/layout/style/test/test_stylo_blocklist-01.html
+++ b/layout/style/test/test_stylo_blocklist-01.html
@@ -2,23 +2,28 @@
<html>
<head>
<title>Test the mechanism of stylo blocklist</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.getDOMWindowUtils(window).addToStyloBlocklist("stylo-blocklist.com");
-let win =
- window.open("http://stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
- is(evt.data, "TEST-PASS",
- "Document with blocked domain should not use servo backend");
- win.close();
- SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
- SimpleTest.finish();
+let utils = SpecialPowers.getDOMWindowUtils(window);
+if (utils.isOldStyleSystemAvailable) {
+ SimpleTest.waitForExplicitFinish();
+ utils.addToStyloBlocklist("stylo-blocklist.com");
+ let win =
+ window.open("http://stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
+ window.onmessage = function (evt) {
+ is(evt.data, "TEST-PASS",
+ "Document with blocked domain should not use servo backend");
+ win.close();
+ SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
+ SimpleTest.finish();
+ }
+} else {
+ ok(true, "nothing to test");
}
</script>
</pre>
</body>
</html>
--- a/layout/style/test/test_stylo_blocklist-02.html
+++ b/layout/style/test/test_stylo_blocklist-02.html
@@ -2,23 +2,28 @@
<html>
<head>
<title>Test the mechanism of stylo blocklist</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.getDOMWindowUtils(window).addToStyloBlocklist("stylo-blocklist.com");
-let win =
- window.open("http://test.stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
- is(evt.data, "TEST-PASS",
- "Document with blocked sub-domain should not use servo backend");
- win.close();
- SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
- SimpleTest.finish();
+let utils = SpecialPowers.getDOMWindowUtils(window);
+if (utils.isOldStyleSystemAvailable) {
+ SimpleTest.waitForExplicitFinish();
+ utils.addToStyloBlocklist("stylo-blocklist.com");
+ let win =
+ window.open("http://test.stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
+ window.onmessage = function (evt) {
+ is(evt.data, "TEST-PASS",
+ "Document with blocked sub-domain should not use servo backend");
+ win.close();
+ SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
+ SimpleTest.finish();
+ }
+} else {
+ ok(true, "nothing to test");
}
</script>
</pre>
</body>
</html>
--- a/layout/style/test/test_stylo_blocklist-03.html
+++ b/layout/style/test/test_stylo_blocklist-03.html
@@ -2,24 +2,29 @@
<html>
<head>
<title>Test the mechanism of stylo blocklist</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
-SimpleTest.waitForExplicitFinish();
-// "http://example.com" should not be in the blocklist by any chance. Adding this
-// line is just for safety, and it also makes this test more readable.
-SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("example.com");
-let win =
- window.open("http://example.com/tests/layout/style/test/stylo_non_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
- is(evt.data, "TEST-PASS",
- "Document without blocked domain should use servo backend");
- win.close();
- SimpleTest.finish();
+let utils = SpecialPowers.getDOMWindowUtils(window);
+if (utils.isOldStyleSystemAvailable) {
+ SimpleTest.waitForExplicitFinish();
+ // "http://example.com" should not be in the blocklist by any chance. Adding this
+ // line is just for safety, and it also makes this test more readable.
+ utils.removeFromStyloBlocklist("example.com");
+ let win =
+ window.open("http://example.com/tests/layout/style/test/stylo_non_blocked_domain_page.html", "");
+ window.onmessage = function (evt) {
+ is(evt.data, "TEST-PASS",
+ "Document without blocked domain should use servo backend");
+ win.close();
+ SimpleTest.finish();
+ }
+} else {
+ ok(true, "nothing to test");
}
</script>
</pre>
</body>
</html>