1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<!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>
|