Bug 1515814 - Ensure that nobody uses this in a child process. r=asuth
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 21 Dec 2018 19:47:40 +0000
changeset 508854 bfb1e23872cc2b88bab9f929e0ecf7b102e15614
parent 508853 64e898f29fd8a1f93fb0e5fb0ee1e897ff8daec6
child 508855 bb5fbd4432e3ff9d628c54fe362405583dde1c7e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1515814
milestone66.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 1515814 - Ensure that nobody uses this in a child process. r=asuth This assures us that nobody misuses this code in the wrong process. Differential Revision: https://phabricator.services.mozilla.com/D15161
toolkit/components/cleardata/ServiceWorkerCleanUp.jsm
--- a/toolkit/components/cleardata/ServiceWorkerCleanUp.jsm
+++ b/toolkit/components/cleardata/ServiceWorkerCleanUp.jsm
@@ -1,20 +1,25 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "serviceWorkerManager",
                                    "@mozilla.org/serviceworkers/manager;1",
                                    "nsIServiceWorkerManager");
 
+if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) {
+  throw "ServiceWorkerCleanUp.jsm can only be used in the parent process";
+}
+
 this.EXPORTED_SYMBOLS = ["ServiceWorkerCleanUp"];
 
 function unregisterServiceWorker(aSW) {
   return new Promise(resolve => {
     let unregisterCallback = {
       unregisterSucceeded: resolve,
       unregisterFailed: resolve, // We don't care about failures.
       QueryInterface: ChromeUtils.generateQI([Ci.nsIServiceWorkerUnregisterCallback]),