author | Phil Ringnalda <philringnalda@gmail.com> |
Sun, 04 Jan 2015 08:40:27 -0800 | |
changeset 221962 | 636498d041b548b37c8b30b27d702852fb0064de |
parent 221961 | dc7317efb518884b0774ddbc9ff882784e9ff410 |
child 221963 | 6f64f1e85e7c7d29ceb343a745bfd9b4b9c0525c |
child 221974 | c094fd467a5179b226fdf3d34535fa6b109f9439 |
child 221979 | eece95bdb7d1e53c93c7c7be016fd977f3b216ba |
push id | 28051 |
push user | philringnalda@gmail.com |
push date | Sun, 04 Jan 2015 23:17:55 +0000 |
treeherder | mozilla-central@636498d041b5 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1018320 |
milestone | 37.0a1 |
backs out | 2ef1c26d77d3f892e385b828f0694a41a3740006 bce9ed290dddb7492cf3b333751589af21c4a563 8c01c134e40f0c73b8841e2210b17333944e4804 46353577ef7a88f1b3032e6ea04ac94d14b58f44 edf5737d6e0e7ead604d0b0cc7b15a33f3828150 c6fcdd1c681f960d875496b6bef09b7c7eab507c 5e26604cc6e03a3e0bfd49efddeffffc4b7dc442 |
first release with | nightly linux32
636498d041b5
/
37.0a1
/
20150105030202
/
files
nightly linux64
636498d041b5
/
37.0a1
/
20150105030202
/
files
nightly mac
636498d041b5
/
37.0a1
/
20150105030202
/
files
nightly win32
636498d041b5
/
37.0a1
/
20150105030202
/
files
nightly win64
636498d041b5
/
37.0a1
/
20150105030202
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
37.0a1
/
20150105030202
/
pushlog to previous
nightly linux64
37.0a1
/
20150105030202
/
pushlog to previous
nightly mac
37.0a1
/
20150105030202
/
pushlog to previous
nightly win32
37.0a1
/
20150105030202
/
pushlog to previous
nightly win64
37.0a1
/
20150105030202
/
pushlog to previous
|
--- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -10,17 +10,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'); #ifdef MOZ_WIDGET_GONK Cu.import('resource://gre/modules/NetworkStatsService.jsm'); Cu.import('resource://gre/modules/ResourceStatsService.jsm'); #endif // Identity Cu.import('resource://gre/modules/SignInToWebsite.jsm'); SignInToWebsiteController.init();
--- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -337,19 +337,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/BrowserElementParent.manifest @BINPATH@/components/BrowserElementParent.js @BINPATH@/components/ContactManager.js @BINPATH@/components/ContactManager.manifest
--- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -540,20 +540,16 @@ @RESPATH@/components/nsDOMIdentity.js @RESPATH@/components/nsIDService.js @RESPATH@/components/Identity.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/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1843,43 +1843,16 @@ Navigator::MozHasPendingMessage(const ns if (NS_FAILED(rv)) { aRv.Throw(rv); return false; } return result; } void -Navigator::MozSetMessageHandlerPromise(Promise& aPromise, - ErrorResult& aRv) -{ - // The WebIDL binding is responsible for the pref check here. - aRv = EnsureMessagesManager(); - if (NS_WARN_IF(aRv.Failed())) { - return; - } - - bool result = false; - aRv = mMessagesManager->MozIsHandlingMessage(&result); - if (NS_WARN_IF(aRv.Failed())) { - return; - } - - if (!result) { - aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); - return; - } - - aRv = mMessagesManager->MozSetMessageHandlerPromise(&aPromise); - if (NS_WARN_IF(aRv.Failed())) { - return; - } -} - -void Navigator::MozSetMessageHandler(const nsAString& aType, systemMessageCallback* aCallback, ErrorResult& aRv) { // The WebIDL binding is responsible for the pref check here. nsresult rv = EnsureMessagesManager(); if (NS_FAILED(rv)) { aRv.Throw(rv);
--- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -230,18 +230,16 @@ public: TVManager* GetTv(); network::Connection* GetConnection(ErrorResult& aRv); nsDOMCameraManager* GetMozCameras(ErrorResult& aRv); MediaDevices* GetMediaDevices(ErrorResult& aRv); void MozSetMessageHandler(const nsAString& aType, systemMessageCallback* aCallback, ErrorResult& aRv); bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv); - void MozSetMessageHandlerPromise(Promise& aPromise, ErrorResult& aRv); - #ifdef MOZ_B2G already_AddRefed<Promise> GetMobileIdAssertion(const MobileIdOptions& options, ErrorResult& aRv); #endif #ifdef MOZ_B2G_RIL MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv); IccManager* GetMozIccManager(ErrorResult& aRv); #endif // MOZ_B2G_RIL
--- a/dom/messages/SystemMessageInternal.js +++ b/dom/messages/SystemMessageInternal.js @@ -41,17 +41,16 @@ try { const kMessages =["SystemMessageManager:GetPendingMessages", "SystemMessageManager:HasPendingMessages", "SystemMessageManager:Register", "SystemMessageManager:Unregister", "SystemMessageManager:Message:Return:OK", "SystemMessageManager:AskReadyToRegister", "SystemMessageManager:HandleMessagesDone", - "SystemMessageManager:HandleMessageDone", "child-process-shutdown"] function debug(aMsg) { // dump("-- SystemMessageInternal " + Date.now() + " : " + aMsg + "\n"); } let defaultMessageConfigurator = { @@ -80,18 +79,16 @@ function SystemMessageInternal() { this._webappsRegistryReady = false; this._bufferedSysMsgs = []; this._cpuWakeLocks = {}; this._configurators = {}; - this._pendingPromises = new Map(); - Services.obs.addObserver(this, "xpcom-shutdown", false); Services.obs.addObserver(this, "webapps-registry-start", false); Services.obs.addObserver(this, "webapps-registry-ready", false); Services.obs.addObserver(this, "webapps-clear-data", false); kMessages.forEach(function(aMsg) { ppmm.addMessageListener(aMsg, this); }, this); @@ -174,48 +171,33 @@ SystemMessageInternal.prototype = { page = aPage; } return page !== null; }, this); return page; }, sendMessage: function(aType, aMessage, aPageURI, aManifestURI, aExtra) { - return new Promise((aResolve, aReject) => { - this.sendMessageInternal(aType, aMessage, aPageURI, aManifestURI, aExtra, - aResolve, aReject); - }); - }, - - sendMessageInternal: function(aType, aMessage, aPageURI, aManifestURI, - aExtra, aResolvePromiseCb, aRejectPromiseCb) { // Buffer system messages until the webapps' registration is ready, // so that we can know the correct pages registered to be sent. if (!this._webappsRegistryReady) { this._bufferedSysMsgs.push({ how: "send", type: aType, msg: aMessage, pageURI: aPageURI, manifestURI: aManifestURI, - extra: aExtra, - resolvePromiseCb: aResolvePromiseCb, - rejectPromiseCb: aRejectPromiseCb }); + extra: aExtra }); return; } // Give this message an ID so that we can identify the message and // clean it up from the pending message queue when apps receive it. let messageID = gUUIDGenerator.generateUUID().toString(); + let manifestURL = aManifestURI.spec; - - let pendingPromise = { resolvePromiseCb: aResolvePromiseCb, - rejectPromiseCb: aRejectPromiseCb, - manifestURL: manifestURL, - counter: 0 }; - let pageURLs = []; if (aPageURI) { pageURLs.push(aPageURI.spec); } else { // Send this message to all the registered pages of the app if |aPageURI| // is not specified. for (let i = 0; i < this._pages.length; i++) { let page = this._pages[i]; @@ -239,32 +221,24 @@ SystemMessageInternal.prototype = { debug("Returned status of sending message: " + result); // Don't need to open the pages and queue the system message // which was not allowed to be sent. if (result === MSG_SENT_FAILURE_PERM_DENIED) { return; } - // For each page we must receive a confirm. - ++pendingPromise.counter; - let page = this._findPage(aType, aPageURL, manifestURL); if (page) { // Queue this message in the corresponding pages. this._queueMessage(page, aMessage, messageID); this._openAppPage(page, aMessage, aExtra, result); } - }, this); - - if (pendingPromise.counter) { - this._pendingPromises.set(messageID, pendingPromise); - } }, broadcastMessage: function(aType, aMessage, aExtra) { // Buffer system messages until the webapps' registration is ready, // so that we can know the correct pages registered to be broadcasted. if (!this._webappsRegistryReady) { this._bufferedSysMsgs.push({ how: "broadcast", type: aType, @@ -414,18 +388,17 @@ SystemMessageInternal.prototype = { // To prevent the hacked child process from sending commands to parent // to manage system messages, we need to check its manifest URL. if (["SystemMessageManager:Register", // TODO: fix bug 988142 to re-enable. // "SystemMessageManager:Unregister", "SystemMessageManager:GetPendingMessages", "SystemMessageManager:HasPendingMessages", "SystemMessageManager:Message:Return:OK", - "SystemMessageManager:HandleMessagesDone", - "SystemMessageManager:HandleMessageDone"].indexOf(aMessage.name) != -1) { + "SystemMessageManager:HandleMessagesDone"].indexOf(aMessage.name) != -1) { if (!aMessage.target.assertContainApp(msg.manifestURL)) { debug("Got message from a child process containing illegal manifest URL."); return null; } } switch(aMessage.name) { case "SystemMessageManager:AskReadyToRegister": @@ -464,30 +437,27 @@ SystemMessageInternal.prototype = { { debug("Got child-process-shutdown from " + aMessage.target); for (let manifestURL in this._listeners) { // See if any processes in this manifest URL have this target. this._removeTargetFromListener(aMessage.target, manifestURL, true, null); - - this._rejectPendingPromisesFromManifestURL(manifestURL); } break; } case "SystemMessageManager:Unregister": { debug("Got Unregister from " + aMessage.target + " innerWinID " + msg.innerWindowID); this._removeTargetFromListener(aMessage.target, msg.manifestURL, false, msg.pageURL); - this._rejectPendingPromisesFromManifestURL(msg.manifestURL); break; } case "SystemMessageManager:GetPendingMessages": { debug("received SystemMessageManager:GetPendingMessages " + msg.type + " for " + msg.pageURL + " @ " + msg.manifestURL); // This is a sync call used to return the pending messages for a page. @@ -545,35 +515,16 @@ SystemMessageInternal.prototype = { if (pendingMessages[i].msgID === msg.msgID) { pendingMessages.splice(i, 1); break; } } } break; } - case "SystemMessageManager:HandleMessageDone": - { - debug("received SystemMessageManager:HandleMessageDone " + msg.type + - " with msgID " + msg.msgID + " for " + msg.pageURL + - " @ " + msg.manifestURL + " - promise rejected: " + msg.rejected); - - // Maybe this should resolve/reject a pending promise. - if (msg.rejected) { - this._rejectPendingPromises(msg.msgID); - } else { - this._resolvePendingPromises(msg.msgID); - } - - // A page has finished handling some of its system messages, so we try - // to release the CPU wake lock we acquired on behalf of that page. - this._releaseCpuWakeLock(this._createKeyForPage(msg), 1); - break; - } - case "SystemMessageManager:HandleMessagesDone": { debug("received SystemMessageManager:HandleMessagesDone " + msg.type + " with " + msg.handledCount + " for " + msg.pageURL + " @ " + msg.manifestURL); // A page has finished handling some of its system messages, so we try // to release the CPU wake lock we acquired on behalf of that page. @@ -591,32 +542,30 @@ SystemMessageInternal.prototype = { }, this); Services.obs.removeObserver(this, "xpcom-shutdown"); Services.obs.removeObserver(this, "webapps-registry-start"); Services.obs.removeObserver(this, "webapps-registry-ready"); Services.obs.removeObserver(this, "webapps-clear-data"); ppmm = null; this._pages = null; this._bufferedSysMsgs = null; - this._pendingPromises.clear(); break; case "webapps-registry-start": this._webappsRegistryReady = false; break; case "webapps-registry-ready": // After the webapps' registration has been done for sure, // re-fire the buffered system messages if there is any. this._webappsRegistryReady = true; this._bufferedSysMsgs.forEach(function(aSysMsg) { switch (aSysMsg.how) { case "send": - this.sendMessageInternal( + this.sendMessage( aSysMsg.type, aSysMsg.msg, - aSysMsg.pageURI, aSysMsg.manifestURI, aSysMsg.extra, - aSysMsg.resolvePromiseCb, aSysMsg.rejectPromiseCb); + aSysMsg.pageURI, aSysMsg.manifestURI, aSysMsg.extra); break; case "broadcast": this.broadcastMessage(aSysMsg.type, aSysMsg.msg, aSysMsg.extra); break; } }, this); this._bufferedSysMsgs.length = 0; break; @@ -642,19 +591,16 @@ SystemMessageInternal.prototype = { for (let i = this._pages.length - 1; i >= 0; i--) { let page = this._pages[i]; if (page.manifestURL === manifestURL) { this._pages.splice(i, 1); debug("Remove " + page.pageURL + " @ " + page.manifestURL + " from registered pages due to app uninstallation."); } } - - this._rejectPendingPromisesFromManifestURL(manifestURL); - debug("Finish updating registered pages for an uninstalled app."); break; } }, _queueMessage: function(aPage, aMessage, aMessageID) { // Queue the message for this page because we've never known if an app is // opened or not. We'll clean it up when the app has already received it. @@ -741,20 +687,19 @@ SystemMessageInternal.prototype = { // which contain the window page that matches the manifest/page URL of // the destination of system message. if (target.winCounts[aPageURL] === undefined) { continue; } appPageIsRunning = true; // We need to acquire a CPU wake lock for that page and expect that - // we'll receive a "SystemMessageManager:HandleMessagesDone" or a - // "SystemMessageManager:HandleMessageDone" message when the page - // finishes handling the system message. At that point, we'll release - // the lock we acquired. + // we'll receive a "SystemMessageManager:HandleMessagesDone" message + // when the page finishes handling the system message. At that point, + // we'll release the lock we acquired. this._acquireCpuWakeLock(pageKey); // Multiple windows can share the same target (process), the content // window needs to check if the manifest/page URL is matched. Only // *one* window should handle the system message. let manager = target.target; manager.sendAsyncMessage("SystemMessageManager:Message", { type: aType, @@ -764,61 +709,25 @@ SystemMessageInternal.prototype = { msgID: aMessageID }); } } if (!appPageIsRunning) { // The app page isn't running and relies on the 'open-app' chrome event to // wake it up. We still need to acquire a CPU wake lock for that page and // expect that we will receive a "SystemMessageManager:HandleMessagesDone" - // or a "SystemMessageManager:HandleMessageDone" message when the page - // finishes handling the system message with other pending messages. At - // that point, we'll release the lock we acquired. + // message when the page finishes handling the system message with other + // pending messages. At that point, we'll release the lock we acquired. this._acquireCpuWakeLock(pageKey); return MSG_SENT_FAILURE_APP_NOT_RUNNING; } else { return MSG_SENT_SUCCESS; } }, - _resolvePendingPromises: function(aMessageID) { - if (!this._pendingPromises.has(aMessageID)) { - debug("Unknown pendingPromise messageID. This seems a bug!!"); - return; - } - - let obj = this._pendingPromises.get(aMessageID); - if (!--obj.counter) { - obj.resolvePromiseCb(); - this._pendingPromises.delete(aMessageID); - } - }, - - _rejectPendingPromises: function(aMessageID) { - if (!this._pendingPromises.has(aMessageID)) { - debug("Unknown pendingPromise messageID. This seems a bug!!"); - return; - } - - let obj = this._pendingPromises.get(aMessageID); - if (!--obj.counter) { - obj.rejectPromiseCb(); - this._pendingPromises.delete(aMessageID); - } - }, - - _rejectPendingPromisesFromManifestURL: function(aManifestURL) { - for (var [i, obj] of this._pendingPromises) { - if (obj.manifestURL == aManifestURL) { - obj.rejectPromiseCb(); - this._pendingPromises.delete(i); - } - } - }, - classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"), QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal, Ci.nsIObserver]) } this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageInternal]);
--- a/dom/messages/SystemMessageManager.js +++ b/dom/messages/SystemMessageManager.js @@ -37,50 +37,45 @@ function SystemMessageManager() { this._dispatchers = {}; // Pending messages for this page, keyed by message type. this._pendings = {}; // Flag to specify if this process has already registered the manifest URL. this._registerManifestURLReady = false; - // Used to know if the promise has to be accepted or not. - this._isHandling = false; - this._promise = null; - // Flag to determine this process is a parent or child process. let appInfo = Cc["@mozilla.org/xre/app-info;1"]; this._isParentProcess = !appInfo || appInfo.getService(Ci.nsIXULRuntime) .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; // An oberver to listen to whether the |SystemMessageInternal| is ready. if (this._isParentProcess) { Services.obs.addObserver(this, kSystemMessageInternalReady, false); } } SystemMessageManager.prototype = { __proto__: DOMRequestIpcHelper.prototype, - _dispatchMessage: function(aType, aDispatcher, aMessage, aMessageID) { + _dispatchMessage: function(aType, aDispatcher, aMessage) { if (aDispatcher.isHandling) { // Queue up the incomming message if we're currently dispatching a // message; we'll send the message once we finish with the current one. // // _dispatchMethod is reentrant because a page can spin up a nested // event loop from within a system message handler (e.g. via alert()), // and we can then try to send the page another message while it's // inside this nested event loop. - aDispatcher.messages.push({ message: aMessage, messageID: aMessageID }); + aDispatcher.messages.push(aMessage); return; } aDispatcher.isHandling = true; - this._isHandling = true; // We get a json blob, but in some cases we want another kind of object // to be dispatched. To do so, we check if we have a valid contract ID of // "@mozilla.org/dom/system-messages/wrapper/TYPE;1" component implementing // nsISystemMessageWrapper. debug("Dispatching " + JSON.stringify(aMessage) + "\n"); let contractID = "@mozilla.org/dom/system-messages/wrapper/" + aType + ";1"; let wrapped = false; @@ -90,56 +85,32 @@ SystemMessageManager.prototype = { let wrapper = Cc[contractID].createInstance(Ci.nsISystemMessagesWrapper); if (wrapper) { aMessage = wrapper.wrapMessage(aMessage, this._window); wrapped = true; debug("wrapped = " + aMessage); } } - let message = wrapped ? aMessage : Cu.cloneInto(aMessage, this._window); + aDispatcher.handler + .handleMessage(wrapped ? aMessage + : Cu.cloneInto(aMessage, this._window)); - let rejectPromise = false; - try { - aDispatcher.handler.handleMessage(message); - } catch(e) { - rejectPromise = true; - } + // We need to notify the parent one of the system messages has been handled, + // so the parent can release the CPU wake lock it took on our behalf. + cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone", + { type: aType, + manifestURL: this._manifestURL, + pageURL: this._pageURL, + handledCount: 1 }); aDispatcher.isHandling = false; - this._isHandling = false; - - let self = this; - function sendResponse() { - // We need to notify the parent one of the system messages has been - // handled, so the parent can release the CPU wake lock it took on our - // behalf. - cpmm.sendAsyncMessage("SystemMessageManager:HandleMessageDone", - { type: aType, - manifestURL: self._manifestURL, - pageURL: self._pageURL, - msgID: aMessageID, - rejected: rejectPromise }); - } - - if (!this._promise) { - debug("No promise set, sending the response immediately"); - sendResponse(); - } else { - debug("Using the promise to postpone the response."); - this._promise.then(sendResponse, function() { - rejectPromise = true; - sendResponse(); - }); - this._promise = null; - } if (aDispatcher.messages.length > 0) { - let msg = aDispatcher.messages.shift(); - this._dispatchMessage(aType, aDispatcher, msg.message, msg.messageID); + this._dispatchMessage(aType, aDispatcher, aDispatcher.messages.shift()); } else { // No more messages that need to be handled, we can notify the // ContentChild to release the CPU wake lock grabbed by the ContentParent // (i.e. NewWakeLockOnBehalfOfProcess()) and reset the process's priority. // // TODO: Bug 874353 - Remove SystemMessageHandledListener in ContentParent Services.obs.notifyObservers(/* aSubject */ null, "handle-system-messages-done", @@ -194,35 +165,19 @@ SystemMessageManager.prototype = { } return cpmm.sendSyncMessage("SystemMessageManager:HasPendingMessages", { type: aType, pageURL: this._pageURL, manifestURL: this._manifestURL })[0]; }, - mozIsHandlingMessage: function() { - debug("is handling message: " + this._isHandling); - return this._isHandling; - }, - - mozSetMessageHandlerPromise: function(aPromise) { - debug("setting a promise"); - - if (!this._isHandling) { - throw "Not in a handleMessage method"; - } - - this._promise = aPromise; - }, - uninit: function() { this._dispatchers = null; this._pendings = null; - this._promise = null; if (this._isParentProcess) { Services.obs.removeObserver(this, kSystemMessageInternalReady); } if (this._isInBrowserElement) { debug("the app loaded in the browser doesn't need to unregister " + "the manifest URL for listening to the system messages"); @@ -276,19 +231,18 @@ SystemMessageManager.prototype = { cpmm.sendAsyncMessage("SystemMessageManager:Message:Return:OK", { type: msg.type, manifestURL: this._manifestURL, pageURL: this._pageURL, msgID: msg.msgID }); } messages.forEach(function(aMsg) { - this._dispatchMessage(msg.type, dispatcher, aMsg, msg.msgID); + this._dispatchMessage(msg.type, dispatcher, aMsg); }, this); - } else { // Since no handlers are registered, we need to notify the parent as if // all the queued system messages have been handled (notice |handledCount: // messages.length|), so the parent can release the CPU wake lock it took // on our behalf. cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone", { type: msg.type, manifestURL: this._manifestURL,
--- a/dom/messages/SystemMessagePermissionsChecker.jsm +++ b/dom/messages/SystemMessagePermissionsChecker.jsm @@ -79,17 +79,16 @@ this.SystemMessagePermissionsTable = { "desktop-notification": [] }, "push": { "push": [] }, "push-register": { "push": [] }, - "request-sync": { }, "sms-delivery-success": { "sms": [] }, "sms-read-success": { "sms": [] }, "sms-received": { "sms": []
--- a/dom/messages/interfaces/nsIDOMNavigatorSystemMessages.idl +++ b/dom/messages/interfaces/nsIDOMNavigatorSystemMessages.idl @@ -5,20 +5,15 @@ #include "domstubs.idl" [scriptable, function, uuid(42692976-57fd-4bb4-ab95-2b97ebdc5056)] interface nsIDOMSystemMessageCallback : nsISupports { void handleMessage(in jsval message); }; -[scriptable, uuid(d04d3c11-26aa-46eb-a981-353af101f9cf)] +[scriptable, uuid(091e90dd-0e8b-463d-8cdc-9225d3a6ff90)] interface nsIDOMNavigatorSystemMessages : nsISupports { void mozSetMessageHandler(in DOMString type, in nsIDOMSystemMessageCallback callback); boolean mozHasPendingMessage(in DOMString type); - - // the parameter is a promise object. - void mozSetMessageHandlerPromise(in nsISupports promise); - - bool mozIsHandlingMessage(); };
--- a/dom/messages/interfaces/nsISystemMessagesInternal.idl +++ b/dom/messages/interfaces/nsISystemMessagesInternal.idl @@ -4,34 +4,31 @@ #include "domstubs.idl" interface nsIURI; interface nsIDOMWindow; // Implemented by the contract id @mozilla.org/system-message-internal;1 -[scriptable, uuid(54c8e274-decb-4258-9a24-4ebfcbf3d00a)] +[scriptable, uuid(6296a314-2abf-4cd0-9097-5e81ee6832e2)] interface nsISystemMessagesInternal : nsISupports { /* * Allow any internal user to send a message of a given type to a given page * of an app. The message will be sent to all the registered pages of the app * when |pageURI| is not specified. * @param type The type of the message to be sent. * @param message The message payload. * @param pageURI The URI of the page that will be opened. Nullable. * @param manifestURI The webapp's manifest URI. * @param extra Extra opaque information that will be passed around in the observer * notification to open the page. - * returns a Promise */ - nsISupports sendMessage(in DOMString type, in jsval message, - in nsIURI pageURI, in nsIURI manifestURI, - [optional] in jsval extra); + void sendMessage(in DOMString type, in jsval message, in nsIURI pageURI, in nsIURI manifestURI, [optional] in jsval extra); /* * Allow any internal user to broadcast a message of a given type. * The application that registers the message will be launched. * @param type The type of the message to be sent. * @param message The message payload. * @param extra Extra opaque information that will be passed around in the observer * notification to open the page.
--- a/dom/moz.build +++ b/dom/moz.build @@ -38,17 +38,16 @@ interfaces = [ DIRS += ['interfaces/' + i for i in interfaces] DIRS += [ 'animation', 'apps', 'base', 'activities', 'archivereader', - 'requestsync', 'bindings', 'battery', 'browser-element', 'canvas', 'cellbroadcast', 'contacts', 'crypto', 'phonenumberutils',
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,124 +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" ], - - init: function(aWindow) { - debug("init"); - - // DOMRequestIpcHelper.initHelper sets this._window - this.initDOMRequestHelper(aWindow, this._messages); - }, - - sendMessage: function(aMsg, aObj) { - let self = this; - return this.createPromise(function(aResolve, aReject) { - aObj.requestID = - self.getPromiseResolverId({ resolve: aResolve, reject: aReject }); - cpmm.sendAsyncMessage(aMsg, aObj, null, - self._window.document.nodePrincipal); - }); - }, - - registrations: function() { - debug('registrations'); - return this.sendMessage("RequestSyncManager:Registrations", {}); - }, - - setPolicy: function(aTask, aOrigin, aManifestURL, aIsInBrowserElement, - aState, aOverwrittenMinInterval) { - debug('setPolicy'); - - return this.sendMessage("RequestSyncManager:SetPolicy", - { task: aTask, - origin: aOrigin, - manifestURL: aManifestURL, - isInBrowserElement: aIsInBrowserElement, - state: aState, - overwrittenMinInterval: aOverwrittenMinInterval }); - }, - - 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,101 +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.createPromise(function(aResolve, aReject) { - aObj.requestID = - self.getPromiseResolverId({ resolve: aResolve, reject: aReject }); - 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,849 +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"); - -this.RequestSyncService = { - __proto__: IndexedDBHelper.prototype, - - children: [], - - _messages: [ "RequestSync:Register", - "RequestSync:Unregister", - "RequestSync:Registrations", - "RequestSync:Registration", - "RequestSyncManager:Registrations", - "RequestSyncManager:SetPolicy" ], - - _pendingOperation: false, - _pendingMessages: [], - - _registrations: {}, - - _wifi: false, - - _activeTask: null, - _queuedTasks: [], - - // Initialization of the RequestSyncService. - init: function() { - debug("init"); - - this._messages.forEach((function(msgName) { - ppmm.addMessageListener(msgName, this); - }).bind(this)); - - Services.obs.addObserver(this, 'xpcom-shutdown', false); - Services.obs.addObserver(this, 'webapps-clear-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. - - let self = this; - this.dbTxn("readonly", function(aStore) { - aStore.openCursor().onsuccess = function(event) { - let cursor = event.target.result; - if (cursor) { - self.addRegistration(cursor.value); - cursor.continue(); - } - } - }, - 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, 'webapps-clear-data'); - Services.obs.removeObserver(this, 'wifi-state-changed'); - - this.close(); - - // Removing all the registrations will delete the pending timers. - let self = this; - this.forEachRegistration(function(aObj) { - let key = self.principalToKey(aObj.principal); - self.removeRegistrationInternal(aObj.data.task, key); - }); - }, - - observe: function(aSubject, aTopic, aData) { - debug("observe"); - - switch (aTopic) { - case 'xpcom-shutdown': - this.shutdown(); - break; - - case 'webapps-clear-data': - this.clearData(aSubject); - break; - - case 'wifi-state-changed': - this.wifiStateChanged(aSubject == 'enabled'); - 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 params = - aData.QueryInterface(Ci.mozIApplicationClearPrivateDataParams); - if (!params) { - return; - } - - // At this point we don't have the origin, so we cannot create the full - // key. Using the partial one is enough to detect the uninstalled app. - var partialKey = params.appId + '|' + params.browserOnly + '|'; - var dbKeys = []; - - for (let key in this._registrations) { - if (key.indexOf(partialKey) != 0) { - 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.appId + '|' + - aPrincipal.isInBrowserElement + '|' + - aPrincipal.origin; - }, - - // Add a task to the _registrations map and create the timer if it's needed. - addRegistration: function(aObj) { - debug('addRegistration'); - - let key = this.principalToKey(aObj.principal); - if (!(key in this._registrations)) { - this._registrations[key] = {}; - } - - this.scheduleTimer(aObj); - this._registrations[key][aObj.data.task] = aObj; - }, - - // 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]; - if (obj.timer) { - obj.timer.cancel(); - } - - // 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 (var 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. - if (!aMessage.principal) { - return; - } - - let uri = Services.io.newURI(aMessage.principal.origin, null, null); - - let principal; - try { - principal = secMan.getAppCodebasePrincipal(uri, - aMessage.principal.appId, aMessage.principal.isInBrowserElement); - } catch(e) { - return; - } - - if (!principal) { - return; - } - - switch (aMessage.name) { - case "RequestSync:Register": - this.register(aMessage.target, aMessage.data, principal); - break; - - case "RequestSync:Unregister": - this.unregister(aMessage.target, aMessage.data, principal); - break; - - case "RequestSync:Registrations": - this.registrations(aMessage.target, aMessage.data, principal); - break; - - case "RequestSync:Registration": - this.registration(aMessage.target, aMessage.data, principal); - break; - - case "RequestSyncManager:Registrations": - this.managerRegistrations(aMessage.target, aMessage.data, principal); - break; - - case "RequestSyncManager:SetPolicy": - this.managerSetPolicy(aMessage.target, aMessage.data, principal); - 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 + "|" + - aPrincipal.appId + '|' + - aPrincipal.isInBrowserElement + '|' + - aPrincipal.origin; - - let data = { principal: aPrincipal, - dbKey: dbKey, - data: aData.params, - active: true, - timer: null }; - - let self = this; - this.dbTxn('readwrite', function(aStore) { - aStore.put(data, data.dbKey); - }, - function() { - self.addRegistration(data); - 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.principal.isInBrowserElement != aData.isInBrowserElement || - aObj.principal.origin != 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); - aTarget.sendAsyncMessage("RequestSyncManager:SetPolicy:Return", - { requestID: aData.requestID }); - }); - }, - - // 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.origin, - isInBrowserElement: aObj.principal.isInBrowserElement }; - - 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) { - debug("scheduleTimer"); - - if (aObj.timer) { - aObj.timer.cancel(); - aObj.timer = null; - } - - // A registration can be already inactive if it was 1 shot. - if (!aObj.active) { - return; - } - - if (aObj.data.state == RSYNC_STATE_DISABLED) { - return; - } - - // WifiOnly check. - if (aObj.data.state == RSYNC_STATE_WIFIONLY && !this._wifi) { - return; - } - - aObj.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - - let interval = aObj.data.minInterval; - if (aObj.data.overwrittenMinInterval > 0) { - interval = aObj.data.overwrittenMinInterval; - } - - let self = this; - aObj.timer.initWithCallback(function() { self.timeout(aObj); }, - interval * 1000, - Ci.nsITimer.TYPE_ONE_SHOT); - }, - - timeout: function(aObj) { - 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); - } - 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); - 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); - return; - } - - aObj.timer = null; - this._activeTask = aObj; - - if (!manifestURL || !pageURL) { - dump("ERROR!! RequestSyncService - Failed to create URI for the page or the manifest\n"); - aObj.active = false; - this.updateObjectInDB(aObj); - return; - } - - // 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); - - let done = false; - let self = this; - function taskCompleted() { - debug("promise or timeout for task calls taskCompleted"); - - if (!done) { - done = true; - self.operationCompleted(); - } - - 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() { - debug("operationCompleted"); - - if (!this._activeTask) { - dump("ERROR!! RequestSyncService - OperationCompleted called without an active task\n"); - return; - } - - // One shot? Then this is not active. - this._activeTask.active = !this._activeTask.data.oneShot; - this._activeTask.data.lastSync = new Date(); - - let self = this; - this.updateObjectInDB(this._activeTask, function() { - // SchedulerTimer creates a timer and a nsITimer cannot be cloned. This - // is the reason why this operation has to be done after storing the task - // into IDB. - if (!self._activeTask.data.oneShot) { - self.scheduleTimer(self._activeTask); - } - - self.processNextTask(); - }); - }, - - processNextTask: function() { - debug("processNextTask"); - - this._activeTask = null; - - if (this._queuedTasks.length == 0) { - return; - } - - let task = this._queuedTasks.shift(); - this.timeout(task); - }, - - 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.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 (var key in this._registrations) { - for (var task in this._registrations[key]) { - list.push(this._registrations[key][task]); - } - } - - for (var 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. - let self = this; - this.forEachRegistration(function(aObj) { - if (aObj.data.state == RSYNC_STATE_WIFIONLY && aObj.timer) { - aObj.timer.cancel(); - aObj.timer = null; - - // It can be that this task has been already schedulated. - self.removeTaskFromQueue(aObj); - } - }); - return; - } - - // Enable all the tasks. - let self = this; - this.forEachRegistration(function(aObj) { - if (aObj.active && !aObj.timer) { - if (!aObj.data.wifiOnly) { - dump("ERROR - Found a disabled task that is not wifiOnly."); - } - - self.scheduleTimer(aObj); - } - }); - } -} - -RequestSyncService.init(); - -this.EXPORTED_SYMBOLS = [""];
deleted file mode 100644 --- a/dom/requestsync/RequestSyncTask.jsm +++ /dev/null @@ -1,101 +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); - }); - } -};
deleted file mode 100644 --- a/dom/requestsync/RequestSyncWifiService.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ -/* vim: set ts=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; - -} // anonymous namespace - -/* static */ void -RequestSyncWifiService::Init() -{ - nsRefPtr<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); - } - - nsRefPtr<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")); - } -} - -} // dom namespace -} // mozilla namespace
deleted file mode 100644 --- a/dom/requestsync/RequestSyncWifiService.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ -/* vim: set ts=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 MOZ_FINAL : public nsISupports - , public NetworkObserver -{ -public: - NS_DECL_ISUPPORTS - - static void Init(); - - static already_AddRefed<RequestSyncWifiService> GetInstance(); - - void Notify(const hal::NetworkInformation& aNetworkInfo); - -private: - RequestSyncWifiService() - : mIsWifi(false) - {} - - ~RequestSyncWifiService() - {} - - bool mIsWifi; -}; - -} // dom namespace -} // mozilla namespace - -#endif // mozilla_dom_RequestSyncWifiService_h
deleted file mode 100644 --- a/dom/requestsync/moz.build +++ /dev/null @@ -1,32 +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') - -FAIL_ON_WARNINGS = True -FINAL_LIBRARY = 'xul'
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,187 +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() { - ok(false, "Some promise failed"); -} - -function test_register() { - navigator.sync.register('foobar', { minInterval: 5, wakeUpPage:'/' }).then( - function() { - ok(true, "navigator.sync.register() worked!"); - runTests(); - }, genericError); -} - -function test_unregister() { - navigator.sync.unregister('foobar').then( - function() { - ok(true, "navigator.sync.unregister() worked!"); - runTests(); - }, genericError); -} - -function test_unregisterDuplicate() { - navigator.sync.unregister('foobar').then( - genericError, - 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); -} - -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); -} - -function test_registrationsEmpty() { - navigator.sync.registrations().then( - function(results) { - is(results.length, 0, "navigator.sync.registrations() should return an empty array."); - runTests(); - }, - genericError); -} - -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); -} - -function test_managerRegistrationsEmpty() { - navigator.syncManager.registrations().then( - function(results) { - is(results.length, 0, "navigator.syncManager.registrations() should return an empty array."); - runTests(); - }, - genericError); -} - -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"); - runTests(); - }, - genericError); -} - -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); - }).catch(genericError); -}
deleted file mode 100644 --- a/dom/requestsync/tests/file_app.sjs +++ /dev/null @@ -1,54 +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,19 +0,0 @@ -[DEFAULT] -skip-if = e10s -support-files = - file_app.template.webapp - file_app.sjs - file_basic_app.html - common_app.js - common_basic.js - -[test_webidl.html] -[test_minInterval.html] -[test_basic.html] -[test_basic_app.html] -run-if = buildapp != 'b2g' -[test_wakeUp.html] -run-if = buildapp == 'b2g' && toolkit == 'gonk' -[test_promise.html] -[test_promise_app.html] -run-if = buildapp == 'b2g' && toolkit == 'gonk'
deleted file mode 100644 --- a/dom/requestsync/tests/test_basic.html +++ /dev/null @@ -1,79 +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() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("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,135 +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() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/RequestSyncService.jsm"); - } - - SpecialPowers.setAllAppsLaunchable(true); - SpecialPowers.setBoolPref("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_minInterval.html +++ /dev/null @@ -1,65 +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(runTests); - } - - var tests = [ - function() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("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_promise_app.html +++ /dev/null @@ -1,150 +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"> - - var foobarCounter = 0; - var pendingCounter = 0; - function setMessageHandler() { - navigator.mozSetMessageHandler('request-sync', function(e) { - - if (e.task == 'foobar') { - ok(true, "foobar message received:" + ++foobarCounter); - - if (foobarCounter == 1) { - // The first time we wait 2 seconds. - info("Setting a promise object."); - navigator.mozSetMessageHandlerPromise(new Promise(function(a, b) { - SimpleTest.requestFlakyTimeout("Just testing to make sure things work."); - setTimeout(a, 2000); - })); - } else if (foobarCounter == 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 (foobarCounter == 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); - })); - } - } - - else if (e.task == 'pending') { - ok(true, "pending message received: " + ++pendingCounter); - if (pendingCounter == 5) { - runTests(); - } - } - - else { - ok(false, "Unknown message"); - } - }); - - runTests(); - } - - function test_register_foobar() { - navigator.sync.register('foobar', { minInterval: 2, - oneShot: false, - data: 42, - wifiOnly: false, - wakeUpPage: location.href }).then( - function() { - ok(true, "navigator.sync.register() foobar done"); - runTests(); - }, genericError); - } - - function test_register_pending() { - navigator.sync.register('pending', { minInterval: 2, - oneShot: false, - data: 'hello world!', - wifiOnly: false, - wakeUpPage: location.href }).then( - function() { - ok(true, "navigator.sync.register() pending done"); - runTests(); - }, genericError); - } - - function test_unregister_foobar() { - navigator.sync.unregister('foobar').then( - function() { - ok(true, "navigator.sync.unregister() foobar done"); - runTests(); - }, genericError); - } - - function test_unregister_pending() { - navigator.sync.unregister('pending').then( - function() { - ok(true, "navigator.sync.unregister() pending 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", 5000 /* 5 seconds */], - ["dom.ignore_webidl_scope_checks", true]]}, runTests); - }, - - function() { - SpecialPowers.pushPermissions( - [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests); - }, - - function() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/RequestSyncService.jsm"); - } - runTests(); - }, - - setMessageHandler, - - test_register_foobar, - test_register_pending, - - test_wait, - - test_unregister_foobar, - test_unregister_pending, - ]; - - 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,151 +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 == 3) { - runTests(); - } - } - - 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; - 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.ignore_webidl_scope_checks", true]]}, runTests); - }, - - function() { - SpecialPowers.pushPermissions( - [{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests); - }, - - function() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/RequestSyncService.jsm"); - } - runTests(); - }, - - 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,86 +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 test_no_interface() { - ok(!("sync" in navigator), "navigator.sync should not exist without permissions"); - ok(!("syncManager" in navigator), "navigator.syncManager should not exist without permissions"); - runTests(); - } - - function test_sync() { - 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"); - } - - 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"); - - test_sync(); - runTests(); - } - - function test_sync_manager_interface() { - ok("sync" in navigator, "navigator.sync should exist with permissions"); - ok("syncManager" in navigator, "navigator.syncManager should exist with permissions"); - - test_sync(); - - ok("registrations" in navigator.syncManager, "navigator.syncManager.registrations exists"); - runTests(); - } - - var tests = [ - 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 @@ -1205,24 +1205,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, pref: "dom.requestSync.enabled", premission: "requestsync-manager" }, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "RequestSyncScheduler", b2g: true, pref: "dom.requestSync.enabled" }, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "RequestSyncApp", b2g: true, pref: "dom.requestSync.enabled", premission: "requestsync-manager" }, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "RequestSyncTask", b2g: true, pref: "dom.requestSync.enabled", premission: "requestsync-manager" }, -// IMPORTANT: Do not change this list without review from a DOM peer! {name: "Telephony", b2g: true, pref: "dom.telephony.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "TelephonyCall", b2g: true, pref: "dom.telephony.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "TelephonyCallGroup", b2g: true, pref: "dom.telephony.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "TelephonyCallId", b2g: true, pref: "dom.telephony.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -280,22 +280,16 @@ partial interface Navigator { // nsIDOMNavigatorSystemMessages and sort of maybe // http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 callback systemMessageCallback = void (optional object message); partial interface Navigator { [Throws, Pref="dom.sysmsg.enabled"] void mozSetMessageHandler (DOMString type, systemMessageCallback? callback); [Throws, Pref="dom.sysmsg.enabled"] boolean mozHasPendingMessage (DOMString type); - - // This method can be called only from the systeMessageCallback function and - // it allows the page to set a promise to keep alive the app until the - // current operation is not fully completed. - [Throws, Pref="dom.sysmsg.enabled"] - void mozSetMessageHandlerPromise (Promise<any> promise); }; #ifdef MOZ_B2G_RIL partial interface Navigator { [Throws, Pref="dom.mobileconnection.enabled", CheckPermissions="mobileconnection mobilenetwork", UnsafeInPrerendering] readonly attribute MozMobileConnectionArray mozMobileConnections; };
deleted file mode 100644 --- a/dom/webidl/RequestSyncManager.webidl +++ /dev/null @@ -1,54 +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", - CheckPermissions="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", - CheckPermissions="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); -}; - -[NavigatorProperty="syncManager", - AvailableIn=CertifiedApps, - Pref="dom.requestSync.enabled", - CheckPermissions="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 @@ -336,18 +336,16 @@ WEBIDL_FILES = [ 'ProfileTimelineMarker.webidl', 'Promise.webidl', 'PromiseDebugging.webidl', 'PushManager.webidl', 'RadioNodeList.webidl', 'Range.webidl', 'Rect.webidl', 'Request.webidl', - 'RequestSyncManager.webidl', - 'RequestSyncScheduler.webidl', 'ResourceStats.webidl', 'ResourceStatsManager.webidl', 'Response.webidl', 'RGBColor.webidl', 'RTCConfiguration.webidl', 'RTCIceCandidate.webidl', 'RTCIdentityAssertion.webidl', 'RTCPeerConnection.webidl',
--- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -59,17 +59,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 "AudioChannelService.h" #include "mozilla/dom/DataStoreService.h" #ifdef MOZ_XUL #include "nsXULPopupManager.h" #include "nsXULContentUtils.h" #include "nsXULPrototypeCache.h" @@ -296,20 +295,16 @@ nsLayoutStatics::Initialize() CacheObserver::Init(); CounterStyleManager::InitializeBuiltinCounterStyles(); CameraPreferences::Initialize(); IMEStateManager::Init(); -#ifdef MOZ_B2G - RequestSyncWifiService::Init(); -#endif - return NS_OK; } void nsLayoutStatics::Shutdown() { // Don't need to shutdown nsWindowMemoryReporter, that will be done by the // memory reporter manager.
--- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -281,19 +281,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