Bug 1159792 - get rid of dom.workers.websocket.enabled pref, r=smaug

This commit is contained in:
Andrea Marchesini 2015-05-14 12:24:06 +01:00
parent 45f3d053c5
commit bcd095019c
9 changed files with 6 additions and 150 deletions

View File

@ -1792,53 +1792,6 @@ WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
}
namespace {
class PrefEnabledRunnable final : public WorkerMainThreadRunnable
{
public:
explicit PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate)
: WorkerMainThreadRunnable(aWorkerPrivate)
, mEnabled(false)
{ }
bool MainThreadRun() override
{
AssertIsOnMainThread();
mEnabled = Preferences::GetBool("dom.workers.websocket.enabled", false);
return true;
}
bool IsEnabled() const
{
return mEnabled;
}
private:
bool mEnabled;
};
} // anonymous namespace
bool
WebSocket::PrefEnabled(JSContext* /* aCx */, JSObject* /* aGlobal */)
{
// WebSockets are always enabled on main-thread.
if (NS_IsMainThread()) {
return true;
}
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
workerPrivate->AssertIsOnWorkerThread();
nsRefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate);
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
}
nsresult
WebSocketImpl::ParseURL(const nsAString& aURL)
{

View File

@ -12,8 +12,7 @@
enum BinaryType { "blob", "arraybuffer" };
[Func="mozilla::dom::WebSocket::PrefEnabled",
Exposed=(Window,Worker),
[Exposed=(Window,Worker),
Constructor(DOMString url),
Constructor(DOMString url, DOMString protocols),
Constructor(DOMString url, sequence<DOMString> protocols)]

View File

@ -199,7 +199,6 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
[test_bug978260.html]
[test_webSocket_sharedWorker.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
[test_websocket_pref.html]
[test_bug1104064.html]
[test_consoleAndBlobs.html]
[test_bug1132395.html]

View File

@ -13,8 +13,8 @@
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({ set: [["dom.workers.sharedWorkers.enabled", true],
["dom.workers.websocket.enabled", true]]}, function() {
SpecialPowers.pushPrefEnv({ set: [["dom.workers.sharedWorkers.enabled", true]]},
function() {
var sw = new SharedWorker('webSocket_sharedWorker.js');
sw.port.onmessage = function(event) {
if (event.data.type == 'finish') {

View File

@ -14,8 +14,6 @@
<pre id="feedback"></pre>
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", true]]},
function() {
var worker = new Worker("websocket_worker.js");
worker.onmessage = function(event) {
@ -40,9 +38,7 @@ function() {
};
worker.postMessage('foobar');
});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
</script>
</pre>

View File

@ -15,8 +15,6 @@
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", true]]},
function() {
var worker = new Worker("websocket_basic_worker.js");
worker.onmessage = function(event) {
@ -51,9 +49,7 @@ function() {
}
runTest();
});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
</script>
</pre>

View File

@ -15,8 +15,6 @@
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", true]]},
function() {
var worker = new Worker("websocket_loadgroup_worker.js");
var stopped = false;
@ -55,9 +53,7 @@ function() {
}
runTest();
});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
</script>
</pre>

View File

@ -1,77 +0,0 @@
<!--
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">
SpecialPowers.pushPrefEnv({"set": [["dom.workers.websocket.enabled", true]]},
function() {
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();
}
runTest();
});
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

View File

@ -132,12 +132,6 @@ pref("dom.workers.maxPerDomain", 20);
// Whether or not Shared Web Workers are enabled.
pref("dom.workers.sharedWorkers.enabled", true);
// Whether or not WebSockets in workers are enabled.
// Note: we need this pref because WebSocket in Workers is a new implementation
// and we want to be able to disable it quickly in case of regressions.
// When this feature is stable enough we can get rid of this pref: Bug 1159792
pref("dom.workers.websocket.enabled", true);
// Service workers
pref("dom.serviceWorkers.enabled", false);