Bug 1269303 - Remove RequestSync API, r=fabrice
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 May 2016 11:13:03 +0200
changeset 362932 b2dfb759f29036a6c211b36dd6246d3083d52f2a
parent 362931 5991e7117793c2b9be47d12daf8c6ac7a18ec27c
child 362933 5ff6c23714396e0c4d8d1add6b3ec3e2815b9880
push id17058
push userbmo:ttromey@mozilla.com
push dateTue, 03 May 2016 14:35:18 +0000
reviewersfabrice
bugs1269303
milestone49.0a1
Bug 1269303 - Remove RequestSync API, r=fabrice
b2g/app/b2g.js
b2g/chrome/content/shell.js
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/apps/PermissionsTable.jsm
dom/downloads/tests/shim_app_as_test.js
dom/moz.build
dom/requestsync/RequestSync.manifest
dom/requestsync/RequestSyncApp.jsm
dom/requestsync/RequestSyncManager.js
dom/requestsync/RequestSyncScheduler.js
dom/requestsync/RequestSyncService.jsm
dom/requestsync/RequestSyncTask.jsm
dom/requestsync/RequestSyncWifiService.cpp
dom/requestsync/RequestSyncWifiService.h
dom/requestsync/moz.build
dom/requestsync/tests/common_app.js
dom/requestsync/tests/common_basic.js
dom/requestsync/tests/file_app.sjs
dom/requestsync/tests/file_app.template.webapp
dom/requestsync/tests/file_basic_app.html
dom/requestsync/tests/file_interface.html
dom/requestsync/tests/mochitest.ini
dom/requestsync/tests/system_message_chrome_script.js
dom/requestsync/tests/test_basic.html
dom/requestsync/tests/test_basic_app.html
dom/requestsync/tests/test_bug1151082.html
dom/requestsync/tests/test_minInterval.html
dom/requestsync/tests/test_promise.html
dom/requestsync/tests/test_runNow.html
dom/requestsync/tests/test_wakeUp.html
dom/requestsync/tests/test_webidl.html
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/RequestSyncManager.webidl
dom/webidl/RequestSyncScheduler.webidl
dom/webidl/moz.build
layout/build/nsLayoutStatics.cpp
mobile/android/installer/package-manifest.in
modules/libpref/init/all.js
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -1050,19 +1050,16 @@ pref("dom.mozSettings.SettingsManager.ve
 pref("dom.mozSettings.SettingsRequestManager.verbose.enabled", false);
 pref("dom.mozSettings.SettingsService.verbose.enabled", false);
 
 // Controlling whether we want to allow forcing some Settings
 // IndexedDB transactions to be opened as readonly or keep everything as
 // readwrite.
 pref("dom.mozSettings.allowForceReadOnly", false);
 
-// RequestSync API is enabled by default on B2G.
-pref("dom.requestSync.enabled", true);
-
 // Comma separated list of activity names that can only be provided by
 // the system app in dev mode.
 pref("dom.activities.developer_mode_only", "import-app");
 
 // mulet apparently loads firefox.js as well as b2g.js, so we have to explicitly
 // disable serviceworkers and push here to get them disabled in mulet.
 pref("dom.serviceWorkers.enabled", false);
 pref("dom.push.enabled", false);
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -11,17 +11,16 @@ Cu.import('resource://gre/modules/AlarmS
 Cu.import('resource://gre/modules/ActivitiesService.jsm');
 Cu.import('resource://gre/modules/NotificationDB.jsm');
 Cu.import('resource://gre/modules/Payment.jsm');
 Cu.import("resource://gre/modules/AppsUtils.jsm");
 Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
 Cu.import('resource://gre/modules/Keyboard.jsm');
 Cu.import('resource://gre/modules/ErrorPage.jsm');
 Cu.import('resource://gre/modules/AlertsHelper.jsm');
-Cu.import('resource://gre/modules/RequestSyncService.jsm');
 Cu.import('resource://gre/modules/SystemUpdateService.jsm');
 
 if (isGonk) {
   Cu.import('resource://gre/modules/NetworkStatsService.jsm');
   Cu.import('resource://gre/modules/ResourceStatsService.jsm');
 }
 
 Cu.import('resource://gre/modules/KillSwitchMain.jsm');
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -346,19 +346,16 @@
 @RESPATH@/components/xpcom_xpti.xpt
 @RESPATH@/components/xpconnect.xpt
 @RESPATH@/components/xulapp.xpt
 @RESPATH@/components/xul.xpt
 @RESPATH@/components/xultmpl.xpt
 @RESPATH@/components/zipwriter.xpt
 
 ; JavaScript components
-@RESPATH@/components/RequestSync.manifest
-@RESPATH@/components/RequestSyncManager.js
-@RESPATH@/components/RequestSyncScheduler.js
 @RESPATH@/components/ChromeNotifications.js
 @RESPATH@/components/ChromeNotifications.manifest
 @RESPATH@/components/ConsoleAPI.manifest
 @RESPATH@/components/ConsoleAPIStorage.js
 @RESPATH@/components/BrowserElementParent.manifest
 @RESPATH@/components/BrowserElementParent.js
 @RESPATH@/components/BrowserElementProxy.manifest
 @RESPATH@/components/BrowserElementProxy.js
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -507,20 +507,16 @@
 @RESPATH@/components/Webapps.manifest
 @RESPATH@/components/AppsService.js
 @RESPATH@/components/AppsService.manifest
 @RESPATH@/components/recording-cmdline.js
 @RESPATH@/components/recording-cmdline.manifest
 @RESPATH@/components/htmlMenuBuilder.js
 @RESPATH@/components/htmlMenuBuilder.manifest
 
-@RESPATH@/components/RequestSync.manifest
-@RESPATH@/components/RequestSyncManager.js
-@RESPATH@/components/RequestSyncScheduler.js
-
 @RESPATH@/components/PermissionSettings.js
 @RESPATH@/components/PermissionSettings.manifest
 @RESPATH@/components/ContactManager.js
 @RESPATH@/components/ContactManager.manifest
 @RESPATH@/components/PhoneNumberService.js
 @RESPATH@/components/PhoneNumberService.manifest
 @RESPATH@/components/NotificationStorage.js
 @RESPATH@/components/NotificationStorage.manifest
--- a/dom/apps/PermissionsTable.jsm
+++ b/dom/apps/PermissionsTable.jsm
@@ -467,21 +467,16 @@ this.PermissionsTable =  { geolocation: 
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "presentation-device-manage": {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
-                           "requestsync-manager": {
-                             app: DENY_ACTION,
-                             privileged: DENY_ACTION,
-                             certified: ALLOW_ACTION
-                           },
                            "secureelement-manage": {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "inputport": {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
--- a/dom/downloads/tests/shim_app_as_test.js
+++ b/dom/downloads/tests/shim_app_as_test.js
@@ -1,16 +1,10 @@
 /**
- * Support logic to run a test file as an installed app.  This file is derived
- * from dom/requestsync/tests/test_basic_app.html but uses
- * DOMApplicationRegistry in a chrome script (shim_app_as_test_chrome.js) to
- * directly install the apps instead of mozApps.install because mozApps.install
- * can't install privileged/certified apps.  (This is the same mechanism used by
- * the Firefox OS Gaia email app's backend test runner.)
- *
+ * Support logic to run a test file as an installed app.
  * You really only want to do this if your test cares about the app's origin
  * or you REALLY want to double-check AvailableIn and other WebIDL-provided
  * security mechanisms.
  *
  * If you trust WebIDL, your life may be made significantly easier by just
  * setting the pref "dom.ignore_webidl_scope_checks" to true, which makes
  * BindingUtils.cpp's IsInPrivilegedApp and IsInCertifiedApp return true no
  * matter what *on the main thread*.  You are potentially out of luck on
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -41,17 +41,16 @@ DIRS += ['interfaces/' + i for i in inte
 
 DIRS += [
     'animation',
     'apps',
     'base',
     'bluetooth',
     'activities',
     'archivereader',
-    'requestsync',
     'bindings',
     'battery',
     'browser-element',
     'cache',
     'canvas',
     'cellbroadcast',
     'contacts',
     'crypto',
deleted file mode 100644
--- a/dom/requestsync/RequestSync.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-component {8ee5ab74-15c4-478f-9d32-67627b9f0f1a} RequestSyncScheduler.js
-contract @mozilla.org/dom/request-sync-scheduler;1 {8ee5ab74-15c4-478f-9d32-67627b9f0f1a}
-
-component {e6f55080-e549-4e30-9d00-15f240fb763c} RequestSyncManager.js
-contract @mozilla.org/dom/request-sync-manager;1 {e6f55080-e549-4e30-9d00-15f240fb763c}
deleted file mode 100644
--- a/dom/requestsync/RequestSyncApp.jsm
+++ /dev/null
@@ -1,48 +0,0 @@
-/* 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';
-
-this.EXPORTED_SYMBOLS = ['RequestSyncApp'];
-
-function debug(s) {
-  //dump('DEBUG RequestSyncApp: ' + s + '\n');
-}
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-
-this.RequestSyncApp = function(aData) {
-  debug('created');
-
-  let keys = [ 'origin', 'manifestURL', 'isInBrowserElement' ];
-  for (let i = 0; i < keys.length; ++i) {
-    if (!(keys[i] in aData)) {
-      dump("ERROR - RequestSyncApp must receive a full app object: " + keys[i] + " missing.");
-      throw "ERROR!";
-    }
-
-    this["_" + keys[i]] = aData[keys[i]];
-  }
-}
-
-this.RequestSyncApp.prototype = {
-  classDescription: 'RequestSyncApp XPCOM Component',
-  classID: Components.ID('{5a0b64db-a2be-4f08-a6c5-8bf2e3ae0c57}'),
-  contractID: '@mozilla.org/dom/request-sync-manager;1',
-  QueryInterface: XPCOMUtils.generateQI([]),
-
-  get origin() {
-    return this._origin;
-  },
-
-  get manifestURL() {
-    return this._manifestURL;
-  },
-
-  get isInBrowserElement() {
-    return this._isInBrowserElement;
-  }
-};
deleted file mode 100644
--- a/dom/requestsync/RequestSyncManager.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/* 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';
-
-function debug(s) {
-  //dump('DEBUG RequestSyncManager: ' + s + '\n');
-}
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import('resource://gre/modules/RequestSyncApp.jsm');
-Cu.import('resource://gre/modules/RequestSyncTask.jsm');
-
-XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-                                   "@mozilla.org/childprocessmessagemanager;1",
-                                   "nsIMessageSender");
-
-function RequestSyncManager() {
-  debug('created');
-}
-
-RequestSyncManager.prototype = {
-  __proto__: DOMRequestIpcHelper.prototype,
-
-  classDescription: 'RequestSyncManager XPCOM Component',
-  classID: Components.ID('{e6f55080-e549-4e30-9d00-15f240fb763c}'),
-  contractID: '@mozilla.org/dom/request-sync-manager;1',
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
-                                         Ci.nsIObserver,
-                                         Ci.nsIDOMGlobalPropertyInitializer]),
-
-  _messages: [ "RequestSyncManager:Registrations:Return",
-               "RequestSyncManager:SetPolicy:Return",
-               "RequestSyncManager:RunTask:Return" ],
-
-  init: function(aWindow) {
-    debug("init");
-
-    // DOMRequestIpcHelper.initHelper sets this._window
-    this.initDOMRequestHelper(aWindow, this._messages);
-  },
-
-  sendMessage: function(aMsg, aObj) {
-    let self = this;
-    return this.createPromiseWithId(function(aResolverId) {
-      aObj.requestID = aResolverId;
-      cpmm.sendAsyncMessage(aMsg, aObj, null,
-                            self._window.document.nodePrincipal);
-    });
-  },
-
-  registrations: function() {
-    debug('registrations');
-    return this.sendMessage("RequestSyncManager:Registrations", {});
-  },
-
-  setPolicy: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement,
-                      aState, aOverwrittenMinInterval) {
-    debug('setPolicy');
-
-    return this.sendMessage("RequestSyncManager:SetPolicy",
-      { task: aTask,
-        origin: aOrigin,
-        manifestURL: aManifestURL,
-        isInBrowserElement: aIsInIsolatedMozBrowserElement,
-        state: aState,
-        overwrittenMinInterval: aOverwrittenMinInterval });
-  },
-
-  runTask: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement) {
-    debug('runTask');
-
-    return this.sendMessage("RequestSyncManager:RunTask",
-      { task: aTask,
-        origin: aOrigin,
-        manifestURL: aManifestURL,
-        isInBrowserElement: aIsInIsolatedMozBrowserElement });
-  },
-
-  registrationsResult: function(aData) {
-    debug("registrationsResult");
-
-    let results = new this._window.Array();
-    for (let i = 0; i < aData.length; ++i) {
-      if (!("app" in aData[i])) {
-        dump("ERROR - Serialization error in RequestSyncManager.\n");
-        continue;
-      }
-
-      let app = new RequestSyncApp(aData[i].app);
-      let exposedApp =
-        this._window.RequestSyncApp._create(this._window, app);
-
-      let task = new RequestSyncTask(this, this._window, exposedApp, aData[i]);
-      let exposedTask =
-        this._window.RequestSyncTask._create(this._window, task);
-
-      results.push(exposedTask);
-    }
-    return results;
-  },
-
-  receiveMessage: function(aMessage) {
-    debug('receiveMessage');
-
-    let req = this.getPromiseResolver(aMessage.data.requestID);
-    if (!req) {
-      return;
-    }
-
-    if ('error' in aMessage.data) {
-      req.reject(Cu.cloneInto(aMessage.data.error, this._window));
-      return;
-    }
-
-    if (aMessage.name == 'RequestSyncManager:Registrations:Return') {
-      req.resolve(this.registrationsResult(aMessage.data.results));
-      return;
-    }
-
-    if ('results' in aMessage.data) {
-      req.resolve(Cu.cloneInto(aMessage.data.results, this._window));
-      return;
-    }
-
-    req.resolve();
-  }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RequestSyncManager]);
deleted file mode 100644
--- a/dom/requestsync/RequestSyncScheduler.js
+++ /dev/null
@@ -1,100 +0,0 @@
-/* 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';
-
-function debug(s) {
-  //dump('DEBUG RequestSyncScheduler: ' + s + '\n');
-}
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import('resource://gre/modules/DOMRequestHelper.jsm');
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-
-XPCOMUtils.defineLazyServiceGetter(this, 'cpmm',
-                                   '@mozilla.org/childprocessmessagemanager;1',
-                                   'nsIMessageSender');
-
-function RequestSyncScheduler() {
-  debug('created');
-}
-
-RequestSyncScheduler.prototype = {
-  __proto__: DOMRequestIpcHelper.prototype,
-
-  classDescription: 'RequestSyncScheduler XPCOM Component',
-  classID: Components.ID('{8ee5ab74-15c4-478f-9d32-67627b9f0f1a}'),
-  contractID: '@mozilla.org/dom/request-sync-scheduler;1',
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
-                                         Ci.nsIObserver,
-                                         Ci.nsIDOMGlobalPropertyInitializer]),
-
-  _messages: [ 'RequestSync:Register:Return',
-               'RequestSync:Unregister:Return',
-               'RequestSync:Registrations:Return',
-               'RequestSync:Registration:Return' ],
-
-  init: function(aWindow) {
-    debug('init');
-
-    // DOMRequestIpcHelper.initHelper sets this._window
-    this.initDOMRequestHelper(aWindow, this._messages);
-  },
-
-  register: function(aTask, aParams) {
-    debug('register');
-    return this.sendMessage('RequestSync:Register',
-                            { task: aTask, params: aParams });
-  },
-
-  unregister: function(aTask) {
-    debug('unregister');
-    return this.sendMessage('RequestSync:Unregister',
-                            { task: aTask });
-  },
-
-  registrations: function() {
-    debug('registrations');
-    return this.sendMessage('RequestSync:Registrations', {});
-  },
-
-  registration: function(aTask) {
-    debug('registration');
-    return this.sendMessage('RequestSync:Registration',
-                            { task: aTask });
-  },
-
-  sendMessage: function(aMsg, aObj) {
-    let self = this;
-    return this.createPromiseWithId(function(aResolverId) {
-      aObj.requestID = aResolverId;
-      cpmm.sendAsyncMessage(aMsg, aObj, null,
-                            self._window.document.nodePrincipal);
-    });
-  },
-
-  receiveMessage: function(aMessage) {
-    debug('receiveMessage');
-
-    let req = this.getPromiseResolver(aMessage.data.requestID);
-    if (!req) {
-      return;
-    }
-
-    if ('error' in aMessage.data) {
-      req.reject(Cu.cloneInto(aMessage.data.error, this._window));
-      return;
-    }
-
-    if ('results' in aMessage.data) {
-      req.resolve(Cu.cloneInto(aMessage.data.results, this._window));
-      return;
-    }
-
-    req.resolve();
-  }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RequestSyncScheduler]);
deleted file mode 100644
--- a/dom/requestsync/RequestSyncService.jsm
+++ /dev/null
@@ -1,1008 +0,0 @@
-/* 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'
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-function debug(s) {
-  //dump('DEBUG RequestSyncService: ' + s + '\n');
-}
-
-const RSYNCDB_VERSION = 1;
-const RSYNCDB_NAME = "requestSync";
-const RSYNC_MIN_INTERVAL = 100;
-
-const RSYNC_OPERATION_TIMEOUT = 120000 // 2 minutes
-
-const RSYNC_STATE_ENABLED = "enabled";
-const RSYNC_STATE_DISABLED = "disabled";
-const RSYNC_STATE_WIFIONLY = "wifiOnly";
-
-Cu.import('resource://gre/modules/IndexedDBHelper.jsm');
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.importGlobalProperties(["indexedDB"]);
-
-
-XPCOMUtils.defineLazyServiceGetter(this, "appsService",
-                                   "@mozilla.org/AppsService;1",
-                                   "nsIAppsService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-                                   "@mozilla.org/childprocessmessagemanager;1",
-                                   "nsISyncMessageSender");
-
-XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
-                                   "@mozilla.org/parentprocessmessagemanager;1",
-                                   "nsIMessageBroadcaster");
-
-XPCOMUtils.defineLazyServiceGetter(this, "systemMessenger",
-                                   "@mozilla.org/system-message-internal;1",
-                                   "nsISystemMessagesInternal");
-
-XPCOMUtils.defineLazyServiceGetter(this, "secMan",
-                                   "@mozilla.org/scriptsecuritymanager;1",
-                                   "nsIScriptSecurityManager");
-
-XPCOMUtils.defineLazyServiceGetter(this, "powerManagerService",
-                                   "@mozilla.org/power/powermanagerservice;1",
-                                   "nsIPowerManagerService");
-
-XPCOMUtils.defineLazyModuleGetter(this, "AlarmService",
-                                  "resource://gre/modules/AlarmService.jsm");
-
-this.RequestSyncService = {
-  __proto__: IndexedDBHelper.prototype,
-
-  children: [],
-
-  _messages: [ "RequestSync:Register",
-               "RequestSync:Unregister",
-               "RequestSync:Registrations",
-               "RequestSync:Registration",
-               "RequestSyncManager:Registrations",
-               "RequestSyncManager:SetPolicy",
-               "RequestSyncManager:RunTask" ],
-
-  _pendingOperation: false,
-  _pendingMessages: [],
-
-  _registrations: {},
-
-  _wifi: false,
-
-  _activeTask: null,
-  _queuedTasks: [],
-
-  _timers: {},
-  _pendingRequests: {},
-
-  // This array contains functions to be executed after the scheduling of the
-  // current task or immediately if there are not scheduling in progress.
-  _afterSchedulingTasks: [],
-
-  // Initialization of the RequestSyncService.
-  init: function() {
-    debug("init");
-
-    if (!Services.prefs.getBoolPref("dom.requestSync.enabled")) {
-      return;
-    }
-
-    this._messages.forEach((function(msgName) {
-      ppmm.addMessageListener(msgName, this);
-    }).bind(this));
-
-    Services.obs.addObserver(this, 'xpcom-shutdown', false);
-    Services.obs.addObserver(this, 'clear-origin-data', false);
-    Services.obs.addObserver(this, 'wifi-state-changed', false);
-
-    this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
-
-    // Loading all the data from the database into the _registrations map.
-    // Any incoming message will be stored and processed when the async
-    // operation is completed.
-
-    this.dbTxn("readonly", function(aStore) {
-      aStore.openCursor().onsuccess = event => {
-        let cursor = event.target.result;
-        if (cursor) {
-          this.addRegistration(cursor.value, function() {
-            cursor.continue();
-          });
-        }
-      }
-    }.bind(this),
-    function() {
-      debug("initialization done");
-    },
-    function() {
-      dump("ERROR!! RequestSyncService - Failed to retrieve data from the database.\n");
-    });
-  },
-
-  // Shutdown the RequestSyncService.
-  shutdown: function() {
-    debug("shutdown");
-
-    this._messages.forEach((function(msgName) {
-      ppmm.removeMessageListener(msgName, this);
-    }).bind(this));
-
-    Services.obs.removeObserver(this, 'xpcom-shutdown');
-    Services.obs.removeObserver(this, 'clear-origin-data');
-    Services.obs.removeObserver(this, 'wifi-state-changed');
-
-    this.close();
-
-    // Removing all the registrations will delete the pending timers.
-    this.forEachRegistration(function(aObj) {
-      let key = this.principalToKey(aObj.principal);
-      this.removeRegistrationInternal(aObj.data.task, key);
-    }.bind(this));
-  },
-
-  observe: function(aSubject, aTopic, aData) {
-    debug("observe");
-
-    switch (aTopic) {
-      case 'xpcom-shutdown':
-        this.executeAfterScheduling(function() {
-          this.shutdown();
-        }.bind(this));
-        break;
-
-      case 'clear-origin-data':
-        this.executeAfterScheduling(function() {
-          this.clearData(aData);
-        }.bind(this));
-        break;
-
-      case 'wifi-state-changed':
-        this.executeAfterScheduling(function() {
-          this.wifiStateChanged(aSubject == 'enabled');
-        }.bind(this));
-        break;
-
-      default:
-        debug("Wrong observer topic: " + aTopic);
-        break;
-    }
-  },
-
-  // When an app is uninstalled, we have to clean all its tasks.
-  clearData: function(aData) {
-    debug('clearData');
-
-    if (!aData) {
-      return;
-    }
-
-    let pattern = JSON.parse(aData);
-    let dbKeys = [];
-
-    for (let key in this._registrations) {
-      let prin = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(key);
-      if (!ChromeUtils.originAttributesMatchPattern(prin.originAttributes, pattern)) {
-        continue;
-      }
-
-      for (let task in this._registrations[key]) {
-        dbKeys = this._registrations[key][task].dbKey;
-        this.removeRegistrationInternal(task, key);
-      }
-    }
-
-    if (dbKeys.length == 0) {
-      return;
-    }
-
-    // Remove the tasks from the database.
-    this.dbTxn('readwrite', function(aStore) {
-      for (let i = 0; i < dbKeys.length; ++i) {
-        aStore.delete(dbKeys[i]);
-      }
-    },
-    function() {
-      debug("ClearData completed");
-    }, function() {
-      debug("ClearData failed");
-    });
-  },
-
-  // Creation of the schema for the database.
-  upgradeSchema: function(aTransaction, aDb, aOldVersion, aNewVersion) {
-    debug('updateSchema');
-    aDb.createObjectStore(RSYNCDB_NAME, { autoIncrement: true });
-  },
-
-  // This method generates the key for the indexedDB object storage.
-  principalToKey: function(aPrincipal) {
-    return aPrincipal.origin;
-  },
-
-  // Add a task to the _registrations map and create the timer if it's needed.
-  addRegistration: function(aObj, aCb) {
-    debug('addRegistration');
-
-    let key = this.principalToKey(aObj.principal);
-    if (!(key in this._registrations)) {
-      this._registrations[key] = {};
-    }
-
-    this.scheduleTimer(aObj, function() {
-      this._registrations[key][aObj.data.task] = aObj;
-      if (aCb) {
-        aCb();
-      }
-    }.bind(this));
-  },
-
-  // Remove a task from the _registrations map and delete the timer if it's
-  // needed. It also checks if the principal is correct before doing the real
-  // operation.
-  removeRegistration: function(aTaskName, aKey, aPrincipal) {
-    debug('removeRegistration');
-
-    if (!(aKey in this._registrations) ||
-        !(aTaskName in this._registrations[aKey])) {
-      return false;
-    }
-
-    // Additional security check.
-    if (!aPrincipal.equals(this._registrations[aKey][aTaskName].principal)) {
-      return false;
-    }
-
-    this.removeRegistrationInternal(aTaskName, aKey);
-    return true;
-  },
-
-  removeRegistrationInternal: function(aTaskName, aKey) {
-    debug('removeRegistrationInternal');
-
-    let obj = this._registrations[aKey][aTaskName];
-
-    this.removeTimer(obj);
-
-    // It can be that this task has been already schedulated.
-    this.removeTaskFromQueue(obj);
-
-    // It can be that this object is already in scheduled, or in the queue of a
-    // iDB transacation. In order to avoid rescheduling it, we must disable it.
-    obj.active = false;
-
-    delete this._registrations[aKey][aTaskName];
-
-    // Lets remove the key in case there are not tasks registered.
-    for (let key in this._registrations[aKey]) {
-      return;
-    }
-    delete this._registrations[aKey];
-  },
-
-  removeTaskFromQueue: function(aObj) {
-    let pos = this._queuedTasks.indexOf(aObj);
-    if (pos != -1) {
-      this._queuedTasks.splice(pos, 1);
-    }
-  },
-
-  // The communication from the exposed objects and the service is done using
-  // messages. This function receives and processes them.
-  receiveMessage: function(aMessage) {
-    debug("receiveMessage");
-
-    // We cannot process this request now.
-    if (this._pendingOperation) {
-      this._pendingMessages.push(aMessage);
-      return;
-    }
-
-    // The principal is used to validate the message.
-    let principal = aMessage.principal;
-    if (!principal) {
-      return;
-    }
-
-    switch (aMessage.name) {
-      case "RequestSync:Register":
-        this.executeAfterScheduling(function() {
-          this.register(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSync:Unregister":
-        this.executeAfterScheduling(function() {
-          this.unregister(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSync:Registrations":
-        this.executeAfterScheduling(function() {
-          this.registrations(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSync:Registration":
-        this.executeAfterScheduling(function() {
-          this.registration(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSyncManager:Registrations":
-        this.executeAfterScheduling(function() {
-          this.managerRegistrations(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSyncManager:SetPolicy":
-        this.executeAfterScheduling(function() {
-          this.managerSetPolicy(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      case "RequestSyncManager:RunTask":
-        this.executeAfterScheduling(function() {
-          this.managerRunTask(aMessage.target, aMessage.data, principal);
-        }.bind(this));
-        break;
-
-      default:
-        debug("Wrong message: " + aMessage.name);
-        break;
-    }
-  },
-
-  // Basic validation.
-  validateRegistrationParams: function(aParams) {
-    if (aParams === null) {
-      return false;
-    }
-
-    // We must have a page.
-    if (!("wakeUpPage" in aParams) ||
-        aParams.wakeUpPage.length == 0) {
-      return false;
-    }
-
-    let minInterval = RSYNC_MIN_INTERVAL;
-    try {
-      minInterval = Services.prefs.getIntPref("dom.requestSync.minInterval");
-    } catch(e) {}
-
-    if (!("minInterval" in aParams) ||
-        aParams.minInterval < minInterval) {
-      return false;
-    }
-
-    return true;
-  },
-
-  // Registration of a new task.
-  register: function(aTarget, aData, aPrincipal) {
-    debug("register");
-
-    if (!this.validateRegistrationParams(aData.params)) {
-      aTarget.sendAsyncMessage("RequestSync:Register:Return",
-                               { requestID: aData.requestID,
-                                 error: "ParamsError" } );
-      return;
-    }
-
-    let key = this.principalToKey(aPrincipal);
-    if (key in this._registrations &&
-        aData.task in this._registrations[key]) {
-      // if this task already exists we overwrite it.
-      this.removeRegistrationInternal(aData.task, key);
-    }
-
-    // This creates a RequestTaskFull object.
-    aData.params.task = aData.task;
-    aData.params.lastSync = 0;
-    aData.params.principal = aPrincipal;
-
-    aData.params.state = RSYNC_STATE_ENABLED;
-    if (aData.params.wifiOnly) {
-      aData.params.state = RSYNC_STATE_WIFIONLY;
-    }
-
-    aData.params.overwrittenMinInterval = 0;
-
-    let dbKey = aData.task + "|" + key;
-
-    let data = { principal: aPrincipal,
-                 dbKey: dbKey,
-                 data: aData.params,
-                 active: true };
-
-    let self = this;
-    this.dbTxn('readwrite', function(aStore) {
-      aStore.put(data, data.dbKey);
-    },
-    function() {
-      self.addRegistration(data, function() {
-        aTarget.sendAsyncMessage("RequestSync:Register:Return",
-                                 { requestID: aData.requestID });
-      });
-    },
-    function() {
-      aTarget.sendAsyncMessage("RequestSync:Register:Return",
-                               { requestID: aData.requestID,
-                                 error: "IndexDBError" } );
-    });
-  },
-
-  // Unregister a task.
-  unregister: function(aTarget, aData, aPrincipal) {
-    debug("unregister");
-
-    let key = this.principalToKey(aPrincipal);
-    if (!(key in this._registrations) ||
-        !(aData.task in this._registrations[key])) {
-      aTarget.sendAsyncMessage("RequestSync:Unregister:Return",
-                               { requestID: aData.requestID,
-                                 error: "UnknownTaskError" });
-      return;
-    }
-
-    let dbKey = this._registrations[key][aData.task].dbKey;
-    this.removeRegistration(aData.task, key, aPrincipal);
-
-    let self = this;
-    this.dbTxn('readwrite', function(aStore) {
-      aStore.delete(dbKey);
-    },
-    function() {
-      aTarget.sendAsyncMessage("RequestSync:Unregister:Return",
-                               { requestID: aData.requestID });
-    },
-    function() {
-      aTarget.sendAsyncMessage("RequestSync:Unregister:Return",
-                               { requestID: aData.requestID,
-                                 error: "IndexDBError" } );
-    });
-  },
-
-  // Get the list of registered tasks for this principal.
-  registrations: function(aTarget, aData, aPrincipal) {
-    debug("registrations");
-
-    let results = [];
-    let key = this.principalToKey(aPrincipal);
-    if (key in this._registrations) {
-      for (let i in this._registrations[key]) {
-        results.push(this.createPartialTaskObject(
-          this._registrations[key][i].data));
-      }
-    }
-
-    aTarget.sendAsyncMessage("RequestSync:Registrations:Return",
-                             { requestID: aData.requestID,
-                               results: results });
-  },
-
-  // Get a particular registered task for this principal.
-  registration: function(aTarget, aData, aPrincipal) {
-    debug("registration");
-
-    let results = null;
-    let key = this.principalToKey(aPrincipal);
-    if (key in this._registrations &&
-        aData.task in this._registrations[key]) {
-      results = this.createPartialTaskObject(
-        this._registrations[key][aData.task].data);
-    }
-
-    aTarget.sendAsyncMessage("RequestSync:Registration:Return",
-                             { requestID: aData.requestID,
-                               results: results });
-  },
-
-  // Get the list of the registered tasks.
-  managerRegistrations: function(aTarget, aData, aPrincipal) {
-    debug("managerRegistrations");
-
-    let results = [];
-    let self = this;
-    this.forEachRegistration(function(aObj) {
-      results.push(self.createFullTaskObject(aObj.data));
-    });
-
-    aTarget.sendAsyncMessage("RequestSyncManager:Registrations:Return",
-                             { requestID: aData.requestID,
-                               results: results });
-  },
-
-  // Set a policy to a task.
-  managerSetPolicy: function(aTarget, aData, aPrincipal) {
-    debug("managerSetPolicy");
-
-    let toSave = null;
-    let self = this;
-    this.forEachRegistration(function(aObj) {
-      if (aObj.data.task != aData.task) {
-        return;
-      }
-
-      if (aObj.principal.isInIsolatedMozBrowserElement != aData.isInBrowserElement ||
-          aObj.principal.originNoSuffix != aData.origin) {
-        return;
-      }
-
-      let app = appsService.getAppByLocalId(aObj.principal.appId);
-      if (app && app.manifestURL != aData.manifestURL ||
-          (!app && aData.manifestURL != "")) {
-        return;
-      }
-
-      if ("overwrittenMinInterval" in aData) {
-        aObj.data.overwrittenMinInterval = aData.overwrittenMinInterval;
-      }
-
-      aObj.data.state = aData.state;
-
-      if (toSave) {
-        dump("ERROR!! RequestSyncService - SetPolicy matches more than 1 task.\n");
-        return;
-      }
-
-      toSave = aObj;
-    });
-
-    if (!toSave) {
-      aTarget.sendAsyncMessage("RequestSyncManager:SetPolicy:Return",
-                               { requestID: aData.requestID, error: "UnknownTaskError" });
-      return;
-    }
-
-    this.updateObjectInDB(toSave, function() {
-      self.scheduleTimer(toSave, function() {
-        aTarget.sendAsyncMessage("RequestSyncManager:SetPolicy:Return",
-                                 { requestID: aData.requestID });
-      });
-    });
-  },
-
-  // Run a task now.
-  managerRunTask: function(aTarget, aData, aPrincipal) {
-    debug("runTask");
-
-    let task = null;
-    this.forEachRegistration(function(aObj) {
-      if (aObj.data.task != aData.task) {
-        return;
-      }
-
-      if (aObj.principal.isInIsolatedMozBrowserElement != aData.isInBrowserElement ||
-          aObj.principal.originNoSuffix != aData.origin) {
-        return;
-      }
-
-      let app = appsService.getAppByLocalId(aObj.principal.appId);
-      if (app && app.manifestURL != aData.manifestURL ||
-          (!app && aData.manifestURL != "")) {
-        return;
-      }
-
-      if (task) {
-        dump("ERROR!! RequestSyncService - RunTask matches more than 1 task.\n");
-        return;
-      }
-
-      task = aObj;
-    });
-
-    if (!task) {
-      aTarget.sendAsyncMessage("RequestSyncManager:RunTask:Return",
-                               { requestID: aData.requestID, error: "UnknownTaskError" });
-      return;
-    }
-
-    // Storing the requestID into the task for the callback.
-    this.storePendingRequest(task, aTarget, aData.requestID);
-    this.timeout(task, null);
-  },
-
-  // We cannot expose the full internal object to content but just a subset.
-  // This method creates this subset.
-  createPartialTaskObject: function(aObj) {
-    return { task: aObj.task,
-             lastSync: aObj.lastSync,
-             oneShot: aObj.oneShot,
-             minInterval: aObj.minInterval,
-             wakeUpPage: aObj.wakeUpPage,
-             wifiOnly: aObj.wifiOnly,
-             data: aObj.data };
-  },
-
-  createFullTaskObject: function(aObj) {
-    let obj = this.createPartialTaskObject(aObj);
-
-    obj.app = { manifestURL: '',
-                origin: aObj.principal.originNoSuffix,
-                isInBrowserElement: aObj.principal.isInIsolatedMozBrowserElement };
-
-    let app = appsService.getAppByLocalId(aObj.principal.appId);
-    if (app) {
-      obj.app.manifestURL = app.manifestURL;
-    }
-
-    obj.state = aObj.state;
-    obj.overwrittenMinInterval = aObj.overwrittenMinInterval;
-    return obj;
-  },
-
-  // Creation of the timer for a particular task object.
-  scheduleTimer: function(aObj, aCb) {
-    debug("scheduleTimer");
-
-    aCb = aCb || function() {};
-
-    this.removeTimer(aObj);
-
-    // A  registration can be already inactive if it was 1 shot.
-    if (!aObj.active) {
-      aCb();
-      return;
-    }
-
-    if (aObj.data.state == RSYNC_STATE_DISABLED) {
-      aCb();
-      return;
-    }
-
-    // WifiOnly check.
-    if (aObj.data.state == RSYNC_STATE_WIFIONLY && !this._wifi) {
-      aCb();
-      return;
-    }
-
-    if (this.scheduling) {
-      dump("ERROR!! RequestSyncService - ScheduleTimer called into ScheduleTimer.\n");
-      aCb();
-      return;
-    }
-
-    this.scheduling = true;
-
-    this.createTimer(aObj, function() {
-      this.scheduling = false;
-
-      while (this._afterSchedulingTasks.length) {
-        var cb = this._afterSchedulingTasks.shift();
-        cb();
-      }
-
-      aCb();
-    }.bind(this));
-  },
-
-  executeAfterScheduling: function(aCb) {
-    if (!this.scheduling) {
-      aCb();
-      return;
-    }
-
-    this._afterSchedulingTasks.push(aCb);
-  },
-
-  timeout: function(aObj, aWakeLock) {
-    debug("timeout");
-
-    if (this._activeTask) {
-      debug("queueing tasks");
-      // We have an active task, let's queue this as next task.
-      if (this._queuedTasks.indexOf(aObj) == -1) {
-        this._queuedTasks.push(aObj);
-      }
-      this.maybeReleaseWakeLock(aWakeLock);
-      return;
-    }
-
-    let app = appsService.getAppByLocalId(aObj.principal.appId);
-    if (!app) {
-      dump("ERROR!! RequestSyncService - Failed to retrieve app data from a principal.\n");
-      aObj.active = false;
-      this.updateObjectInDB(aObj, () => {
-        this.maybeReleaseWakeLock(aWakeLock);
-      });
-      return;
-    }
-
-    let manifestURL = Services.io.newURI(app.manifestURL, null, null);
-    let pageURL = Services.io.newURI(aObj.data.wakeUpPage, null, aObj.principal.URI);
-
-    // Maybe need to be rescheduled?
-    if (this.hasPendingMessages('request-sync', manifestURL, pageURL)) {
-      this.scheduleTimer(aObj, () => {
-        this.maybeReleaseWakeLock(aWakeLock);
-      });
-      return;
-    }
-
-    this.removeTimer(aObj);
-
-    if (!manifestURL || !pageURL) {
-      dump("ERROR!! RequestSyncService - Failed to create URI for the page or the manifest\n");
-      aObj.active = false;
-      this.updateObjectInDB(aObj, () => {
-        this.maybeReleaseWakeLock(aWakeLock);
-      });
-      return;
-    }
-
-    this._activeTask = aObj;
-
-    // We don't want to run more than 1 task at the same time. We do this using
-    // the promise created by sendMessage(). But if the task takes more than
-    // RSYNC_OPERATION_TIMEOUT millisecs, we have to ignore the promise and
-    // continue processing other tasks.
-
-    let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-
-    // We need a wakelock to keep the device alive and we want to release it
-    // only when all the steps are fully completely. This can involve calling
-    // timeout() again if we have something in _queuedTasks. In this scenario
-    // we want to reuse the same wakelock and we receive it as param.
-    // The Wakelock is passed to operationCompleted() because we want to wait
-    // until the data is written into IDB and maybe until all the pending next
-    // tasks are executed too.
-    let wakeLock = aWakeLock ? aWakeLock : powerManagerService.newWakeLock("cpu");
-    let done = false;
-    let self = this;
-    function taskCompleted() {
-      debug("promise or timeout for task calls taskCompleted");
-
-      if (!done) {
-        done = true;
-        self.operationCompleted(wakeLock);
-      }
-
-      timer.cancel();
-      timer = null;
-    }
-
-    let timeout = RSYNC_OPERATION_TIMEOUT;
-    try {
-      let tmp = Services.prefs.getIntPref("dom.requestSync.maxTaskTimeout");
-      timeout = tmp;
-    } catch(e) {}
-
-    timer.initWithCallback(function() {
-      debug("Task is taking too much, let's ignore the promise.");
-      taskCompleted();
-    }, timeout, Ci.nsITimer.TYPE_ONE_SHOT);
-
-    // Sending the message.
-    debug("Sending message.");
-    let promise =
-      systemMessenger.sendMessage('request-sync',
-                                  this.createPartialTaskObject(aObj.data),
-                                  pageURL, manifestURL);
-
-    promise.then(function() {
-      debug("promise resolved");
-      taskCompleted();
-    }, function() {
-      debug("promise rejected");
-      taskCompleted();
-    });
-  },
-
-  operationCompleted: function(aWakeLock) {
-    debug("operationCompleted");
-
-    if (!this._activeTask) {
-      dump("ERROR!! RequestSyncService - OperationCompleted called without an active task\n");
-      aWakeLock.unlock();
-      return;
-    }
-
-    // One shot? Then this is not active.
-    this._activeTask.active = !this._activeTask.data.oneShot;
-    this._activeTask.data.lastSync = new Date();
-
-    let pendingRequests = this.stealPendingRequests(this._activeTask);
-    for (let i = 0; i < pendingRequests.length; ++i) {
-      pendingRequests[i]
-          .target.sendAsyncMessage("RequestSyncManager:RunTask:Return",
-                                   { requestID: pendingRequests[i].requestID });
-    }
-
-    this.updateObjectInDB(this._activeTask, function() {
-      if (!this._activeTask.data.oneShot) {
-        this.scheduleTimer(this._activeTask, function() {
-          this.processNextTask(aWakeLock);
-        }.bind(this));
-      } else {
-        this.processNextTask(aWakeLock);
-      }
-    }.bind(this));
-  },
-
-  processNextTask: function(aWakeLock) {
-    debug("processNextTask");
-
-    this._activeTask = null;
-
-    if (this._queuedTasks.length == 0) {
-      aWakeLock.unlock();
-      return;
-    }
-
-    let task = this._queuedTasks.shift();
-    this.timeout(task, aWakeLock);
-  },
-
-  hasPendingMessages: function(aMessageName, aManifestURL, aPageURL) {
-    let hasPendingMessages =
-      cpmm.sendSyncMessage("SystemMessageManager:HasPendingMessages",
-                           { type: aMessageName,
-                             pageURL: aPageURL.spec,
-                             manifestURL: aManifestURL.spec })[0];
-
-    debug("Pending messages: " + hasPendingMessages);
-    return hasPendingMessages;
-  },
-
-  // Update the object into the database.
-  updateObjectInDB: function(aObj, aCb) {
-    debug("updateObjectInDB");
-
-    this.dbTxn('readwrite', function(aStore) {
-      aStore.put(aObj, aObj.dbKey);
-    },
-    function() {
-      if (aCb) {
-        aCb();
-      }
-      debug("UpdateObjectInDB completed");
-    }, function() {
-      debug("UpdateObjectInDB failed");
-    });
-  },
-
-  pendingOperationStarted: function() {
-    debug('pendingOperationStarted');
-    this._pendingOperation = true;
-  },
-
-  pendingOperationDone: function() {
-    debug('pendingOperationDone');
-
-    this._pendingOperation = false;
-
-    // managing the pending messages now that the initialization is completed.
-    while (this._pendingMessages.length && !this._pendingOperation) {
-      this.receiveMessage(this._pendingMessages.shift());
-    }
-  },
-
-  // This method creates a transaction and runs callbacks. Plus it manages the
-  // pending operations system.
-  dbTxn: function(aType, aCb, aSuccessCb, aErrorCb) {
-    debug('dbTxn');
-
-    this.pendingOperationStarted();
-
-    let self = this;
-    this.newTxn(aType, RSYNCDB_NAME, function(aTxn, aStore) {
-      aCb(aStore);
-    },
-    function() {
-      self.pendingOperationDone();
-      aSuccessCb();
-    },
-    function() {
-      self.pendingOperationDone();
-      aErrorCb();
-    });
-  },
-
-  forEachRegistration: function(aCb) {
-    // This method is used also to remove registations from the map, so we have
-    // to make a new list and let _registations free to be used.
-    let list = [];
-    for (let key in this._registrations) {
-      for (let task in this._registrations[key]) {
-        list.push(this._registrations[key][task]);
-      }
-    }
-
-    for (let i = 0; i < list.length; ++i) {
-      aCb(list[i]);
-    }
-  },
-
-  wifiStateChanged: function(aEnabled) {
-    debug("onWifiStateChanged");
-
-    this._wifi = aEnabled;
-
-    if (!this._wifi) {
-      // Disable all the wifiOnly tasks.
-      this.forEachRegistration(function(aObj) {
-        if (aObj.data.state == RSYNC_STATE_WIFIONLY && this.hasTimer(aObj)) {
-          this.removeTimer(aObj);
-
-          // It can be that this task has been already schedulated.
-          this.removeTaskFromQueue(aObj);
-        }
-      }.bind(this));
-      return;
-    }
-
-    // Enable all the tasks.
-    this.forEachRegistration(function(aObj) {
-      if (aObj.active && !this.hasTimer(aObj)) {
-        if (!aObj.data.wifiOnly) {
-          dump("ERROR - Found a disabled task that is not wifiOnly.");
-        }
-
-        this.scheduleTimer(aObj);
-      }
-    }.bind(this));
-  },
-
-  createTimer: function(aObj, aCb) {
-    aCb = aCb || function() {};
-
-    let interval = aObj.data.minInterval;
-    if (aObj.data.overwrittenMinInterval > 0) {
-      interval = aObj.data.overwrittenMinInterval;
-    }
-
-    AlarmService.add(
-      { date: new Date(Date.now() + interval * 1000),
-        ignoreTimezone: false },
-      () => this.timeout(aObj, null),
-      function(aTimerId) {
-        this._timers[aObj.dbKey] = aTimerId;
-        aCb();
-      }.bind(this),
-      () => aCb());
-  },
-
-  hasTimer: function(aObj) {
-    return (aObj.dbKey in this._timers);
-  },
-
-  removeTimer: function(aObj) {
-    if (aObj.dbKey in this._timers) {
-      AlarmService.remove(this._timers[aObj.dbKey]);
-      delete this._timers[aObj.dbKey];
-    }
-  },
-
-  storePendingRequest: function(aObj, aTarget, aRequestID) {
-    if (!(aObj.dbKey in this._pendingRequests)) {
-      this._pendingRequests[aObj.dbKey] = [];
-    }
-
-    this._pendingRequests[aObj.dbKey].push({ target: aTarget,
-                                             requestID: aRequestID });
-  },
-
-  stealPendingRequests: function(aObj) {
-    if (!(aObj.dbKey in this._pendingRequests)) {
-      return [];
-    }
-
-    let requests = this._pendingRequests[aObj.dbKey];
-    delete this._pendingRequests[aObj.dbKey];
-    return requests;
-  },
-
-  maybeReleaseWakeLock: function(aWakeLock) {
-    if (aWakeLock) {
-      aWakeLock.unlock();
-    }
-  }
-}
-
-RequestSyncService.init();
-
-this.EXPORTED_SYMBOLS = [""];
deleted file mode 100644
--- a/dom/requestsync/RequestSyncTask.jsm
+++ /dev/null
@@ -1,108 +0,0 @@
-/* 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';
-
-this.EXPORTED_SYMBOLS = ['RequestSyncTask'];
-
-function debug(s) {
-  //dump('DEBUG RequestSyncTask: ' + s + '\n');
-}
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-
-this.RequestSyncTask = function(aManager, aWindow, aApp, aData) {
-  debug('created');
-
-  this._manager = aManager;
-  this._window = aWindow;
-  this._app = aApp;
-
-  let keys = [ 'task', 'lastSync', 'oneShot', 'minInterval', 'wakeUpPage',
-               'wifiOnly', 'data', 'state', 'overwrittenMinInterval' ];
-  for (let i = 0; i < keys.length; ++i) {
-    if (!(keys[i] in aData)) {
-      dump("ERROR - RequestSyncTask must receive a fully app object: " + keys[i] + " missing.");
-      throw "ERROR!";
-    }
-
-    this["_" + keys[i]] = aData[keys[i]];
-  }
-}
-
-this.RequestSyncTask.prototype = {
-  classDescription: 'RequestSyncTask XPCOM Component',
-  classID: Components.ID('{a1e1c9c6-ce42-49d4-b8b4-fbd686d8fdd9}'),
-  contractID: '@mozilla.org/dom/request-sync-manager;1',
-  QueryInterface: XPCOMUtils.generateQI([]),
-
-  get app() {
-    return this._app;
-  },
-
-  get state() {
-    return this._state;
-  },
-
-  get overwrittenMinInterval() {
-    return this._overwrittenMinInterval;
-  },
-
-  get task() {
-    return this._task;
-  },
-
-  get lastSync() {
-    return this._lastSync;
-  },
-
-  get wakeUpPage() {
-    return this._wakeUpPage;
-  },
-
-  get oneShot() {
-    return this._oneShot;
-  },
-
-  get minInterval() {
-    return this._minInterval;
-  },
-
-  get wifiOnly() {
-    return this._wifiOnly;
-  },
-
-  get data() {
-    return this._data;
-  },
-
-  setPolicy: function(aState, aOverwrittenMinInterval) {
-    debug("setPolicy");
-    let self = this;
-
-    return new this._window.Promise(function(aResolve, aReject) {
-      let p = self._manager.setPolicy(self._task, self._app.origin,
-                                      self._app.manifestURL,
-                                      self._app.isInBrowserElement,
-                                      aState,
-                                      aOverwrittenMinInterval);
-
-      // Set the new value only when the promise is resolved.
-      p.then(function() {
-        self._state = aState;
-        self._overwrittenMinInterval = aOverwrittenMinInterval;
-        aResolve();
-      }, aReject);
-    });
-  },
-
-  runNow: function() {
-    debug("runNow");
-    return this._manager.runTask(this._task, this._app.origin,
-                                 this._app.manifestURL,
-                                 this._app.isInBrowserElement);
-  }
-};
deleted file mode 100644
--- a/dom/requestsync/RequestSyncWifiService.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#include "RequestSyncWifiService.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "mozilla/Services.h"
-#include "mozilla/StaticPtr.h"
-#include "nsIObserverService.h"
-
-namespace mozilla {
-namespace dom {
-
-using namespace hal;
-
-NS_IMPL_ISUPPORTS0(RequestSyncWifiService)
-
-namespace {
-
-StaticRefPtr<RequestSyncWifiService> sService;
-
-} // namespace
-
-/* static */ void
-RequestSyncWifiService::Init()
-{
-  RefPtr<RequestSyncWifiService> service = GetInstance();
-  if (!service) {
-    NS_WARNING("Failed to initialize RequestSyncWifiService.");
-  }
-}
-
-/* static */ already_AddRefed<RequestSyncWifiService>
-RequestSyncWifiService::GetInstance()
-{
-  if (!sService) {
-    sService = new RequestSyncWifiService();
-    hal::RegisterNetworkObserver(sService);
-    ClearOnShutdown(&sService);
-  }
-
-  RefPtr<RequestSyncWifiService> service = sService.get();
-  return service.forget();
-}
-
-void
-RequestSyncWifiService::Notify(const hal::NetworkInformation& aNetworkInfo)
-{
-  bool isWifi = aNetworkInfo.isWifi();
-  if (isWifi == mIsWifi) {
-    return;
-  }
-
-  mIsWifi = isWifi;
-
-  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  if (obs) {
-    obs->NotifyObservers(nullptr, "wifi-state-changed",
-                         mIsWifi ? MOZ_UTF16("enabled") :
-                                   MOZ_UTF16("disabled"));
-  }
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/requestsync/RequestSyncWifiService.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef mozilla_dom_RequestSyncWifiService_h
-#define mozilla_dom_RequestSyncWifiService_h
-
-#include "mozilla/dom/network/Types.h"
-#include "mozilla/Hal.h"
-#include "nsIObserver.h"
-
-namespace mozilla {
-namespace dom {
-
-class RequestSyncWifiService final : public nsISupports
-                                   , public NetworkObserver
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  static void Init();
-
-  static already_AddRefed<RequestSyncWifiService> GetInstance();
-
-  void Notify(const hal::NetworkInformation& aNetworkInfo) override;
-
-private:
-  RequestSyncWifiService()
-    : mIsWifi(false)
-  {}
-
-  ~RequestSyncWifiService()
-  {}
-
-  bool mIsWifi;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_RequestSyncWifiService_h
deleted file mode 100644
--- a/dom/requestsync/moz.build
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
-
-EXPORTS.mozilla.dom += [
-    'RequestSyncWifiService.h',
-]
-
-EXTRA_COMPONENTS += [
-    'RequestSync.manifest',
-    'RequestSyncManager.js',
-    'RequestSyncScheduler.js',
-]
-
-EXTRA_JS_MODULES += [
-    'RequestSyncApp.jsm',
-    'RequestSyncService.jsm',
-    'RequestSyncTask.jsm',
-]
-
-SOURCES += [
-    'RequestSyncWifiService.cpp',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-FINAL_LIBRARY = 'xul'
-
-if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wshadow']
deleted file mode 100644
--- a/dom/requestsync/tests/common_app.js
+++ /dev/null
@@ -1,15 +0,0 @@
-function is(a, b, msg) {
-  alert((a === b ? 'OK' : 'KO') + ' ' + msg)
-}
-
-function ok(a, msg) {
-  alert((a ? 'OK' : 'KO')+ ' ' + msg)
-}
-
-function cbError() {
-  alert('KO error');
-}
-
-function finish() {
-  alert('DONE');
-}
deleted file mode 100644
--- a/dom/requestsync/tests/common_basic.js
+++ /dev/null
@@ -1,188 +0,0 @@
-function test_registerFailure() {
-  ok("sync" in navigator, "navigator.sync exists");
-
-  navigator.sync.register().then(
-  function() {
-    ok(false, "navigator.sync.register() throws without a task name");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a task name");
-  })
-
-  .then(function() {
-    return navigator.sync.register(42);
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a string task name");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a string task name");
-  })
-
-  .then(function() {
-    return navigator.sync.register('foobar');
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a param dictionary");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a param dictionary");
-  })
-
-  .then(function() {
-    return navigator.sync.register('foobar', 42);
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a real dictionary");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a real dictionary");
-  })
-
-  .then(function() {
-    return navigator.sync.register('foobar', {});
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a minInterval and wakeUpPage");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a minInterval and wakeUpPage");
-  })
-
-  .then(function() {
-    return navigator.sync.register('foobar', { minInterval: 100 });
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a wakeUpPage");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a wakeUpPage");
-  })
-
-  .then(function() {
-    return navigator.sync.register('foobar', { wakeUpPage: 100 });
-  }).then(function() {
-    ok(false, "navigator.sync.register() throws without a minInterval");
-  }, function() {
-    ok(true, "navigator.sync.register() throws without a minInterval");
-  })
-
-  .then(function() {
-    runTests();
-  });
-}
-
-function genericError(name, val) {
-  ok(false, "Promise from " + name + " rejected with value: " + val);
-}
-
-function test_register() {
-  navigator.sync.register('foobar', { minInterval: 5, wakeUpPage:'/' }).then(
-  function() {
-    ok(true, "navigator.sync.register() worked!");
-    runTests();
-  }, genericError.bind(null, 'register'));
-}
-
-function test_unregister() {
-  navigator.sync.unregister('foobar').then(
-  function() {
-    ok(true, "navigator.sync.unregister() worked!");
-    runTests();
-  }, genericError.bind(null, 'unregister'));
-}
-
-function test_unregisterDuplicate() {
-  navigator.sync.unregister('foobar').then(
-  genericError.bind(null, 'unregisterDuplicate'),
-  function(error) {
-    ok(true, "navigator.sync.unregister() should throw if the task doesn't exist.");
-    ok(error, "UnknownTaskError", "Duplicate unregistration error is correct");
-    runTests();
-  });
-}
-
-function test_registrationEmpty() {
-  navigator.sync.registration('bar').then(
-  function(results) {
-    is(results, null, "navigator.sync.registration() should return null.");
-    runTests();
-  },
-  genericError.bind(null, 'registrationEmpty'));
-}
-
-function test_registration() {
-  navigator.sync.registration('foobar').then(
-  function(results) {
-    is(results.task, 'foobar', "navigator.sync.registration().task is correct");
-    ok("lastSync" in results, "navigator.sync.registration().lastSync is correct");
-    is(results.oneShot, true, "navigator.sync.registration().oneShot is correct");
-    is(results.minInterval, 5, "navigator.sync.registration().minInterval is correct");
-    ok("wakeUpPage" in results, "navigator.sync.registration().wakeUpPage is correct");
-    ok("wifiOnly" in results, "navigator.sync.registration().wifiOnly is correct");
-    ok("data" in results, "navigator.sync.registration().data is correct");
-    ok(!("app" in results), "navigator.sync.registrations().app is correct");
-    runTests();
-  },
-  genericError.bind(null, 'registration'));
-}
-
-function test_registrationsEmpty() {
-  navigator.sync.registrations().then(
-  function(results) {
-    is(results.length, 0, "navigator.sync.registrations() should return an empty array.");
-    runTests();
-  },
-  genericError.bind(null, 'registrationEmpty'));
-}
-
-function test_registrations() {
-  navigator.sync.registrations().then(
-  function(results) {
-    is(results.length, 1, "navigator.sync.registrations() should not return an empty array.");
-    is(results[0].task, 'foobar', "navigator.sync.registrations()[0].task is correct");
-    ok("lastSync" in results[0], "navigator.sync.registrations()[0].lastSync is correct");
-    is(results[0].oneShot, true, "navigator.sync.registrations()[0].oneShot is correct");
-    is(results[0].minInterval, 5, "navigator.sync.registrations()[0].minInterval is correct");
-    ok("wakeUpPage" in results[0], "navigator.sync.registration()[0].wakeUpPage is correct");
-    ok("wifiOnly" in results[0], "navigator.sync.registrations()[0].wifiOnly is correct");
-    ok("data" in results[0], "navigator.sync.registrations()[0].data is correct");
-    ok(!("app" in results[0]), "navigator.sync.registrations()[0].app is correct");
-    runTests();
-  },
-  genericError.bind(null, 'registrations'));
-}
-
-function test_managerRegistrationsEmpty() {
-  navigator.syncManager.registrations().then(
-  function(results) {
-    is(results.length, 0, "navigator.syncManager.registrations() should return an empty array.");
-    runTests();
-  },
-  genericError.bind(null, 'managerRegistrationsEmpty'));
-}
-
-function test_managerRegistrations(state, overwrittenMinInterval) {
-  navigator.syncManager.registrations().then(
-  function(results) {
-    is(results.length, 1, "navigator.sync.registrations() should not return an empty array.");
-    is(results[0].task, 'foobar', "navigator.sync.registrations()[0].task is correct");
-    ok("lastSync" in results[0], "navigator.sync.registrations()[0].lastSync is correct");
-    is(results[0].oneShot, true, "navigator.sync.registrations()[0].oneShot is correct");
-    is(results[0].minInterval, 5, "navigator.sync.registrations()[0].minInterval is correct");
-    ok("wakeUpPage" in results[0], "navigator.sync.registration()[0].wakeUpPage is correct");
-    ok("wifiOnly" in results[0], "navigator.sync.registrations()[0].wifiOnly is correct");
-    ok("data" in results[0], "navigator.sync.registrations()[0].data is correct");
-    ok("app" in results[0], "navigator.sync.registrations()[0].app is correct");
-    ok("manifestURL" in results[0].app, "navigator.sync.registrations()[0].app.manifestURL is correct");
-    is(results[0].app.origin, 'http://mochi.test:8888', "navigator.sync.registrations()[0].app.origin is correct");
-    is(results[0].app.isInBrowserElement, false, "navigator.sync.registrations()[0].app.isInBrowserElement is correct");
-    is(results[0].state, state, "navigator.sync.registrations()[0].state is correct");
-    is(results[0].overwrittenMinInterval, overwrittenMinInterval, "navigator.sync.registrations()[0].overwrittenMinInterval is correct");
-    ok("setPolicy" in results[0], "navigator.sync.registrations()[0].setPolicy is correct");
-    ok("runNow" in results[0], "navigator.sync.registrations()[0].runNow is correct");
-    runTests();
-  },
-  genericError.bind(null, 'managerRegistrations'));
-}
-
-function test_managerSetPolicy(state, overwrittenMinInterval) {
-  navigator.syncManager.registrations().then(
-  function(results) {
-    results[0].setPolicy(state, overwrittenMinInterval).then(
-    function() {
-      ok(state, results[0].state, "State matches");
-      ok(overwrittenMinInterval, results[0].overwrittenMinInterval, "OverwrittenMinInterval matches");
-      runTests();
-    }, genericError.bind(null, 'managerSetPolicy'));
-  }).catch(genericError.bind(null, 'managerSetPolicy_catch'));
-}
deleted file mode 100644
--- a/dom/requestsync/tests/file_app.sjs
+++ /dev/null
@@ -1,52 +0,0 @@
-var gBasePath = "tests/dom/requestsync/tests/";
-var gTemplate = "file_app.template.webapp";
-
-function handleRequest(request, response) {
-  var query = getQuery(request);
-
-  var testToken = '';
-  if ('testToken' in query) {
-    testToken = query.testToken;
-  }
-
-  var template = gBasePath + gTemplate;
-  response.setHeader("Content-Type", "application/x-web-app-manifest+json", false);
-  response.write(readTemplate(template).replace(/TESTTOKEN/g, testToken));
-}
-
-// Copy-pasted incantations. There ought to be a better way to synchronously read
-// a file into a string, but I guess we're trying to discourage that.
-function readTemplate(path) {
-  var file = Components.classes["@mozilla.org/file/directory_service;1"].
-                        getService(Components.interfaces.nsIProperties).
-                        get("CurWorkD", Components.interfaces.nsILocalFile);
-  var fis  = Components.classes['@mozilla.org/network/file-input-stream;1'].
-                        createInstance(Components.interfaces.nsIFileInputStream);
-  var cis = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
-                       createInstance(Components.interfaces.nsIConverterInputStream);
-  var split = path.split("/");
-  for(var i = 0; i < split.length; ++i) {
-    file.append(split[i]);
-  }
-  fis.init(file, -1, -1, false);
-  cis.init(fis, "UTF-8", 0, 0);
-
-  var data = "";
-  let str = {};
-  let read = 0;
-  do {
-    read = cis.readString(0xffffffff, str); // read as much as we can and put it in str.value
-    data += str.value;
-  } while (read != 0);
-  cis.close();
-  return data;
-}
-
-function getQuery(request) {
-  var query = {};
-  request.queryString.split('&').forEach(function (val) {
-    var [name, value] = val.split('=');
-    query[name] = unescape(value);
-  });
-  return query;
-}
deleted file mode 100644
--- a/dom/requestsync/tests/file_app.template.webapp
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-  "name": "Really Rapid Release (hosted)",
-  "description": "Updated even faster than <a href='http://mozilla.org'>Firefox</a>, just to annoy slashdotters.",
-  "launch_path": "/tests/dom/requestsync/tests/TESTTOKEN",
-  "icons": { "128": "default_icon" }
-}
deleted file mode 100644
--- a/dom/requestsync/tests/file_basic_app.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <script type="application/javascript" src="common_app.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <meta charset="utf-8">
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  function test_sync_interface() {
-    ok("sync" in navigator, "navigator.sync should exist with permissions");
-    ok(!("syncManager" in navigator), "navigator.syncManager should not exist without permissions");
-
-    ok("register" in navigator.sync, "navigator.sync.register exists");
-    ok("unregister" in navigator.sync, "navigator.sync.unregister exists");
-    ok("registrations" in navigator.sync, "navigator.sync.registrations exists");
-    ok("registration" in navigator.sync, "navigator.sync.registration exists");
-
-    runTests();
-  }
-
-  var tests = [
-    test_sync_interface,
-
-    test_registrationsEmpty,
-
-    test_registerFailure,
-    test_register,
-    // overwrite the same registration.
-    test_register,
-
-    test_registrations,
-
-    test_registrationEmpty,
-    test_registration,
-
-    test_unregister,
-    test_unregisterDuplicate,
-
-    test_registrationsEmpty,
-
-    // Let's keep a registration active when the app is uninstall...
-    test_register,
-    test_registrations
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  runTests();
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/file_interface.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <script type="application/javascript" src="common_app.js"></script>
-  <meta charset="utf-8">
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  ok("sync" in navigator, "navigator.sync should exist with permissions");
-  ok("register" in navigator.sync, "navigator.sync.register exists");
-  ok("unregister" in navigator.sync, "navigator.sync.unregister exists");
-  ok("registrations" in navigator.sync, "navigator.sync.registrations exists");
-  ok("registration" in navigator.sync, "navigator.sync.registration exists");
-
-  finish();
-
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/mochitest.ini
+++ /dev/null
@@ -1,25 +0,0 @@
-[DEFAULT]
-support-files =
-  file_app.template.webapp
-  file_app.sjs
-  file_basic_app.html
-  common_app.js
-  common_basic.js
-  system_message_chrome_script.js
-
-[test_webidl.html]
-skip-if = os == "android" || toolkit == "gonk"
-[test_minInterval.html]
-skip-if = os == "android" || toolkit == "gonk"
-[test_basic.html]
-skip-if = os == "android" || toolkit == "gonk"
-[test_basic_app.html]
-skip-if = buildapp != 'mulet' || e10s # mozapps
-[test_wakeUp.html]
-run-if = buildapp == 'b2g' && toolkit == 'gonk'
-[test_runNow.html]
-run-if = buildapp == 'b2g' && toolkit == 'gonk'
-[test_promise.html]
-skip-if = os == "android" || toolkit == "gonk"
-[test_bug1151082.html]
-skip-if = os == "android" || toolkit == "gonk"
deleted file mode 100644
--- a/dom/requestsync/tests/system_message_chrome_script.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-'use strict';
-
-var { classes: Cc, interfaces: Ci } = Components;
-
-const systemMessenger = Cc["@mozilla.org/system-message-internal;1"]
-                          .getService(Ci.nsISystemMessagesInternal);
-const ioService = Cc["@mozilla.org/network/io-service;1"]
-                    .getService(Ci.nsIIOService);
-
-addMessageListener("trigger-register-page", function(aData) {
-  systemMessenger.registerPage(aData.type,
-                               ioService.newURI(aData.pageURL, null, null),
-                               ioService.newURI(aData.manifestURL, null, null));
-  sendAsyncMessage("page-registered");
-});
deleted file mode 100644
--- a/dom/requestsync/tests/test_basic.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for RequestSync basic use</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-  <script type="application/javascript;version=1.7">
-
-
-  var tests = [
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1],
-                                         ["dom.ignore_webidl_scope_checks", true]]}, runTests);
-    },
-
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
-    },
-
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      runTests();
-    },
-
-    test_managerRegistrationsEmpty,
-    test_registrationsEmpty,
-
-    test_registerFailure,
-    test_register,
-    // overwrite the same registration.
-    test_register,
-
-    function() { test_managerRegistrations('wifiOnly', 0); },
-    test_registrations,
-
-    test_registrationEmpty,
-    test_registration,
-
-    function() { test_managerSetPolicy('disabled', 123); },
-    function() { test_managerRegistrations('disabled', 123); },
-
-    function() { test_managerSetPolicy('enabled', 42); },
-    function() { test_managerRegistrations('enabled', 42); },
-
-    test_unregister,
-    test_unregisterDuplicate,
-
-    test_managerRegistrationsEmpty,
-    test_registrationsEmpty,
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_basic_app.html
+++ /dev/null
@@ -1,130 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for requestSync - basic operations in app</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  var gHostedManifestURL = 'http://test/tests/dom/requestsync/tests/file_app.sjs?testToken=file_basic_app.html';
-  var gApp;
-
-  function cbError() {
-    ok(false, "Error callback invoked");
-    finish();
-  }
-
-  function installApp() {
-    var request = navigator.mozApps.install(gHostedManifestURL);
-    request.onerror = cbError;
-    request.onsuccess = function() {
-      gApp = request.result;
-      runTests();
-    }
-  }
-
-  function uninstallApp() {
-    // Uninstall the app.
-    var request = navigator.mozApps.mgmt.uninstall(gApp);
-    request.onerror = cbError;
-    request.onsuccess = function() {
-      // All done.
-      info("All done");
-      runTests();
-    }
-  }
-
-  function testApp() {
-    var ifr = document.createElement('iframe');
-    ifr.setAttribute('mozbrowser', 'true');
-    ifr.setAttribute('mozapp', gApp.manifestURL);
-    ifr.setAttribute('src', gApp.manifest.launch_path);
-    var domParent = document.getElementById('container');
-
-    // Set us up to listen for messages from the app.
-    var listener = function(e) {
-      var message = e.detail.message;
-      if (/^OK/.exec(message)) {
-        ok(true, "Message from app: " + message);
-      } else if (/KO/.exec(message)) {
-        ok(false, "Message from app: " + message);
-      } else if (/DONE/.exec(message)) {
-        ok(true, "Messaging from app complete");
-        ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
-        domParent.removeChild(ifr);
-        runTests();
-      }
-    }
-
-    // This event is triggered when the app calls "alert".
-    ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
-    domParent.appendChild(ifr);
-  }
-
-  var tests = [
-    // Permissions
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "browser", "allow": 1, "context": document },
-         { "type": "embed-apps", "allow": 1, "context": document },
-         { "type": "requestsync-manager", "allow": 1, "context": document },
-         { "type": "webapps-manage", "allow": 1, "context": document }], runTests);
-    },
-
-    // Preferences
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1],
-                                         ["dom.ignore_webidl_scope_checks", true],
-                                         ["dom.testing.ignore_ipc_principal", true]]}, runTests);
-    },
-
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      SpecialPowers.pushPrefEnv({"set":[["dom.mozBrowserFramesEnabled", true]]}, runTests);
-    },
-
-    // No confirmation needed when an app is installed
-    function() {
-      SpecialPowers.autoConfirmAppInstall(() =>
-        SpecialPowers.autoConfirmAppUninstall(runTests));
-    },
-
-    test_managerRegistrationsEmpty,
-
-    // Installing the app
-    installApp,
-
-    // Run tests in app
-    testApp,
-
-    // Uninstall the app
-    uninstallApp,
-
-    test_managerRegistrationsEmpty
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_bug1151082.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for RequestSync bug 1151082</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-  <script type="application/javascript;version=1.7">
-
-
-  var tests = [
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1],
-                                         ["dom.ignore_webidl_scope_checks", true]]}, runTests);
-    },
-
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
-    },
-
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      runTests();
-    },
-
-    function() {
-      counter = 2;
-      function registerCb() {
-        if (!--counter) {
-          ok(true, "All the registrations are done.");
-          runTests();
-        }
-      }
-
-      navigator.sync.register('foobar', { minInterval: 5, wakeUpPage:'/' }).then(registerCb, genericError);
-      navigator.sync.register('barfoo', { minInterval: 5, wakeUpPage:'/' }).then(registerCb, genericError);
-    },
-
-    function() {
-      counter = 2;
-      function unregisterCb() {
-        if (!--counter) {
-          ok(true, "All the unregistrations are done.");
-          runTests();
-        }
-      }
-
-      navigator.sync.unregister('foobar').then(unregisterCb, genericError);
-      navigator.sync.unregister('barfoo').then(unregisterCb, genericError);
-    }
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_minInterval.html
+++ /dev/null
@@ -1,69 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for RequestSync minInterval pref</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-  <script type="application/javascript;version=1.7">
-
-  function test_minInterval(expected) {
-    navigator.sync.register('foobar', { minInterval: 1, wakeUpPage: '/' }).then(
-    function() {
-      ok(expected, "MinInterval succeeded");
-    },
-    function(e) {
-      ok(!expected, "MinInterval failed");
-      is(e, "ParamsError", "Correct error received");
-    })
-
-    .then(function() {
-      if (expected) {
-        navigator.sync.unregister('foobar').then(runTests);
-      } else {
-        runTests();
-      }
-    });
-  }
-
-  var tests = [
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      runTests();
-    },
-
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.ignore_webidl_scope_checks", true],
-                                         ["dom.requestSync.enabled", true]]}, runTests);
-    },
-
-    function() { test_minInterval(false); },
-
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.minInterval", 1]]}, runTests);
-    },
-
-    function() { test_minInterval(true); },
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_promise.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for requestSync - promise</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["dom.sysmsg.enabled", true]]}, function() {
-
-  ok("mozSetMessageHandlerPromise" in navigator, "mozSetMessageHandlerPromise exists");
-
-  var status = false;
-  try {
-    navigator.mozSetMessageHandlerPromise();
-  } catch(e) {
-    status = true;
-  }
-  ok(status, "mozSetMessageHandlerPromise wants a promise 1");
-
-  status = false;
-  try {
-    navigator.mozSetMessageHandlerPromise(42);
-  } catch(e) {
-    status = true;
-  }
-  ok(status, "mozSetMessageHandlerPromise wants a promise 2");
-
-  status = false;
-  try {
-    navigator.mozSetMessageHandlerPromise("hello world");
-  } catch(e) {
-    status = true;
-  }
-  ok(status, "mozSetMessageHandlerPromise wants a promise 3");
-
-  status = false;
-  try {
-    navigator.mozSetMessageHandlerPromise(new Promise(function(a, b) {}));
-  } catch(e) {
-    info(e);
-    status = true;
-  }
-  ok(status, "mozSetMessageHandlerPromise cannot be called outside a messageHandler");
-  SimpleTest.finish();
-});
-
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_runNow.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for requestSync - runNow</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  var taskExecuted = false;
-
-  function registerPage() {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('system_message_chrome_script.js'));
-    gScript.addMessageListener("page-registered", function pageRegisteredHandler() {
-      gScript.removeMessageListener("page-registered", pageRegisteredHandler);
-      gScript.destroy();
-      runTests();
-    });
-
-    gScript.sendAsyncMessage("trigger-register-page",
-                             { type: "request-sync",
-                               manifestURL: window.location.origin + "/manifest.webapp",
-                               pageURL: window.location.href });
-  }
-
-  function setMessageHandler() {
-    navigator.mozSetMessageHandler('request-sync', function(e) {
-      ok(true, "One event has been received!");
-
-      if (e.task == "oneShot") {
-        is(e.data, 42, "e.data is correct");
-        is(e.lastSync, 0, "e.lastSync is correct");
-        is(e.oneShot, true, "e.oneShot is correct");
-        is(e.minInterval, 1024, "e.minInterval is correct");
-        is(e.wifiOnly, false, "e.wifiOnly is correct");
-        taskExecuted = true;
-      } else {
-        ok(false, "Unknown event has been received!");
-      }
-    });
-
-    runTests();
-  }
-
-  function test_register_oneShot() {
-    navigator.sync.register('oneShot', { minInterval: 1024,
-                                         oneShot: true,
-                                         data: 42,
-                                         wifiOnly: false,
-                                         wakeUpPage: location.href }).then(
-    function() {
-      ok(true, "navigator.sync.register() oneShot done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_unregister_oneShot() {
-    navigator.sync.unregister('oneShot').then(
-    function() {
-      ok(true, "navigator.sync.unregister() oneShot done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_runNow() {
-    navigator.syncManager.registrations().then(
-    function(array) {
-      for (var i = 0; i < array.length; ++i) { info(array[i].task); }
-      is(array.length, 1, "One registration found.");
-      array[0].runNow().then(function() {
-        ok(taskExecuted, "Task has been executed");
-        runTests();
-      });
-    }, genericError);
-  }
-
-  var tests = [
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.sysmsg.enabled", true],
-                                         ["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1],
-                                         ["dom.requestSync.maxTaskTimeout", 10000 /* 10 seconds */],
-                                         ["dom.ignore_webidl_scope_checks", true]]}, runTests);
-    },
-
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
-    },
-
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      runTests();
-    },
-
-    registerPage,
-
-    setMessageHandler,
-
-    test_register_oneShot,
-
-    test_runNow,
-
-    test_unregister_oneShot,
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      SimpleTest.finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_wakeUp.html
+++ /dev/null
@@ -1,187 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for requestSync - wakeUp</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common_basic.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  var oneShotCounter = 0;
-  var multiShotCounter = 0;
-
-  function maybeDone() {
-    if (oneShotCounter == 1 && multiShotCounter == 5) {
-      runTests();
-    }
-  }
-
-  function registerPage() {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('system_message_chrome_script.js'));
-    gScript.addMessageListener("page-registered", function pageRegisteredHandler() {
-      gScript.removeMessageListener("page-registered", pageRegisteredHandler);
-      gScript.destroy();
-      runTests();
-    });
-
-    gScript.sendAsyncMessage("trigger-register-page",
-                             { type: "request-sync",
-                               manifestURL: window.location.origin + "/manifest.webapp",
-                               pageURL: window.location.href });
-  }
-
-  function setMessageHandler() {
-    navigator.mozSetMessageHandler('request-sync', function(e) {
-      ok(true, "One event has been received!");
-
-      if (e.task == "oneShot") {
-        is(e.data, 42, "e.data is correct");
-        is(e.lastSync, 0, "e.lastSync is correct");
-        is(e.oneShot, true, "e.oneShot is correct");
-        is(e.minInterval, 2, "e.minInterval is correct");
-        is(e.wifiOnly, false, "e.wifiOnly is correct");
-
-        is(++oneShotCounter, 1, "Only 1 shot should be received here");
-        maybeDone();
-      }
-
-      else if (e.task == "multiShots") {
-        is(e.data, 'hello world!', "e.data is correct");
-
-        if (multiShotCounter == 0) {
-          is(e.lastSync, 0, "e.lastSync is correct");
-        } else {
-          isnot(e.lastSync, 0, "e.lastSync is correct");
-        }
-
-        is(e.oneShot, false, "e.oneShot is correct");
-        is(e.minInterval, 3, "e.minInterval is correct");
-        is(e.wifiOnly, false, "e.wifiOnly is correct");
-
-        ++multiShotCounter;
-
-        if (multiShotCounter == 1) {
-          info("Setting a promise object.");
-          navigator.mozSetMessageHandlerPromise(new Promise(function(a, b) {
-            setTimeout(a, 0);
-          }));
-        } else if (multiShotCounter == 2) {
-          // The second time we don't reply at all.
-          info("Setting a promise object without resolving it.");
-          navigator.mozSetMessageHandlerPromise(new Promise(function(a, b) {}));
-        } else if (multiShotCounter == 3) {
-          info("Throwing an exception.");
-          // Now we throw an exception
-          SimpleTest.expectUncaughtException();
-          throw "Booom!";
-        } else {
-          info("Setting a promise object and reject it.");
-          navigator.mozSetMessageHandlerPromise(new Promise(function(a, b) {
-            setTimeout(b, 0);
-          }));
-        }
-
-        maybeDone();
-      }
-
-      else {
-        ok(false, "Unknown event has been received!");
-      }
-    });
-
-    runTests();
-  }
-
-  function test_register_oneShot() {
-    navigator.sync.register('oneShot', { minInterval: 2,
-                                         oneShot: true,
-                                         data: 42,
-                                         wifiOnly: false,
-                                         wakeUpPage: location.href }).then(
-    function() {
-      ok(true, "navigator.sync.register() oneShot done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_register_multiShots() {
-    navigator.sync.register('multiShots', { minInterval: 3,
-                                            oneShot: false,
-                                            data: 'hello world!',
-                                            wifiOnly: false,
-                                            wakeUpPage: location.href }).then(
-    function() {
-      ok(true, "navigator.sync.register() multiShots done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_unregister_oneShot() {
-    navigator.sync.unregister('oneShot').then(
-    function() {
-      ok(true, "navigator.sync.unregister() oneShot done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_unregister_multiShots() {
-    navigator.sync.unregister('multiShots').then(
-    function() {
-      ok(true, "navigator.sync.unregister() multiShots done");
-      runTests();
-    }, genericError);
-  }
-
-  function test_wait() {
-    // nothing to do here.
-  }
-
-  var tests = [
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1],
-                                         ["dom.requestSync.maxTaskTimeout", 10000 /* 10 seconds */],
-                                         ["dom.ignore_webidl_scope_checks", true]]}, runTests);
-    },
-
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
-    },
-
-    function() {
-      SpecialPowers.importInMainProcess("resource://gre/modules/RequestSyncService.jsm");
-      runTests();
-    },
-
-    registerPage,
-    setMessageHandler,
-
-    test_register_oneShot,
-    test_register_multiShots,
-
-    test_wait,
-
-    test_unregister_oneShot,
-    test_unregister_multiShots,
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      SimpleTest.finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-  </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/requestsync/tests/test_webidl.html
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for RequestSync interfaces</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-  <script type="application/javascript;version=1.7">
-
-  function makeIframe() {
-    var iframe = document.createElement('iframe');
-    return document.body.appendChild(iframe);
-  }
-  function destroyIframe(iframe) {
-    iframe.remove();
-  }
-
-  function test_no_interface() {
-    var iframe = makeIframe();
-    ok(!("sync" in iframe.contentWindow.navigator), "navigator.sync should not exist without permissions");
-    ok(!("syncManager" in iframe.contentWindow.navigator), "navigator.syncManager should not exist without permissions");
-    destroyIframe(iframe);
-    runTests();
-  }
-
-  function test_sync(win) {
-    ok("register" in win.navigator.sync, "navigator.sync.register exists");
-    ok("unregister" in win.navigator.sync, "navigator.sync.unregister exists");
-    ok("registrations" in win.navigator.sync, "navigator.sync.registrations exists");
-    ok("registration" in win.navigator.sync, "navigator.sync.registration exists");
-  }
-
-  function test_sync_interface() {
-    var iframe = makeIframe();
-    ok("sync" in iframe.contentWindow.navigator, "navigator.sync should exist with permissions");
-    ok(!("syncManager" in iframe.contentWindow.navigator), "navigator.syncManager should not exist without permissions");
-
-    test_sync(iframe.contentWindow);
-    destroyIframe(iframe);
-    runTests();
-  }
-
-  function test_sync_manager_interface() {
-    var iframe = makeIframe();
-    ok("sync" in iframe.contentWindow.navigator, "navigator.sync should exist with permissions");
-    ok("syncManager" in iframe.contentWindow.navigator, "navigator.syncManager should exist with permissions");
-
-    test_sync(iframe.contentWindow);
-
-    ok("registrations" in iframe.contentWindow.navigator.syncManager, "navigator.syncManager.registrations exists");
-    destroyIframe(iframe);
-    runTests();
-  }
-
-  var tests = [
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", false]]}, runTests);
-    },
-
-    test_no_interface,
-
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.ignore_webidl_scope_checks", true]]}, runTests);
-    },
-
-    test_no_interface,
-
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
-                                         ["dom.requestSync.minInterval", 1]]}, runTests);
-    },
-
-    test_sync_interface,
-
-    // Permissions
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
-    },
-
-    test_sync_manager_interface,
-  ];
-
-  function runTests() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTests();
-  </script>
-</body>
-</html>
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -1294,22 +1294,16 @@ var interfaceNamesInGlobalScope =
     "SVGUseElement",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SVGViewElement",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SVGZoomAndPan",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SVGZoomEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "RequestSyncManager", b2g: true, permission: ["requestsync-manager"] },
-// IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "RequestSyncApp", b2g: true, permission: ["requestsync-manager"] },
-// IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "RequestSyncTask", b2g: true, permission: ["requestsync-manager"] },
-// IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "Telephony", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "TelephonyCall", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "TelephonyCallGroup", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "TelephonyCallId", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
deleted file mode 100644
--- a/dom/webidl/RequestSyncManager.webidl
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/.
- */
-
-[AvailableIn=CertifiedApps,
- Pref="dom.requestSync.enabled",
- CheckAnyPermissions="requestsync-manager",
- JSImplementation="@mozilla.org/dom/request-sync-task-app;1"]
-interface RequestSyncApp {
-  readonly attribute USVString origin;
-  readonly attribute USVString manifestURL;
-  readonly attribute boolean isInBrowserElement;
-};
-
-enum RequestSyncTaskPolicyState { "enabled", "disabled", "wifiOnly" };
-
-// Like a normal task, but with info about the app.
-[AvailableIn=CertifiedApps,
- Pref="dom.requestSync.enabled",
- CheckAnyPermissions="requestsync-manager",
- JSImplementation="@mozilla.org/dom/request-sync-task-manager;1"]
-interface RequestSyncTask {
-  // This object describes the app that is owning the task.
-  readonly attribute RequestSyncApp app;
-
-  // Using setPolicy it's possible to owerwrite the state and the minInterval.
-  readonly attribute RequestSyncTaskPolicyState state;
-  readonly attribute long overwrittenMinInterval;
-
-  // These attributes are taken from the configuration of the task:
-
-  readonly attribute USVString task;
-  readonly attribute DOMTimeStamp lastSync;
-  readonly attribute USVString wakeUpPage;
-  readonly attribute boolean oneShot;
-  readonly attribute long minInterval;
-  readonly attribute boolean wifiOnly;
-  readonly attribute any data;
-
-  Promise<void> setPolicy(RequestSyncTaskPolicyState aState,
-                          optional long ovewrittenMinInterval);
-
-  Promise<void> runNow();
-};
-
-[NavigatorProperty="syncManager",
- AvailableIn=CertifiedApps,
- Pref="dom.requestSync.enabled",
- CheckAnyPermissions="requestsync-manager",
- JSImplementation="@mozilla.org/dom/request-sync-manager;1"]
-// This interface will be used only by the B2G SystemApp
-interface RequestSyncManager {
-    Promise<sequence<RequestSyncTask>> registrations();
-};
deleted file mode 100644
--- a/dom/webidl/RequestSyncScheduler.webidl
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/.
- */
-
-// This is the dictionary for the creation of a new task.
-dictionary RequestTaskParams {
-  required USVString wakeUpPage;
-  boolean oneShot = true;
-  required long minInterval; // in seconds >= dom.requestSync.minInterval or 100 secs
-  boolean wifiOnly = true;
-  any data = null;
-};
-
-
-// This is the dictionary you can have back from registration{s}().
-dictionary RequestTaskFull : RequestTaskParams {
-  USVString task = "";
-
-  // Last synchonization date.. maybe it's useful to know.
-  DOMTimeStamp lastSync;
-};
-
-[NavigatorProperty="sync",
- AvailableIn=CertifiedApps,
- Pref="dom.requestSync.enabled",
- JSImplementation="@mozilla.org/dom/request-sync-scheduler;1"]
-interface RequestSyncScheduler {
-
-  Promise<void> register(USVString task,
-                         optional RequestTaskParams params);
-  Promise<void> unregister(USVString task);
-
-  // Useful methods to get registrations
-  Promise<sequence<RequestTaskFull>> registrations();
-  Promise<RequestTaskFull> registration(USVString task);
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -389,18 +389,16 @@ WEBIDL_FILES = [
     'PresentationReceiver.webidl',
     'PresentationRequest.webidl',
     'ProcessingInstruction.webidl',
     'ProfileTimelineMarker.webidl',
     'RadioNodeList.webidl',
     'Range.webidl',
     'Rect.webidl',
     'Request.webidl',
-    'RequestSyncManager.webidl',
-    'RequestSyncScheduler.webidl',
     'ResourceStats.webidl',
     'ResourceStatsManager.webidl',
     'Response.webidl',
     'RGBColor.webidl',
     'RTCStatsReport.webidl',
     'Screen.webidl',
     'ScreenOrientation.webidl',
     'ScriptProcessorNode.webidl',
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -61,17 +61,16 @@
 #include "nsMathMLOperators.h"
 #include "Navigator.h"
 #include "DOMStorageObserver.h"
 #include "CacheObserver.h"
 #include "DisplayItemClip.h"
 #include "ActiveLayerTracker.h"
 #include "CounterStyleManager.h"
 #include "FrameLayerBuilder.h"
-#include "mozilla/dom/RequestSyncWifiService.h"
 #include "AnimationCommon.h"
 #include "LayerAnimationInfo.h"
 
 #include "AudioChannelService.h"
 #include "mozilla/dom/PromiseDebugging.h"
 #include "mozilla/dom/WebCryptoThreadPool.h"
 
 #ifdef MOZ_XUL
@@ -298,20 +297,16 @@ nsLayoutStatics::Initialize()
   CounterStyleManager::InitializeBuiltinCounterStyles();
 
   CameraPreferences::Initialize();
 
   IMEStateManager::Init();
 
   ServiceWorkerRegistrar::Initialize();
 
-#ifdef MOZ_B2G
-  RequestSyncWifiService::Init();
-#endif
-
 #ifdef DEBUG
   nsStyleContext::Initialize();
   mozilla::LayerAnimationInfo::Initialize();
 #endif
 
   MediaDecoder::InitStatics();
 
   PromiseDebugging::Init();
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -257,19 +257,16 @@
 @BINPATH@/components/xpcom_xpti.xpt
 @BINPATH@/components/xpconnect.xpt
 @BINPATH@/components/xulapp.xpt
 @BINPATH@/components/xul.xpt
 @BINPATH@/components/xultmpl.xpt
 @BINPATH@/components/zipwriter.xpt
 
 ; JavaScript components
-@BINPATH@/components/RequestSync.manifest
-@BINPATH@/components/RequestSyncManager.js
-@BINPATH@/components/RequestSyncScheduler.js
 @BINPATH@/components/ChromeNotifications.js
 @BINPATH@/components/ChromeNotifications.manifest
 @BINPATH@/components/ConsoleAPI.manifest
 @BINPATH@/components/ConsoleAPIStorage.js
 @BINPATH@/components/ContactManager.js
 @BINPATH@/components/ContactManager.manifest
 @BINPATH@/components/PhoneNumberService.js
 @BINPATH@/components/PhoneNumberService.manifest
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5164,19 +5164,16 @@ pref("dom.mozSettings.allowForceReadOnly
 pref("browser.addon-watch.interval", 15000);
 #else
 pref("browser.addon-watch.interval", -1);
 #endif
 pref("browser.addon-watch.ignore", "[\"mochikit@mozilla.org\",\"special-powers@mozilla.org\",\"fxdevtools-adapters@mozilla.org\",\"fx-devtools\"]");
 // the percentage of time addons are allowed to use without being labeled slow
 pref("browser.addon-watch.percentage-limit", 5);
 
-// RequestSync API is disabled by default.
-pref("dom.requestSync.enabled", false);
-
 // Search service settings
 pref("browser.search.log", false);
 pref("browser.search.update", true);
 pref("browser.search.update.log", false);
 pref("browser.search.update.interval", 21600);
 pref("browser.search.suggest.enabled", true);
 pref("browser.search.geoSpecificDefaults", false);
 pref("browser.search.geoip.url", "https://location.services.mozilla.com/v1/country?key=%MOZILLA_API_KEY%");