Mypal/layout/style/test/test_unprefixing_service.html
2019-03-11 13:26:37 +03:00

94 lines
3.1 KiB
HTML

<!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>