mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
74 lines
1.7 KiB
HTML
74 lines
1.7 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for WebSocket object in workers</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<script id="js_script" type="text/js-worker">
|
|
onmessage = function() {
|
|
postMessage("WebSocket" in this ? "OK" : "KO");
|
|
}
|
|
</script>
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
var blob = new Blob([document.getElementById("js_script").textContent],
|
|
{type: "text/javascript"});
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var tests = [
|
|
function() {
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", true]]},
|
|
function() {
|
|
ok("WebSocket" in window, "WebSocket are always enabled on main-thread");
|
|
|
|
var w = new Worker(url);
|
|
w.onmessage = function(e) {
|
|
is(e.data, "OK", "WebSocket enabled in workers!");
|
|
runTest();
|
|
}
|
|
w.postMessage('go');
|
|
});
|
|
},
|
|
|
|
function() {
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", false]]},
|
|
function() {
|
|
ok("WebSocket" in window, "WebSocket are always enabled on main-thread");
|
|
|
|
var w = new Worker(url);
|
|
w.onmessage = function(e) {
|
|
is(e.data, "KO", "WebSocket disabled in workers!");
|
|
runTest();
|
|
}
|
|
w.postMessage('go');
|
|
});
|
|
}
|
|
];
|
|
|
|
function runTest() {
|
|
if (!tests.length) {
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
var t = tests.shift();
|
|
t();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runTest();
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|