summaryrefslogtreecommitdiff
path: root/layout/style/test
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-01-06 21:07:37 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-01-06 22:13:08 +0800
commitb5f8fa64790d0ef75bfd79e72c9cd4a4098277f5 (patch)
tree9c92133410d592e3e953faa3d602c5263b62f2f2 /layout/style/test
parentaf3a27e8388fbb8cca9b30f2e8cbc0eb8ad9a336 (diff)
downloaduxp-b5f8fa64790d0ef75bfd79e72c9cd4a4098277f5.tar.gz
Issue #2084 - Part 1: Remove CSSUnprefixingService.js and associated code
It's effectively dead code since it's been supplanted by built-in webkit-prefixed-CSS support (landed before fork point in Firefox 49). Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1259348
Diffstat (limited to 'layout/style/test')
-rw-r--r--layout/style/test/mochitest.ini4
-rw-r--r--layout/style/test/test_unprefixing_service.html93
-rw-r--r--layout/style/test/test_unprefixing_service_prefs.html132
-rw-r--r--layout/style/test/unprefixing_service_iframe.html394
-rw-r--r--layout/style/test/unprefixing_service_utils.js87
5 files changed, 0 insertions, 710 deletions
diff --git a/layout/style/test/mochitest.ini b/layout/style/test/mochitest.ini
index 8b36e3e1e8..2f0ab87a28 100644
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -273,10 +273,6 @@ support-files = ../../reftests/fonts/markA.woff ../../reftests/fonts/markB.woff
[test_units_frequency.html]
[test_units_length.html]
[test_units_time.html]
-[test_unprefixing_service.html]
-support-files = unprefixing_service_iframe.html unprefixing_service_utils.js
-[test_unprefixing_service_prefs.html]
-support-files = unprefixing_service_iframe.html unprefixing_service_utils.js
[test_value_cloning.html]
[test_value_computation.html]
[test_value_storage.html]
diff --git a/layout/style/test/test_unprefixing_service.html b/layout/style/test/test_unprefixing_service.html
deleted file mode 100644
index c489e2ac01..0000000000
--- a/layout/style/test/test_unprefixing_service.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1107378
--->
-<head>
- <meta charset="utf-8">
- <title>Test for Bug 1107378</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript;version=1.7" src="unprefixing_service_utils.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=1107378">Mozilla Bug 1107378</a>
-<div id="display">
- <iframe id="testIframe"></iframe>
-</div>
-<pre id="test">
-<script type="application/javascript;version=1.7">
-"use strict";
-SimpleTest.waitForExplicitFinish();
-
-/**
- * This test checks that unprefixing is enabled for whitelisted domains, and
- * that it's disabled for non-whitelisted domains.
- *
- * We do this using an iframe, in which we load a test file at a test domain,
- * and we have the iframe report back to us (using postMessage) about
- * whether unprefixing is working.
- *
- * High-level overview of the process here:
- * - First, we tweak prefs to enable unprefixing & enable the test-only
- * entries in our unprefixing whitelist.
- * - The rest of this test is driven by the "startNextTest()" method.
- * This method pops a hostname to test and loads a URL from that host
- * in the iframe.
- * - We then listen for test-results from the iframe, using the postMessage
- * handler in unprefixing_service_utils.js.
- * - When the iframe indicates that it's done, we call "startNextTest()"
- * again to pop the next host & load *that* in the iframe.
- * - When nothing remains to be popped, we're done.
- */
-
-const IFRAME_TESTFILE = "unprefixing_service_iframe.html";
-
-// This function gets invoked when our iframe finishes a given round of testing.
-function startNextTest()
-{
- // Test the next whitelisted host, if any remain.
- if (gWhitelistedHosts.length > 0) {
- let host = gWhitelistedHosts.pop();
- info("Verifying that CSS Unprefixing Service is active, " +
- "at whitelisted test-host '" + host + "'");
- testHost(host, true);
- return;
- }
-
- // Test the next not-whitelisted host, if any remain.
- if (gNotWhitelistedHosts.length > 0) {
- let host = gNotWhitelistedHosts.pop();
- info("Verifying that CSS Unprefixing Service is inactive, " +
- "at non-whitelisted test-host '" + host + "'");
- testHost(host, false);
- return;
- }
-
- // Both arrays empty --> we're done.
- SimpleTest.finish();
-}
-
-function begin()
-{
- // Before we start loading things in iframes, set up postMessage handler.
- registerPostMessageListener(startNextTest);
-
- // Turn on prefs & start the first test!
- SpecialPowers.pushPrefEnv(
- { set: [[PREF_UNPREFIXING_SERVICE, true],
- [PREF_INCLUDE_TEST_DOMAINS, true],
- // Make sure *native* -webkit prefix support is turned off. It's
- // not whitelist-restricted, so if we left it enabled, it'd prevent
- // us from being able to detect CSSUnprefixingService's domain
- // whitelisting in this test.
- ["layout.css.prefixes.webkit", false]]},
- startNextTest);
-}
-
-begin();
-
-</script>
-</pre>
-</body>
-</html>
diff --git a/layout/style/test/test_unprefixing_service_prefs.html b/layout/style/test/test_unprefixing_service_prefs.html
deleted file mode 100644
index 329dce2a63..0000000000
--- a/layout/style/test/test_unprefixing_service_prefs.html
+++ /dev/null
@@ -1,132 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1132743
--->
-<head>
- <meta charset="utf-8">
- <title>Test for Bug 1132743</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript;version=1.7" src="unprefixing_service_utils.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=1132743">Mozilla Bug 1132743</a>
-<div id="display">
- <iframe id="testIframe"></iframe>
-</div>
-<pre id="test">
-<script type="application/javascript;version=1.7">
-"use strict";
-SimpleTest.waitForExplicitFinish();
-
-/**
- * This test checks that our CSS unprefixing prefs are effective.
- *
- * We do this using an iframe, in which we load a test file at a test domain
- * (whose whitelist-status depends on a pref), and we have the iframe report
- * back to us (using postMessage) about whether unprefixing is working.
- *
- * High-level overview of the process here (starting with begin()):
- * - First, we ensure that the pref...
- * "layout.css.unprefixing-service.include-test-domains"
- * ...is *unset* by default. (No point exposing it in about:config).
- * - Then, we test that (as a result of this pref being unset) the
- * unprefixing service is *inactive* at our test-domain, by default.
- * - Then, via a series of calls to "startNextTest()"/"testHost()", we re-test
- * the same test-domain with a variety of pref configurations, to ensure
- * that unprefixing only happens there when we've preffed on the service
- * *and* we've enabled the testing entries in the whiteslist.
- */
-
-const IFRAME_TESTFILE = "unprefixing_service_iframe.html";
-
-// Just test the first host in our known-whitelisted-hosts list.
-const WHITELISTED_TEST_HOST = gWhitelistedHosts[0];
-
-// Configurations of our prefs to test.
-// Each is a 3-entry array, whose entries mean:
-// (1) should we enable the CSS Unprefixing Service pref?
-// (2) should we enable the "include test domains in whitelist" pref?
-// (3) in this pref-configuration, should we expect to see unprefixing active
-// on our whitelisted test-domain?
-//
-// As you can see, the only configuration which should produce unprefixing
-// activity is when *both* prefs are enabled.
-let gTestConfigs = [
- [false, false, false],
- [false, true, false],
- [true, false, false],
- [true, true, true],
-];
-
-// Test that a particular configuration of prefs will activate or inactivate
-// the CSS unprefixing service, for styles loaded from WHITELISTED_TEST_HOST.
-// aTestConfig is described above, in documentation for gTestConfigs.
-function testConfig(aTestConfig)
-{
- if (aTestConfig.length != 3) {
- ok(false, "bug in test; need 3 entries. see gTestConfigs documentation");
- }
-
- info("Verifying that CSS Unprefixing Service is " +
- (aTestConfig[2] ? "active" : "inactive") +
- " at test host, with prefs: " +
- PREF_UNPREFIXING_SERVICE + "=" + aTestConfig[0] + ", " +
- PREF_INCLUDE_TEST_DOMAINS + "=" + aTestConfig[1]);
-
- SpecialPowers.pushPrefEnv(
- { set:
- [[PREF_UNPREFIXING_SERVICE, aTestConfig[0]],
- [PREF_INCLUDE_TEST_DOMAINS, aTestConfig[1]]]
- },
- function() {
- testHost(WHITELISTED_TEST_HOST, aTestConfig[2]);
- });
-}
-
-// This function gets invoked when our iframe finishes a given round of testing.
-function startNextTest()
-{
- if (gTestConfigs.length > 0) {
- // Grab the next test-config, and kick off a test for it.
- testConfig(gTestConfigs.pop());
- return;
- }
-
- // Array empty --> we're done.
- SimpleTest.finish();
-}
-
-function begin()
-{
- // First, check that PREF_INCLUDE_TEST_DOMAINS is unset:
- try {
- let val = SpecialPowers.getBoolPref(PREF_INCLUDE_TEST_DOMAINS);
- ok(false, "The test pref '" + PREF_INCLUDE_TEST_DOMAINS +
- "' should be unspecified by default");
- } catch(e) { /* Good, we threw; pref is unset. */ }
-
- // Before we start loading things in iframes, set up postMessage handler.
- registerPostMessageListener(startNextTest);
-
- // To kick things off, we don't set any prefs; we just test the default state
- // (which should have the "include test domains" pref implicitly disabled, &
- // hence unprefixing should end up being disabled in our iframe). Subsequent
- // tests are kicked off via postMessage-triggered calls to startNextTest(),
- // which will tweak prefs and re-test.
- info("Verifying that CSS Unprefixing Service is inactive at test host, " +
- "with default pref configuration");
- testHost(WHITELISTED_TEST_HOST, false);
-}
-
-// Before we start, make sure *native* -webkit prefix support is turned off.
-// It's not whitelist-restricted (and behaves slightly differently), so if we
-// left it enabled, it'd prevent us from being able to detect
-// CSSUnprefixingService's domain whitelisting in this test.
-SpecialPowers.pushPrefEnv({ set: [["layout.css.prefixes.webkit", false]]},
- begin);
-</script>
-</pre>
-</body>
-</html>
diff --git a/layout/style/test/unprefixing_service_iframe.html b/layout/style/test/unprefixing_service_iframe.html
deleted file mode 100644
index 8edeb20dce..0000000000
--- a/layout/style/test/unprefixing_service_iframe.html
+++ /dev/null
@@ -1,394 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Helper file for testing CSS Unprefixing Service</title>
- <script type="text/javascript" src="property_database.js"></script>
- <style type="text/css">
- #wrapper {
- width: 500px;
- }
- </style>
-</head>
-<body>
-<div id="wrapper">
- <div id="content"></div>
-</div>
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-/** Helper file for testing the CSS Unprefixing Service **/
-
-/* Testcases for CSS Unprefixing service.
- *
- * Each testcase MUST have the following fields:
- * - decl: A CSS declaration with prefixed style, to be tested via elem.style.
- * - targetPropName: The name of the property whose value should be
- * affected by |decl|.
- *
- * And will have EITHER:
- * - isInvalid: If set to something truthy, this implies that |decl| is
- * invalid and should have no effect on |targetPropName|'s
- * computed or specified style.
- *
- * ...OR:
- * - expectedDOMStyleVal: The value that we expect to find in the specified
- * style -- in elem.style.[targetPropName].
- * - expectedCompStyleVal: The value that we expect to find in the computed
- * style -- in getComputedStyle(...)[targetPropName]
- * If omitted, this is assumed to be the same as
- * expectedDOMStyleVal. (Usually they'll be the same.)
- */
-const gTestcases = [
- { decl: "-webkit-box-flex:5",
- targetPropName: "flex-grow",
- expectedDOMStyleVal: "5" },
-
- /* If author happens to specify modern flexbox style after prefixed style,
- make sure the modern stuff is preserved. */
- { decl: "-webkit-box-flex:4;flex-grow:6",
- targetPropName: "flex-grow",
- expectedDOMStyleVal: "6" },
-
- /* Tests for handling !important: */
- { decl: "-webkit-box-flex:3!important;",
- targetPropName: "flex-grow",
- expectedDOMStyleVal: "3" },
- { decl: "-webkit-box-flex:2!important;flex-grow:1",
- targetPropName: "flex-grow",
- expectedDOMStyleVal: "2" },
-
- { decl: "-webkit-box-flex:1!important bogusText;",
- targetPropName: "flex-grow",
- isInvalid: true },
-
- // Make sure we handle weird capitalization in property & value, too:
- { decl: "-WEBKIT-BoX-aLign: baSELine",
- targetPropName: "align-items",
- expectedDOMStyleVal: "baseline" },
-
- { decl: "display:-webkit-box",
- targetPropName: "display",
- expectedDOMStyleVal: "flex" },
-
- { decl: "display:-webkit-box; display:-moz-box;",
- targetPropName: "display",
- expectedDOMStyleVal: "flex" },
-
- { decl: "display:-webkit-foobar; display:-moz-box;",
- targetPropName: "display",
- expectedDOMStyleVal: "-moz-box" },
-
- // -webkit-box-align: baseline | center | end | start | stretch
- // ...maps to:
- // align-items: baseline | center | flex-end | flex-start | stretch
- { decl: "-webkit-box-align: baseline",
- targetPropName: "align-items",
- expectedDOMStyleVal: "baseline" },
- { decl: "-webkit-box-align: center",
- targetPropName: "align-items",
- expectedDOMStyleVal: "center" },
- { decl: "-webkit-box-align: end",
- targetPropName: "align-items",
- expectedDOMStyleVal: "flex-end" },
- { decl: "-webkit-box-align: start",
- targetPropName: "align-items",
- expectedDOMStyleVal: "flex-start" },
- { decl: "-webkit-box-align: stretch",
- targetPropName: "align-items",
- expectedDOMStyleVal: "stretch" },
-
- // -webkit-box-direction is not supported, because it's unused & would be
- // complicated to support. See note in CSSUnprefixingService.js for more.
-
- // -webkit-box-ordinal-group: <number> maps directly to "order".
- { decl: "-webkit-box-ordinal-group: 2",
- targetPropName: "order",
- expectedDOMStyleVal: "2" },
- { decl: "-webkit-box-ordinal-group: 6000",
- targetPropName: "order",
- expectedDOMStyleVal: "6000" },
-
- // -webkit-box-orient: horizontal | inline-axis | vertical | block-axis
- // ...maps to:
- // flex-direction: row | row | column | column
- { decl: "-webkit-box-orient: horizontal",
- targetPropName: "flex-direction",
- expectedDOMStyleVal: "row" },
- { decl: "-webkit-box-orient: inline-axis",
- targetPropName: "flex-direction",
- expectedDOMStyleVal: "row" },
- { decl: "-webkit-box-orient: vertical",
- targetPropName: "flex-direction",
- expectedDOMStyleVal: "column" },
- { decl: "-webkit-box-orient: block-axis",
- targetPropName: "flex-direction",
- expectedDOMStyleVal: "column" },
-
- // -webkit-box-pack: start | center | end | justify
- // ... maps to:
- // justify-content: flex-start | center | flex-end | space-between
- { decl: "-webkit-box-pack: start",
- targetPropName: "justify-content",
- expectedDOMStyleVal: "flex-start" },
- { decl: "-webkit-box-pack: center",
- targetPropName: "justify-content",
- expectedDOMStyleVal: "center" },
- { decl: "-webkit-box-pack: end",
- targetPropName: "justify-content",
- expectedDOMStyleVal: "flex-end" },
- { decl: "-webkit-box-pack: justify",
- targetPropName: "justify-content",
- expectedDOMStyleVal: "space-between" },
-
- // -webkit-transform: <transform> maps directly to "transform"
- { decl: "-webkit-transform: matrix(1, 2, 3, 4, 5, 6)",
- targetPropName: "transform",
- expectedDOMStyleVal: "matrix(1, 2, 3, 4, 5, 6)" },
-
- // -webkit-transform-origin: <value> maps directly to "transform-origin"
- { decl: "-webkit-transform-origin: 0 0",
- targetPropName: "transform-origin",
- expectedDOMStyleVal: "0px 0px 0px",
- expectedCompStyleVal: "0px 0px" },
-
- { decl: "-webkit-transform-origin: 100% 0",
- targetPropName: "transform-origin",
- expectedDOMStyleVal: "100% 0px 0px",
- expectedCompStyleVal: "500px 0px" },
-
- // -webkit-transition: <property> maps directly to "transition"
- { decl: "-webkit-transition: width 1s linear 2s",
- targetPropName: "transition",
- expectedDOMStyleVal: "width 1s linear 2s" },
-
- // -webkit-transition **with** -webkit-prefixed property in value.
- { decl: "-webkit-transition: -webkit-transform 1s linear 2s",
- targetPropName: "transition",
- expectedDOMStyleVal: "transform 1s linear 2s" },
- // (Re-test to check that it sets the "transition-property" subproperty.)
- { decl: "-webkit-transition: -webkit-transform 1s linear 2s",
- targetPropName: "transition-property",
- expectedDOMStyleVal: "transform" },
-
- // Same as previous test, except with "-webkit-transform" in the
- // middle of the value instead of at the beginning (still valid):
- { decl: "-webkit-transition: 1s -webkit-transform linear 2s",
- targetPropName: "transition",
- expectedDOMStyleVal: "transform 1s linear 2s" },
- { decl: "-webkit-transition: 1s -webkit-transform linear 2s",
- targetPropName: "transition-property",
- expectedDOMStyleVal: "transform" },
-
- // -webkit-gradient(linear, ...) expressions:
- { decl: "background-image: -webkit-gradient(linear,0 0,0 100%,from(rgb(1, 2, 3)),to(rgb(104, 105, 106)))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(180deg, rgb(1, 2, 3) 0%, rgb(104, 105, 106) 100%)"},
- { decl: "background-image: -webkit-gradient(linear, left top, right bottom, from(rgb(1, 2, 3)), to(rgb(201, 202, 203)))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(135deg, rgb(1, 2, 3) 0%, rgb(201, 202, 203) 100%)"},
-
- { decl: "background-image: -webkit-gradient(linear, left center, right center, from(rgb(1, 2, 3)), to(rgb(201, 202, 203)))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(to right, rgb(1, 2, 3) 0%, rgb(201, 202, 203) 100%)"},
-
- { decl: "background-image: -webkit-gradient(linear, left center, right center, from(rgb(0, 0, 0)), color-stop(30%, rgb(255, 0, 0)), color-stop(60%, rgb(0, 255, 0)), to(rgb(0, 0, 255)))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(to right, rgb(0, 0, 0) 0%, rgb(255, 0, 0) 30%, rgb(0, 255, 0) 60%, rgb(0, 0, 255) 100%)"},
-
- // -webkit-gradient(radial, ...) expressions:
- { decl: "background-image: -webkit-gradient(radial, center center, 0, center center, 50, from(black), to(white)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "radial-gradient(50px at center center , black 0%, white 100%)",
- // XXXdholbert Note: unnecessary space, see bug 1160063----^
- expectedCompStyleVal: "radial-gradient(50px, rgb(0, 0, 0) 0%, rgb(255, 255, 255) 100%)", },
-
- { decl: "background-image: -webkit-gradient(radial, left bottom, 0, center center, 50, from(yellow), color-stop(20%, orange), color-stop(40%, red), color-stop(60%, green), color-stop(80%, blue), to(purple))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "radial-gradient(50px at left bottom , yellow 0%, orange 20%, red 40%, green 60%, blue 80%, purple 100%)",
- // XXXdholbert Note: unnecessary space, see bug 1160063--^
- expectedCompStyleVal: "radial-gradient(50px at 0% 100%, rgb(255, 255, 0) 0%, rgb(255, 165, 0) 20%, rgb(255, 0, 0) 40%, rgb(0, 128, 0) 60%, rgb(0, 0, 255) 80%, rgb(128, 0, 128) 100%)" },
-
- // -webkit-linear-gradient(...) expressions:
- { decl: "background-image: -webkit-linear-gradient(top, blue, green)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(to bottom, blue, green)",
- expectedCompStyleVal: "linear-gradient(rgb(0, 0, 255), rgb(0, 128, 0))", },
-
- { decl: "background-image: -webkit-linear-gradient(left, blue, green)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(to right, blue, green)",
- expectedCompStyleVal: "linear-gradient(to right, rgb(0, 0, 255), rgb(0, 128, 0))", },
-
- { decl: "background-image: -webkit-linear-gradient(left bottom, blue, green)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(to right top, blue, green)",
- expectedCompStyleVal: "linear-gradient(to top right, rgb(0, 0, 255), rgb(0, 128, 0))", },
-
- { decl: "background-image: -webkit-linear-gradient(130deg, blue, green)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(320deg, blue, green)",
- expectedCompStyleVal: "linear-gradient(320deg, rgb(0, 0, 255), rgb(0, 128, 0))", },
-
- // -webkit-radial-gradient(...) expressions:
- { decl: "background-image: -webkit-radial-gradient(#000, #fff)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "radial-gradient(rgb(0, 0, 0), rgb(255, 255, 255))", },
-
- { decl: "background-image: -webkit-radial-gradient(bottom right, white, black)",
- targetPropName: "background-image",
- expectedDOMStyleVal: "radial-gradient(at right bottom , white, black)",
- // XXXdholbert Note: unnecessary space---------------^ see bug 1160063
- expectedCompStyleVal: "radial-gradient(at 100% 100%, rgb(255, 255, 255), rgb(0, 0, 0))", },
-
- // Combination of unprefixed & prefixed gradient styles in a single 'background-image' expression
- { decl: "background-image: -webkit-linear-gradient(black, white), radial-gradient(blue, purple), -webkit-gradient(linear,0 0,0 100%,from(red),to(orange))",
- targetPropName: "background-image",
- expectedDOMStyleVal: "linear-gradient(black, white), radial-gradient(blue, purple), linear-gradient(180deg, red 0%, orange 100%)",
- expectedCompStyleVal: "linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)), radial-gradient(rgb(0, 0, 255), rgb(128, 0, 128)), linear-gradient(180deg, rgb(255, 0, 0) 0%, rgb(255, 165, 0) 100%)", },
-
-];
-
-function getComputedStyleWrapper(elem, prop)
-{
- return window.getComputedStyle(elem, null).getPropertyValue(prop);
-}
-
-// Shims for "is()" and "ok()", which defer to parent window using postMessage:
-function is(aActual, aExpected, aDesc)
-{
- // Add URL to description:
- aDesc += " (iframe url: '" + window.location + "')";
-
- window.parent.postMessage({type: "is",
- actual: aActual,
- expected: aExpected,
- desc: aDesc}, "*");
-}
-
-function ok(aCondition, aDesc)
-{
- // Add URL to description:
- aDesc += " (iframe url: '" + window.location + "')";
-
- window.parent.postMessage({type: "ok",
- condition: aCondition,
- desc: aDesc}, "*");
-}
-
-// Main test function to use, to test a given unprefixed CSS property.
-// The argument aTestcase should be an entry from gTestcases above.
-function runOneTest(aTestcase)
-{
- let elem = document.getElementById("content");
-
- // (self-test/sanity-check:)
- if (!aTestcase.decl || !aTestcase.targetPropName) {
- ok(false, "Bug in test; missing 'decl' or 'targetPropName' field");
- }
-
- // Populate testcase's implied fields:
- if (aTestcase.isInvalid) {
- // (self-test/sanity-check:)
- if (aTestcase.expectedDOMStyleVal || aTestcase.expectedCompStyleVal) {
- ok(false, "Bug in test; testcase w/ 'isInvalid' field also provided " +
- "an expected*Val field, but should not have");
- }
- aTestcase.expectedDOMStyleVal = '';
- aTestcase.expectedCompStyleVal = // initial computed style:
- getComputedStyleWrapper(elem, aTestcase.targetPropName);
- } else {
- // (self-test/sanity-check:)
- if (!aTestcase.expectedDOMStyleVal) {
- ok(false, "Bug in test; testcase must provide expectedDOMStyleVal " +
- "(or set isInvalid if it's testing an invalid decl)");
- }
- // If expected computed style is unspecified, we assume it should match
- // expected DOM style:
- if (!aTestcase.expectedCompStyleVal) {
- aTestcase.expectedCompStyleVal = aTestcase.expectedDOMStyleVal;
- }
- }
-
- elem.setAttribute("style", aTestcase.decl);
-
- // Check that DOM elem.style has the expected value:
- is(elem.style[aTestcase.targetPropName], aTestcase.expectedDOMStyleVal,
- "Checking if CSS Unprefixing Service produced expected result " +
- "in elem.style['" + aTestcase.targetPropName + "'] " +
- "when given decl '" + aTestcase.decl + "'");
-
- // Check that computed style has the expected value:
- // (only for longhand properties; shorthands aren't in computed style)
- if (gCSSProperties[aTestcase.targetPropName].type == CSS_TYPE_LONGHAND) {
- let computedValue = getComputedStyleWrapper(elem, aTestcase.targetPropName);
- is(computedValue, aTestcase.expectedCompStyleVal,
- "Checking if CSS Unprefixing Service produced expected result " +
- "in computed value of property '" + aTestcase.targetPropName + "' " +
- "when given decl '" + aTestcase.decl + "'");
- }
-
- elem.removeAttribute("style");
-}
-
-// Function used to quickly test that unprefixing is off:
-function testUnprefixingDisabled()
-{
- let elem = document.getElementById("content");
-
- let initialFlexGrow = getComputedStyleWrapper(elem, "flex-grow");
- elem.setAttribute("style", "-webkit-box-flex:5");
- is(getComputedStyleWrapper(elem, "flex-grow"), initialFlexGrow,
- "'-webkit-box-flex' shouldn't affect computed 'flex-grow' " +
- "when CSS Unprefixing Service is inactive");
-
- let initialDisplay = getComputedStyleWrapper(elem, "display");
- elem.setAttribute("style", "display:-webkit-box");
- is(getComputedStyleWrapper(elem, "display"), initialDisplay,
- "'display:-webkit-box' shouldn't affect computed 'display' " +
- "when CSS Unprefixing Service is inactive");
-
- elem.style.display = "-webkit-box";
- is(getComputedStyleWrapper(elem, "display"), initialDisplay,
- "Setting elem.style.display to '-webkit-box' shouldn't affect computed " +
- "'display' when CSS Unprefixing Service is inactive");
-}
-
-// Focused test that CSS Unprefixing Service is functioning properly
-// on direct tweaks to elem.style.display:
-function testStyleDisplayDirectly()
-{
- let elem = document.getElementById("content");
- elem.style.display = "-webkit-box";
-
- is(elem.style.display, "flex",
- "Setting elem.style.display to '-webkit-box' should produce 'flex' " +
- "in elem.style.display, when CSS Unprefixing Service is active");
- is(getComputedStyleWrapper(elem, "display"), "flex",
- "Setting elem.style.display to '-webkit-box' should produce 'flex' " +
- "in computed style, when CSS Unprefixing Service is active");
-
- // clean up:
- elem.style.display = "";
-}
-
-function startTest()
-{
- if (window.location.hash === "#expectEnabled") {
- testStyleDisplayDirectly();
- gTestcases.forEach(runOneTest);
- } else if (window.location.hash === "#expectDisabled") {
- testUnprefixingDisabled();
- } else {
- ok(false,
- "Need a recognized 'window.location.hash' to indicate expectation. " +
- "Got: '" + window.location.hash + "'");
- }
- window.parent.postMessage({type: "testComplete"}, "*");
-}
-
-startTest();
-</script>
-</body>
-</html>
diff --git a/layout/style/test/unprefixing_service_utils.js b/layout/style/test/unprefixing_service_utils.js
deleted file mode 100644
index cd17d20d08..0000000000
--- a/layout/style/test/unprefixing_service_utils.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Shared data & functionality used in tests for CSS Unprefixing Service.
-
-// Whitelisted hosts:
-// (per implementation of nsPrincipal::IsOnCSSUnprefixingWhitelist())
-var gWhitelistedHosts = [
- // test1.example.org is on the whitelist.
- "test1.example.org",
- // test2.example.org is on the "allow all subdomains" whitelist.
- "test2.example.org",
- "sub1.test2.example.org",
- "sub2.test2.example.org"
-];
-
-// *NOT* whitelisted hosts:
-var gNotWhitelistedHosts = [
- // Though test1.example.org is on the whitelist, its subdomains are not.
- "sub1.test1.example.org",
- // mochi.test is not on the whitelist.
- "mochi.test:8888"
-];
-
-// Names of prefs:
-const PREF_UNPREFIXING_SERVICE =
- "layout.css.unprefixing-service.enabled";
-const PREF_INCLUDE_TEST_DOMAINS =
- "layout.css.unprefixing-service.include-test-domains";
-
-// Helper-function to make unique URLs in testHost():
-var gCounter = 0;
-function getIncreasingCounter() {
- return gCounter++;
-}
-
-// This function tests a particular host in our iframe.
-// @param aHost The host to be tested
-// @param aExpectEnabled Should we expect unprefixing to be enabled for host?
-function testHost(aHost, aExpectEnabled) {
- // Build the URL:
- let url = window.location.protocol; // "http:" or "https:"
- url += "//";
- url += aHost;
-
- // Append the path-name, up to the actual filename (the final "/"):
- const re = /(.*\/).*/;
- url += window.location.pathname.replace(re, "$1");
- url += IFRAME_TESTFILE;
- // In case this is the same URL as last time, we add "?N" for some unique N,
- // to make each URL different, so that the iframe actually (re)loads:
- url += "?" + getIncreasingCounter();
- // We give the URL a #suffix to indicate to the test whether it should expect
- // that unprefixing is enabled or disabled:
- url += (aExpectEnabled ? "#expectEnabled" : "#expectDisabled");
-
- let iframe = document.getElementById("testIframe");
- iframe.contentWindow.location = url;
- // The iframe will report its results back via postMessage.
- // Our caller had better have set up a postMessage listener.
-}
-
-// Register a postMessage() handler, to allow our cross-origin iframe to
-// communicate back to the main page's mochitest functionality.
-// The handler expects postMessage to be called with an object like:
-// { type: ["is"|"ok"|"testComplete"], ... }
-// The "is" and "ok" types will trigger the corresponding function to be
-// called in the main page, with named arguments provided in the payload.
-// The "testComplete" type will trigger the passed-in aTestCompleteCallback
-// function to be invoked (e.g. to advance to the next testcase, or to finish
-// the overall test, as-appropriate).
-function registerPostMessageListener(aTestCompleteCallback) {
- let receiveMessage = function(event) {
- if (event.data.type === "is") {
- is(event.data.actual, event.data.expected, event.data.desc);
- } else if (event.data.type === "ok") {
- ok(event.data.condition, event.data.desc);
- } else if (event.data.type === "testComplete") {
- aTestCompleteCallback();
- } else {
- ok(false, "unrecognized data in postMessage call");
- }
- };
-
- window.addEventListener("message", receiveMessage, false);
-}