Bug 1434934 - Remove dom.workers.enabled pref, r=bkelly
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 01 Feb 2018 18:34:08 +0100
changeset 402133 4191749c26091da969f8d5772fc46aa7fc83ad97
parent 402132 3c74a02c5b6f9aaae81c14dbdd2ba98e8cee3e45
child 402134 fdecefbc7f55a12449ecef08dee664a98550f2e0
push id33367
push userrgurzau@mozilla.com
push dateThu, 01 Feb 2018 21:54:13 +0000
treeherdermozilla-central@ee7f64d07649 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1434934
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434934 - Remove dom.workers.enabled pref, r=bkelly
dom/webidl/Worker.webidl
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/test/chrome.ini
dom/workers/test/mochitest.ini
dom/workers/test/test_workersDisabled.html
dom/workers/test/test_workersDisabled.xul
dom/workers/test/workersDisabled_worker.js
modules/libpref/init/all.js
--- a/dom/webidl/Worker.webidl
+++ b/dom/webidl/Worker.webidl
@@ -8,17 +8,16 @@
  *
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera
  * Software ASA.
  * You are granted a license to use, reproduce and create derivative works of
  * this document.
  */
 
 [Constructor(USVString scriptURL, optional WorkerOptions options),
- Func="mozilla::dom::WorkerPrivate::WorkerAvailable",
  Exposed=(Window,DedicatedWorker,SharedWorker,System)]
 interface Worker : EventTarget {
   void terminate();
 
   [Throws]
   void postMessage(any message, optional sequence<object> transfer = []);
 
   attribute EventHandler onmessage;
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -68,18 +68,16 @@
 #endif
 
 // JS_MaybeGC will run once every second during normal execution.
 #define PERIODIC_GC_TIMER_DELAY_SEC 1
 
 // A shrinking GC will run five seconds after the last event is processed.
 #define IDLE_GC_TIMER_DELAY_SEC 5
 
-#define PREF_WORKERS_ENABLED "dom.workers.enabled"
-
 static mozilla::LazyLogModule sWorkerPrivateLog("WorkerPrivate");
 static mozilla::LazyLogModule sWorkerTimeoutsLog("WorkerTimeouts");
 
 mozilla::LogModule*
 WorkerLog()
 {
   return sWorkerPrivateLog;
 }
@@ -2965,34 +2963,16 @@ WorkerPrivate::Constructor(const GlobalO
                            ErrorResult& aRv)
 {
   return WorkerPrivate::Constructor(aGlobal, aScriptURL, false,
                                     WorkerTypeDedicated,
                                     aOptions.mName, nullptr, aRv);
 }
 
 // static
-bool
-WorkerPrivate::WorkerAvailable(JSContext* aCx, JSObject* /* unused */)
-{
-  // If we're already on a worker workers are clearly enabled.
-  if (!NS_IsMainThread()) {
-    return true;
-  }
-
-  // If our caller is chrome, workers are always available.
-  if (nsContentUtils::IsSystemCaller(aCx)) {
-    return true;
-  }
-
-  // Else check the pref.
-  return Preferences::GetBool(PREF_WORKERS_ENABLED);
-}
-
-// static
 already_AddRefed<ChromeWorkerPrivate>
 ChromeWorkerPrivate::Constructor(const GlobalObject& aGlobal,
                                  const nsAString& aScriptURL,
                                  ErrorResult& aRv)
 {
   return WorkerPrivate::Constructor(aGlobal, aScriptURL, true,
                                     WorkerTypeDedicated, EmptyString(),
                                     nullptr, aRv)
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -973,19 +973,16 @@ public:
               WorkerLoadInfo* aLoadInfo, ErrorResult& aRv);
 
   static already_AddRefed<WorkerPrivate>
   Constructor(JSContext* aCx, const nsAString& aScriptURL, bool aIsChromeWorker,
               WorkerType aWorkerType, const nsAString& aWorkerName,
               const nsACString& aServiceWorkerScope,
               WorkerLoadInfo* aLoadInfo, ErrorResult& aRv);
 
-  static bool
-  WorkerAvailable(JSContext* /* unused */, JSObject* /* unused */);
-
   enum LoadGroupBehavior
   {
     InheritLoadGroup,
     OverrideLoadGroup
   };
 
   static nsresult
   GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
--- a/dom/workers/test/chrome.ini
+++ b/dom/workers/test/chrome.ini
@@ -47,17 +47,16 @@ support-files =
   filePosting_worker.js
   fileReadSlice_worker.js
   fileReaderSyncErrors_worker.js
   fileReaderSync_worker.js
   fileSlice_worker.js
   fileSubWorker_worker.js
   file_worker.js
   sharedWorker_privateBrowsing.js
-  workersDisabled_worker.js
 
 [test_WorkerDebugger.initialize.xul]
 [test_WorkerDebugger.postMessage.xul]
 [test_WorkerDebugger.xul]
 [test_WorkerDebuggerGlobalScope.createSandbox.xul]
 [test_WorkerDebuggerGlobalScope.enterEventLoop.xul]
 [test_WorkerDebuggerGlobalScope.reportError.xul]
 skip-if = (os == 'linux') # Bug 1244697
@@ -76,11 +75,10 @@ skip-if = (os == 'linux') # Bug 1244409
 [test_fileBlobPosting.xul]
 [test_fileBlobSubWorker.xul]
 [test_filePosting.xul]
 [test_fileReadSlice.xul]
 [test_fileReaderSync.xul]
 [test_fileReaderSyncErrors.xul]
 [test_fileSlice.xul]
 [test_fileSubWorker.xul]
-[test_workersDisabled.xul]
 [test_bug1062920.xul]
 [test_sharedWorker_privateBrowsing.html]
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -67,17 +67,16 @@ support-files =
   threadErrors_worker1.js
   threadErrors_worker2.js
   threadErrors_worker3.js
   threadErrors_worker4.js
   threadTimeouts_worker.js
   throwingOnerror_worker.js
   timeoutTracing_worker.js
   transferable_worker.js
-  workersDisabled_worker.js
   test_worker_interfaces.js
   worker_driver.js
   worker_wrapper.js
   bug1060621_worker.js
   bug1062920_worker.js
   bug1104064_worker.js
   worker_consoleAndBlobs.js
   bug1132395_sharedWorker.js
@@ -180,17 +179,16 @@ support-files =
 [test_threadErrors.html]
 [test_threadTimeouts.html]
 [test_throwingOnerror.html]
 [test_timeoutTracing.html]
 [test_transferable.html]
 [test_worker_interfaces.html]
 [test_worker_interfaces_secureContext.html]
 scheme=https
-[test_workersDisabled.html]
 [test_referrer.html]
 [test_referrer_header_worker.html]
 [test_importScripts_3rdparty.html]
 [test_sharedWorker_ports.html]
 [test_sharedWorker_lifetime.html]
 [test_navigator_workers_hardwareConcurrency.html]
 [test_bug1278777.html]
 [test_setTimeoutWith0.html]
deleted file mode 100644
--- a/dom/workers/test/test_workersDisabled.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-  <head>
-    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js">
-    </script>
-    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  </head>
-  <body>
-    <script type="text/javascript">
-      SimpleTest.waitForExplicitFinish();
-
-      const enabledPref = "dom.workers.enabled";
-
-      is(SpecialPowers.getBoolPref(enabledPref), true,
-         "Workers should be enabled.");
-
-      SpecialPowers.pushPrefEnv({"set": [[enabledPref, false]]}, test1);
-
-      function test1() {
-        ok(!("Worker" in window), "Worker constructor should not be available.");
-
-        var exception;
-        try {
-          var worker = new Worker("workersDisabled_worker.js");
-        }
-        catch(e) {
-          exception = e;
-        }
-
-        ok(exception, "Shouldn't be able to make a worker.");
-
-        SpecialPowers.pushPrefEnv({"set": [[enabledPref, true]]}, test2);
-      }
-
-      function test2() {
-        ok(("Worker" in window), "Worker constructor should be available.");
-
-        const message = "Hi";
-
-        var worker = new Worker("workersDisabled_worker.js");
-        worker.onmessage = function(event) {
-          is(event.data, message, "Good message.");
-          SimpleTest.finish();
-        }
-        worker.postMessage(message);
-      }
-    </script>
-  </body>
-</html>
-
deleted file mode 100644
--- a/dom/workers/test/test_workersDisabled.xul
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0"?>
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<window title="DOM Worker Threads Test"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="test();">
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-  <script type="application/javascript" src="dom_worker_helper.js"/>
-
-  <script type="application/javascript">
-  <![CDATA[
-    function test()
-    {
-      const enabledPref = "dom.workers.enabled";
-      const message = "Hi";
-
-      var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                            .getService(Components.interfaces.nsIPrefBranch);
-      is(prefs.getBoolPref(enabledPref), true, "Workers should be enabled.");
-
-      prefs.setBoolPref(enabledPref, false);
-
-      ok("Worker" in window, "Worker constructor should be available.");
-      ok("ChromeWorker" in window,
-         "ChromeWorker constructor should be available.");
-
-      var worker = new ChromeWorker("workersDisabled_worker.js");
-      worker.onmessage = function(event) {
-        is(event.data, message, "Good message.");
-        prefs.clearUserPref(enabledPref);
-        finish();
-      }
-      worker.postMessage(message);
-
-      waitForWorkerFinish();
-    }
-  ]]>
-  </script>
-
-  <body xmlns="http://www.w3.org/1999/xhtml">
-    <p id="display"></p>
-    <div id="content" style="display:none;"></div>
-    <pre id="test"></pre>
-  </body>
-  <label id="test-result"/>
-</window>
deleted file mode 100644
--- a/dom/workers/test/workersDisabled_worker.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-onmessage = function(event) {
-  postMessage(event.data);
-}
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -140,19 +140,16 @@ pref("dom.select_events.enabled", true);
 
 // Whether or not selection events on text controls are enabled
 #ifdef NIGHTLY_BUILD
 pref("dom.select_events.textcontrols.enabled", true);
 #else
 pref("dom.select_events.textcontrols.enabled", false);
 #endif
 
-// Whether or not Web Workers are enabled.
-pref("dom.workers.enabled", true);
-
 // The number of workers per domain allowed to run concurrently.
 // We're going for effectively infinite, while preventing abuse.
 pref("dom.workers.maxPerDomain", 512);
 
 pref("dom.serviceWorkers.enabled", false);
 
 // The amount of time (milliseconds) service workers keep running after each event.
 pref("dom.serviceWorkers.idle_timeout", 30000);