зеркало из https://github.com/mozilla/gecko-dev.git
73 строки
1.7 KiB
HTML
73 строки
1.7 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Test for BroadcastChannel</title>
|
||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<div id="content"></div>
|
||
|
|
||
|
<script type="application/javascript">
|
||
|
|
||
|
function testNoPref() {
|
||
|
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", false]]}, function() {
|
||
|
ok(!("BroadcastChannel" in window), "BroadcastChannel should not exist");
|
||
|
runTests();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function testPref() {
|
||
|
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, function() {
|
||
|
ok("BroadcastChannel" in window, "BroadcastChannel should exist");
|
||
|
runTests();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function testNoPrefWorker() {
|
||
|
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", false]]}, function() {
|
||
|
var worker = new Worker("broadcastchannel_pref_worker.js");
|
||
|
worker.onmessage = function(event) {
|
||
|
ok(!event.data.exists, "BroadcastChannel should not exist in workers");
|
||
|
runTests();
|
||
|
}
|
||
|
worker.postMessage('go!');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function testPrefWorker() {
|
||
|
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, function() {
|
||
|
var worker = new Worker("broadcastchannel_pref_worker.js");
|
||
|
worker.onmessage = function(event) {
|
||
|
ok(event.data.exists, "BroadcastChannel should exist in workers");
|
||
|
runTests();
|
||
|
}
|
||
|
worker.postMessage('go!');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
var tests = [
|
||
|
testNoPref,
|
||
|
testPref,
|
||
|
testNoPrefWorker,
|
||
|
testPrefWorker
|
||
|
];
|
||
|
|
||
|
function runTests() {
|
||
|
if (tests.length == 0) {
|
||
|
SimpleTest.finish();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var test = tests.shift();
|
||
|
test();
|
||
|
}
|
||
|
|
||
|
SimpleTest.waitForExplicitFinish();
|
||
|
runTests();
|
||
|
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|