diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-12 14:32:03 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-12 14:32:03 +0200 |
commit | b7d9dad58e5a3f87a6c767412941700bc8010044 (patch) | |
tree | f5e99b3029cf54409ae5951e9e91cca3a54addc7 | |
parent | 73cdd6117df7c17b76aad93952cf574c494351aa (diff) | |
download | uxp-b7d9dad58e5a3f87a6c767412941700bc8010044.tar.gz |
Remove MOZ_B2G leftovers and some dead B2G-only components.
91 files changed, 28 insertions, 5017 deletions
diff --git a/accessible/base/nsAccessibilityService.h b/accessible/base/nsAccessibilityService.h index 5621505928..1f32fc6779 100644 --- a/accessible/base/nsAccessibilityService.h +++ b/accessible/base/nsAccessibilityService.h @@ -336,12 +336,8 @@ void MaybeShutdownAccService(uint32_t aFormerConsumer); inline bool IPCAccessibilityActive() { -#ifdef MOZ_B2G - return false; -#else return XRE_IsContentProcess() && mozilla::Preferences::GetBool("accessibility.ipc_architecture.enabled", true); -#endif } /** diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 4ffccde9d3..9663a6dbf7 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -249,10 +249,6 @@ #include "mozilla/dom/SpeechSynthesis.h" #endif -#ifdef MOZ_B2G -#include "nsPISocketTransportService.h" -#endif - // Apple system headers seem to have a check() macro. <sigh> #ifdef check class nsIScriptTimeoutHandler; @@ -1557,10 +1553,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) #ifdef DEBUG mSetOpenerWindowCalled(false), #endif -#ifdef MOZ_B2G - mNetworkUploadObserverEnabled(false), - mNetworkDownloadObserverEnabled(false), -#endif mCleanedUp(false), mDialogAbuseCount(0), mAreDialogsEnabled(true), @@ -1913,11 +1905,6 @@ nsGlobalWindow::CleanUp() os->RemoveObserver(mObserver, "dom-storage2-changed"); } -#ifdef MOZ_B2G - DisableNetworkEvent(eNetworkUpload); - DisableNetworkEvent(eNetworkDownload); -#endif // MOZ_B2G - if (mIdleService) { mIdleService->RemoveIdleObserver(mObserver, MIN_IDLE_NOTIFICATION_TIME_S); } @@ -1986,9 +1973,6 @@ nsGlobalWindow::CleanUp() mHasGamepad = false; DisableVRUpdates(); mHasVREvents = false; -#ifdef MOZ_B2G - DisableTimeChangeNotifications(); -#endif DisableIdleCallbackRequests(); } else { MOZ_ASSERT(!mHasGamepad); @@ -12133,27 +12117,6 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } -#ifdef MOZ_B2G - if (!nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC) || - !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC)) { - MOZ_ASSERT(IsInnerWindow()); - if (!AsInner()->IsCurrentInnerWindow()) { - return NS_OK; - } - - RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr); - event->InitEvent( - !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC) - ? NETWORK_UPLOAD_EVENT_NAME - : NETWORK_DOWNLOAD_EVENT_NAME, - false, false); - event->SetTrusted(true); - - bool dummy; - return DispatchEvent(event, &dummy); - } -#endif // MOZ_B2G - if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) { MOZ_ASSERT(!NS_strcmp(aData, u"intl.accept_languages")); MOZ_ASSERT(IsInnerWindow()); @@ -15053,80 +15016,6 @@ nsGlobalWindow::GetIsPrerendered() return docShell && docShell->GetIsPrerendered(); } -#ifdef MOZ_B2G -void -nsGlobalWindow::EnableNetworkEvent(EventMessage aEventMessage) -{ - MOZ_ASSERT(IsInnerWindow()); - - nsCOMPtr<nsIPermissionManager> permMgr = - services::GetPermissionManager(); - if (!permMgr) { - NS_ERROR("No PermissionManager available!"); - return; - } - - uint32_t permission = nsIPermissionManager::DENY_ACTION; - permMgr->TestExactPermissionFromPrincipal(GetPrincipal(), "network-events", - &permission); - - if (permission != nsIPermissionManager::ALLOW_ACTION) { - return; - } - - nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); - if (!os) { - NS_ERROR("ObserverService should be available!"); - return; - } - - switch (aEventMessage) { - case eNetworkUpload: - if (!mNetworkUploadObserverEnabled) { - mNetworkUploadObserverEnabled = true; - os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC, false); - } - break; - case eNetworkDownload: - if (!mNetworkDownloadObserverEnabled) { - mNetworkDownloadObserverEnabled = true; - os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC, false); - } - break; - default: - break; - } -} - -void -nsGlobalWindow::DisableNetworkEvent(EventMessage aEventMessage) -{ - MOZ_ASSERT(IsInnerWindow()); - - nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); - if (!os) { - return; - } - - switch (aEventMessage) { - case eNetworkUpload: - if (mNetworkUploadObserverEnabled) { - mNetworkUploadObserverEnabled = false; - os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC); - } - break; - case eNetworkDownload: - if (mNetworkDownloadObserverEnabled) { - mNetworkDownloadObserverEnabled = false; - os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC); - } - break; - default: - break; - } -} -#endif // MOZ_B2G - void nsGlobalWindow::RedefineProperty(JSContext* aCx, const char* aPropName, JS::Handle<JS::Value> aValue, diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 78bee63a19..94d565bf32 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -639,13 +639,6 @@ public: virtual void EnableTimeChangeNotifications() override; virtual void DisableTimeChangeNotifications() override; -#ifdef MOZ_B2G - // Inner windows only. - virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) override; - virtual void DisableNetworkEvent( - mozilla::EventMessage aEventMessage) override; -#endif // MOZ_B2G - virtual nsresult SetArguments(nsIArray* aArguments) override; void MaybeForgiveSpamCount(); @@ -1941,11 +1934,6 @@ protected: nsCOMPtr<nsIURI> mLastOpenedURI; #endif -#ifdef MOZ_B2G - bool mNetworkUploadObserverEnabled; - bool mNetworkDownloadObserverEnabled; -#endif // MOZ_B2G - bool mCleanedUp; nsCOMPtr<nsIDOMOfflineResourceList> mApplicationCache; diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 45823057a5..3fd666beba 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -452,24 +452,6 @@ public: virtual void EnableTimeChangeNotifications() = 0; virtual void DisableTimeChangeNotifications() = 0; -#ifdef MOZ_B2G - /** - * Tell the window that it should start to listen to the network event of the - * given aType. - * - * Inner windows only. - */ - virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) = 0; - - /** - * Tell the window that it should stop to listen to the network event of the - * given aType. - * - * Inner windows only. - */ - virtual void DisableNetworkEvent(mozilla::EventMessage aEventMessage) = 0; -#endif // MOZ_B2G - /** * Tell this window that there is an observer for gamepad input * diff --git a/dom/downloads/DownloadsAPI.js b/dom/downloads/DownloadsAPI.js deleted file mode 100644 index 8294e2a3ea..0000000000 --- a/dom/downloads/DownloadsAPI.js +++ /dev/null @@ -1,517 +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 Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/DOMRequestHelper.jsm"); -Cu.import("resource://gre/modules/DownloadsIPC.jsm"); - -XPCOMUtils.defineLazyServiceGetter(this, "cpmm", - "@mozilla.org/childprocessmessagemanager;1", - "nsIMessageSender"); -XPCOMUtils.defineLazyServiceGetter(this, "volumeService", - "@mozilla.org/telephony/volume-service;1", - "nsIVolumeService"); - -/** - * The content process implementations of navigator.mozDownloadManager and its - * DOMDownload download objects. Uses DownloadsIPC.jsm to communicate with - * DownloadsAPI.jsm in the parent process. - */ - -function debug(aStr) { -#ifdef MOZ_DEBUG - dump("-*- DownloadsAPI.js : " + aStr + "\n"); -#endif -} - -function DOMDownloadManagerImpl() { - debug("DOMDownloadManagerImpl constructor"); -} - -DOMDownloadManagerImpl.prototype = { - __proto__: DOMRequestIpcHelper.prototype, - - // nsIDOMGlobalPropertyInitializer implementation - init: function(aWindow) { - debug("DownloadsManager init"); - this.initDOMRequestHelper(aWindow, - ["Downloads:Added", - "Downloads:Removed"]); - - // Get the manifest URL if this is an installed app - let appsService = Cc["@mozilla.org/AppsService;1"] - .getService(Ci.nsIAppsService); - let principal = aWindow.document.nodePrincipal; - // This returns the empty string if we're not an installed app. Coerce to - // null. - this._manifestURL = appsService.getManifestURLByLocalId(principal.appId) || - null; - }, - - uninit: function() { - debug("uninit"); - downloadsCache.evict(this._window); - }, - - set ondownloadstart(aHandler) { - this.__DOM_IMPL__.setEventHandler("ondownloadstart", aHandler); - }, - - get ondownloadstart() { - return this.__DOM_IMPL__.getEventHandler("ondownloadstart"); - }, - - getDownloads: function() { - debug("getDownloads()"); - - return this.createPromise(function (aResolve, aReject) { - DownloadsIPC.getDownloads().then( - function(aDownloads) { - // Turn the list of download objects into DOM objects and - // send them. - let array = new this._window.Array(); - for (let id in aDownloads) { - let dom = createDOMDownloadObject(this._window, aDownloads[id]); - array.push(this._prepareForContent(dom)); - } - aResolve(array); - }.bind(this), - function() { - aReject("GetDownloadsError"); - } - ); - }.bind(this)); - }, - - clearAllDone: function() { - debug("clearAllDone()"); - // This is a void function; we just kick it off. No promises, etc. - DownloadsIPC.clearAllDone(); - }, - - remove: function(aDownload) { - debug("remove " + aDownload.url + " " + aDownload.id); - return this.createPromise(function (aResolve, aReject) { - if (!downloadsCache.has(this._window, aDownload.id)) { - debug("no download " + aDownload.id); - aReject("InvalidDownload"); - return; - } - - DownloadsIPC.remove(aDownload.id).then( - function(aResult) { - let dom = createDOMDownloadObject(this._window, aResult); - // Change the state right away to not race against the update message. - dom.wrappedJSObject.state = "finalized"; - aResolve(this._prepareForContent(dom)); - }.bind(this), - function() { - aReject("RemoveError"); - } - ); - }.bind(this)); - }, - - adoptDownload: function(aAdoptDownloadDict) { - // Our AdoptDownloadDict only includes simple types, which WebIDL enforces. - // We have no object/any types so we do not need to worry about invoking - // JSON.stringify (and it inheriting our security privileges). - debug("adoptDownload"); - return this.createPromise(function (aResolve, aReject) { - if (!aAdoptDownloadDict) { - debug("Download dictionary is required!"); - aReject("InvalidDownload"); - return; - } - if (!aAdoptDownloadDict.storageName || !aAdoptDownloadDict.storagePath || - !aAdoptDownloadDict.contentType) { - debug("Missing one of: storageName, storagePath, contentType"); - aReject("InvalidDownload"); - return; - } - - // Convert storageName/storagePath to a local filesystem path. - let volume; - // getVolumeByName throws if you give it something it doesn't like - // because XPConnect converts the NS_ERROR_NOT_AVAILABLE to an - // exception. So catch it. - try { - volume = volumeService.getVolumeByName(aAdoptDownloadDict.storageName); - } catch (ex) {} - if (!volume) { - debug("Invalid storage name: " + aAdoptDownloadDict.storageName); - aReject("InvalidDownload"); - return; - } - let computedPath = volume.mountPoint + '/' + - aAdoptDownloadDict.storagePath; - // We validate that there is actually a file at the given path in the - // parent process in DownloadsAPI.js because that's where the file - // access would actually occur either way. - - // Create a DownloadsAPI.jsm 'jsonDownload' style representation. - let jsonDownload = { - url: aAdoptDownloadDict.url, - path: computedPath, - contentType: aAdoptDownloadDict.contentType, - startTime: aAdoptDownloadDict.startTime.valueOf() || Date.now(), - sourceAppManifestURL: this._manifestURL - }; - - DownloadsIPC.adoptDownload(jsonDownload).then( - function(aResult) { - let domDownload = createDOMDownloadObject(this._window, aResult); - aResolve(this._prepareForContent(domDownload)); - }.bind(this), - function(aResult) { - // This will be one of: AdoptError (generic catch-all), - // AdoptNoSuchFile, AdoptFileIsDirectory - aReject(aResult.error); - } - ); - }.bind(this)); - }, - - - /** - * Turns a chrome download object into a content accessible one. - * When we have __DOM_IMPL__ available we just use that, otherwise - * we run _create() with the wrapped js object. - */ - _prepareForContent: function(aChromeObject) { - if (aChromeObject.__DOM_IMPL__) { - return aChromeObject.__DOM_IMPL__; - } - let res = this._window.DOMDownload._create(this._window, - aChromeObject.wrappedJSObject); - return res; - }, - - receiveMessage: function(aMessage) { - let data = aMessage.data; - switch(aMessage.name) { - case "Downloads:Added": - debug("Adding " + uneval(data)); - let event = new this._window.DownloadEvent("downloadstart", { - download: - this._prepareForContent(createDOMDownloadObject(this._window, data)) - }); - this.__DOM_IMPL__.dispatchEvent(event); - break; - } - }, - - classID: Components.ID("{c6587afa-0696-469f-9eff-9dac0dd727fe}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, - Ci.nsISupportsWeakReference, - Ci.nsIObserver, - Ci.nsIDOMGlobalPropertyInitializer]), - -}; - -/** - * Keep track of download objects per window. - */ -var downloadsCache = { - init: function() { - this.cache = new WeakMap(); - }, - - has: function(aWindow, aId) { - let downloads = this.cache.get(aWindow); - return !!(downloads && downloads[aId]); - }, - - get: function(aWindow, aDownload) { - let downloads = this.cache.get(aWindow); - if (!(downloads && downloads[aDownload.id])) { - debug("Adding download " + aDownload.id + " to cache."); - if (!downloads) { - this.cache.set(aWindow, {}); - downloads = this.cache.get(aWindow); - } - // Create the object and add it to the cache. - let impl = Cc["@mozilla.org/downloads/download;1"] - .createInstance(Ci.nsISupports); - impl.wrappedJSObject._init(aWindow, aDownload); - downloads[aDownload.id] = impl; - } - return downloads[aDownload.id]; - }, - - evict: function(aWindow) { - this.cache.delete(aWindow); - } -}; - -downloadsCache.init(); - -/** - * The DOM facade of a download object. - */ - -function createDOMDownloadObject(aWindow, aDownload) { - return downloadsCache.get(aWindow, aDownload); -} - -function DOMDownloadImpl() { - debug("DOMDownloadImpl constructor "); - - this.wrappedJSObject = this; - this.totalBytes = 0; - this.currentBytes = 0; - this.url = null; - this.path = null; - this.storageName = null; - this.storagePath = null; - this.contentType = null; - - /* fields that require getters/setters */ - this._error = null; - this._startTime = new Date(); - this._state = "stopped"; - - /* private fields */ - this.id = null; -} - -DOMDownloadImpl.prototype = { - - createPromise: function(aPromiseInit) { - return new this._window.Promise(aPromiseInit); - }, - - pause: function() { - debug("DOMDownloadImpl pause"); - let id = this.id; - // We need to wrap the Promise.jsm promise in a "real" DOM promise... - return this.createPromise(function(aResolve, aReject) { - DownloadsIPC.pause(id).then(aResolve, aReject); - }); - }, - - resume: function() { - debug("DOMDownloadImpl resume"); - let id = this.id; - // We need to wrap the Promise.jsm promise in a "real" DOM promise... - return this.createPromise(function(aResolve, aReject) { - DownloadsIPC.resume(id).then(aResolve, aReject); - }); - }, - - set onstatechange(aHandler) { - this.__DOM_IMPL__.setEventHandler("onstatechange", aHandler); - }, - - get onstatechange() { - return this.__DOM_IMPL__.getEventHandler("onstatechange"); - }, - - get error() { - return this._error; - }, - - set error(aError) { - this._error = aError; - }, - - get startTime() { - return this._startTime; - }, - - set startTime(aStartTime) { - if (aStartTime instanceof Date) { - this._startTime = aStartTime; - } - else { - this._startTime = new Date(aStartTime); - } - }, - - get state() { - return this._state; - }, - - // We require a setter here to simplify the internals of the Download Manager - // since we actually pass dummy JSON objects to the child process and update - // them. This is the case for all other setters for read-only attributes - // implemented in this object. - set state(aState) { - // We need to ensure that XPCOM consumers of this API respect the enum - // values as well. - if (["downloading", - "stopped", - "succeeded", - "finalized"].indexOf(aState) != -1) { - this._state = aState; - } - }, - - /** - * Initialize a DOMDownload instance for the given window using the - * 'jsonDownload' serialized format of the download encoded by - * DownloadsAPI.jsm. - */ - _init: function(aWindow, aDownload) { - this._window = aWindow; - this.id = aDownload.id; - this._update(aDownload); - Services.obs.addObserver(this, "downloads-state-change-" + this.id, - /* ownsWeak */ true); - debug("observer set for " + this.id); - }, - - /** - * Updates the state of the object and fires the statechange event. - */ - _update: function(aDownload) { - debug("update " + uneval(aDownload)); - if (this.id != aDownload.id) { - return; - } - - let props = ["totalBytes", "currentBytes", "url", "path", "storageName", - "storagePath", "state", "contentType", "startTime", - "sourceAppManifestURL"]; - let changed = false; - let changedProps = {}; - - props.forEach((prop) => { - if (prop in aDownload && (aDownload[prop] != this[prop])) { - this[prop] = aDownload[prop]; - changedProps[prop] = changed = true; - } - }); - - // When the path changes, we should update the storage name and - // storage path used for our downloaded file in case our download - // was re-targetted to a different storage and/or filename. - if (changedProps["path"]) { - let storages = this._window.navigator.getDeviceStorages("sdcard"); - let preferredStorageName; - // Use the first one or the default storage. Just like jsdownloads picks - // the default / preferred download directory. - storages.forEach((aStorage) => { - if (aStorage.default || !preferredStorageName) { - preferredStorageName = aStorage.storageName; - } - }); - // Now get the path for this storage area. - let volume; - if (preferredStorageName) { - let volume = volumeService.getVolumeByName(preferredStorageName); - if (volume) { - // Finally, create the relative path of the file that can be used - // later on to retrieve the file via DeviceStorage. Our path - // needs to omit the starting '/'. - this.storageName = preferredStorageName; - this.storagePath = - this.path.substring(this.path.indexOf(volume.mountPoint) + - volume.mountPoint.length + 1); - } - } - } - - if (aDownload.error) { - // - // When we get a generic error failure back from the js downloads api - // we will verify the status of device storage to see if we can't provide - // a better error result value. - // - // XXX If these checks expand further, consider moving them into their - // own function. - // - let result = aDownload.error.result; - let storage = this._window.navigator.getDeviceStorage("sdcard"); - - // If we don't have access to device storage we'll opt out of these - // extra checks as they are all dependent on the state of the storage. - if (result == Cr.NS_ERROR_FAILURE && storage) { - // We will delay sending the notification until we've inferred which - // error is really happening. - changed = false; - debug("Attempting to infer error via device storage sanity checks."); - // Get device storage and request availability status. - let available = storage.available(); - available.onsuccess = (function() { - debug("Storage Status = '" + available.result + "'"); - let inferredError = result; - switch (available.result) { - case "unavailable": - inferredError = Cr.NS_ERROR_FILE_NOT_FOUND; - break; - case "shared": - inferredError = Cr.NS_ERROR_FILE_ACCESS_DENIED; - break; - } - this._updateWithError(aDownload, inferredError); - }).bind(this); - available.onerror = (function() { - this._updateWithError(aDownload, result); - }).bind(this); - } - - this.error = - new this._window.DOMError("DownloadError", result); - } else { - this.error = null; - } - - // The visible state has not changed, so no need to fire an event. - if (!changed) { - return; - } - - this._sendStateChange(); - }, - - _updateWithError: function(aDownload, aError) { - this.error = - new this._window.DOMError("DownloadError", aError); - this._sendStateChange(); - }, - - _sendStateChange: function() { - // __DOM_IMPL__ may not be available at first update. - if (this.__DOM_IMPL__) { - let event = new this._window.DownloadEvent("statechange", { - download: this.__DOM_IMPL__ - }); - debug("Dispatching statechange event. state=" + this.state); - this.__DOM_IMPL__.dispatchEvent(event); - } - }, - - observe: function(aSubject, aTopic, aData) { - debug("DOMDownloadImpl observe " + aTopic); - if (aTopic !== "downloads-state-change-" + this.id) { - return; - } - - try { - let download = JSON.parse(aData); - // We get the start time as milliseconds, not as a Date object. - if (download.startTime) { - download.startTime = new Date(download.startTime); - } - this._update(download); - } catch(e) {} - }, - - classID: Components.ID("{96b81b99-aa96-439d-8c59-92eeed34705f}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, - Ci.nsIObserver, - Ci.nsISupportsWeakReference]) -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DOMDownloadManagerImpl, - DOMDownloadImpl]); diff --git a/dom/downloads/DownloadsAPI.jsm b/dom/downloads/DownloadsAPI.jsm deleted file mode 100644 index dfb8286fe0..0000000000 --- a/dom/downloads/DownloadsAPI.jsm +++ /dev/null @@ -1,365 +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 Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; - -this.EXPORTED_SYMBOLS = []; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Downloads.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); -Cu.import("resource://gre/modules/osfile.jsm"); - -XPCOMUtils.defineLazyServiceGetter(this, "ppmm", - "@mozilla.org/parentprocessmessagemanager;1", - "nsIMessageBroadcaster"); - -/** - * Parent process logic that services download API requests from the - * DownloadAPI.js instances in content processeses. The actual work of managing - * downloads is done by Toolkit's Downloads.jsm. This module is loaded by B2G's - * shell.js - */ - -function debug(aStr) { -#ifdef MOZ_DEBUG - dump("-*- DownloadsAPI.jsm : " + aStr + "\n"); -#endif -} - -function sendPromiseMessage(aMm, aMessageName, aData, aError) { - debug("sendPromiseMessage " + aMessageName); - let msg = { - id: aData.id, - promiseId: aData.promiseId - }; - - if (aError) { - msg.error = aError; - } - - aMm.sendAsyncMessage(aMessageName, msg); -} - -var DownloadsAPI = { - init: function() { - debug("init"); - - this._ids = new WeakMap(); // Maps toolkit download objects to ids. - this._index = {}; // Maps ids to downloads. - - ["Downloads:GetList", - "Downloads:ClearAllDone", - "Downloads:Remove", - "Downloads:Pause", - "Downloads:Resume", - "Downloads:Adopt"].forEach((msgName) => { - ppmm.addMessageListener(msgName, this); - }); - - let self = this; - Task.spawn(function () { - let list = yield Downloads.getList(Downloads.ALL); - yield list.addView(self); - - debug("view added to download list."); - }).then(null, Components.utils.reportError); - - this._currentId = 0; - }, - - /** - * Returns a unique id for each download, hashing the url and the path. - */ - downloadId: function(aDownload) { - let id = this._ids.get(aDownload, null); - if (!id) { - id = "download-" + this._currentId++; - this._ids.set(aDownload, id); - this._index[id] = aDownload; - } - return id; - }, - - getDownloadById: function(aId) { - return this._index[aId]; - }, - - /** - * Converts a download object into a plain json object that we'll - * send to the DOM side. - */ - jsonDownload: function(aDownload) { - let res = { - totalBytes: aDownload.totalBytes, - currentBytes: aDownload.currentBytes, - url: aDownload.source.url, - path: aDownload.target.path, - contentType: aDownload.contentType, - startTime: aDownload.startTime.getTime(), - sourceAppManifestURL: aDownload._unknownProperties && - aDownload._unknownProperties.sourceAppManifestURL - }; - - if (aDownload.error) { - res.error = aDownload.error; - } - - res.id = this.downloadId(aDownload); - - // The state of the download. Can be any of "downloading", "stopped", - // "succeeded", finalized". - - // Default to "stopped" - res.state = "stopped"; - if (!aDownload.stopped && - !aDownload.canceled && - !aDownload.succeeded && - !aDownload.DownloadError) { - res.state = "downloading"; - } else if (aDownload.succeeded) { - res.state = "succeeded"; - } - return res; - }, - - /** - * download view methods. - */ - onDownloadAdded: function(aDownload) { - let download = this.jsonDownload(aDownload); - debug("onDownloadAdded " + uneval(download)); - ppmm.broadcastAsyncMessage("Downloads:Added", download); - }, - - onDownloadRemoved: function(aDownload) { - let download = this.jsonDownload(aDownload); - download.state = "finalized"; - debug("onDownloadRemoved " + uneval(download)); - ppmm.broadcastAsyncMessage("Downloads:Removed", download); - this._index[this._ids.get(aDownload)] = null; - this._ids.delete(aDownload); - }, - - onDownloadChanged: function(aDownload) { - let download = this.jsonDownload(aDownload); - debug("onDownloadChanged " + uneval(download)); - ppmm.broadcastAsyncMessage("Downloads:Changed", download); - }, - - receiveMessage: function(aMessage) { - if (!aMessage.target.assertPermission("downloads")) { - debug("No 'downloads' permission!"); - return; - } - - debug("message: " + aMessage.name); - - switch (aMessage.name) { - case "Downloads:GetList": - this.getList(aMessage.data, aMessage.target); - break; - case "Downloads:ClearAllDone": - this.clearAllDone(aMessage.data, aMessage.target); - break; - case "Downloads:Remove": - this.remove(aMessage.data, aMessage.target); - break; - case "Downloads:Pause": - this.pause(aMessage.data, aMessage.target); - break; - case "Downloads:Resume": - this.resume(aMessage.data, aMessage.target); - break; - case "Downloads:Adopt": - this.adoptDownload(aMessage.data, aMessage.target); - break; - default: - debug("Invalid message: " + aMessage.name); - } - }, - - getList: function(aData, aMm) { - debug("getList called!"); - let self = this; - Task.spawn(function () { - let list = yield Downloads.getList(Downloads.ALL); - let downloads = yield list.getAll(); - let res = []; - downloads.forEach((aDownload) => { - res.push(self.jsonDownload(aDownload)); - }); - aMm.sendAsyncMessage("Downloads:GetList:Return", res); - }).then(null, Components.utils.reportError); - }, - - clearAllDone: function(aData, aMm) { - debug("clearAllDone called!"); - Task.spawn(function () { - let list = yield Downloads.getList(Downloads.ALL); - list.removeFinished(); - }).then(null, Components.utils.reportError); - }, - - remove: function(aData, aMm) { - debug("remove id " + aData.id); - let download = this.getDownloadById(aData.id); - if (!download) { - sendPromiseMessage(aMm, "Downloads:Remove:Return", - aData, "NoSuchDownload"); - return; - } - - Task.spawn(function() { - yield download.finalize(true); - let list = yield Downloads.getList(Downloads.ALL); - yield list.remove(download); - }).then( - function() { - sendPromiseMessage(aMm, "Downloads:Remove:Return", aData); - }, - function() { - sendPromiseMessage(aMm, "Downloads:Remove:Return", - aData, "RemoveError"); - } - ); - }, - - pause: function(aData, aMm) { - debug("pause id " + aData.id); - let download = this.getDownloadById(aData.id); - if (!download) { - sendPromiseMessage(aMm, "Downloads:Pause:Return", - aData, "NoSuchDownload"); - return; - } - - download.cancel().then( - function() { - sendPromiseMessage(aMm, "Downloads:Pause:Return", aData); - }, - function() { - sendPromiseMessage(aMm, "Downloads:Pause:Return", - aData, "PauseError"); - } - ); - }, - - resume: function(aData, aMm) { - debug("resume id " + aData.id); - let download = this.getDownloadById(aData.id); - if (!download) { - sendPromiseMessage(aMm, "Downloads:Resume:Return", - aData, "NoSuchDownload"); - return; - } - - download.start().then( - function() { - sendPromiseMessage(aMm, "Downloads:Resume:Return", aData); - }, - function() { - sendPromiseMessage(aMm, "Downloads:Resume:Return", - aData, "ResumeError"); - } - ); - }, - - /** - * Receive a download to adopt in the same representation we produce from - * our "jsonDownload" normalizer and add it to the list of downloads. - */ - adoptDownload: function(aData, aMm) { - let adoptJsonRep = aData.jsonDownload; - debug("adoptDownload " + uneval(adoptJsonRep)); - - Task.spawn(function* () { - // Verify that the file exists on disk. This will result in a rejection - // if the file does not exist. We will also use this information for the - // file size to avoid weird inconsistencies. We ignore the filesystem - // timestamp in favor of whatever the caller is telling us. - let fileInfo = yield OS.File.stat(adoptJsonRep.path); - - // We also require that the file is not a directory. - if (fileInfo.isDir) { - throw new Error("AdoptFileIsDirectory"); - } - - // We need to create a Download instance to add to the list. Create a - // serialized representation and then from there the instance. - let serializedRep = { - // explicit initializations in toSerializable - source: { - url: adoptJsonRep.url - // This is where isPrivate would go if adoption supported private - // browsing. - }, - target: { - path: adoptJsonRep.path, - }, - startTime: adoptJsonRep.startTime, - // kPlainSerializableDownloadProperties propagations - succeeded: true, // (all adopted downloads are required to be completed) - totalBytes: fileInfo.size, - contentType: adoptJsonRep.contentType, - // unknown properties added/used by the DownloadsAPI - currentBytes: fileInfo.size, - sourceAppManifestURL: adoptJsonRep.sourceAppManifestURL - }; - - let download = yield Downloads.createDownload(serializedRep); - - // The ALL list is a DownloadCombinedList instance that combines the - // PUBLIC (persisted to disk) and PRIVATE (ephemeral) download lists.. - // When we call add on it, it dispatches to the appropriate list based on - // the 'isPrivate' field of the source. (Which we don't initialize and - // defaults to false.) - let allDownloadList = yield Downloads.getList(Downloads.ALL); - - // This add will automatically notify all views of the added download, - // including DownloadsAPI instances and the DownloadAutoSaveView that's - // subscribed to the PUBLIC list and will save the download. - yield allDownloadList.add(download); - - debug("download adopted"); - // The notification above occurred synchronously, and so we will have - // already dispatched an added notification for our download to the child - // process in question. As such, we only need to relay the download id - // since the download will already have been cached. - return download; - }.bind(this)).then( - (download) => { - sendPromiseMessage(aMm, "Downloads:Adopt:Return", - { - id: this.downloadId(download), - promiseId: aData.promiseId - }); - }, - (ex) => { - let reportAs = "AdoptError"; - // Provide better error codes for expected errors. - if (ex instanceof OS.File.Error && ex.becauseNoSuchFile) { - reportAs = "AdoptNoSuchFile"; - } else if (ex.message === "AdoptFileIsDirectory") { - reportAs = ex.message; - } else { - // Anything else is unexpected and should be reported to help track - // down what's going wrong. - debug("unexpected download error: " + ex); - Cu.reportError(ex); - } - sendPromiseMessage(aMm, "Downloads:Adopt:Return", - { - promiseId: aData.promiseId - }, - reportAs); - }); - } -}; - -DownloadsAPI.init(); diff --git a/dom/downloads/DownloadsAPI.manifest b/dom/downloads/DownloadsAPI.manifest deleted file mode 100644 index 8d6dc9396b..0000000000 --- a/dom/downloads/DownloadsAPI.manifest +++ /dev/null @@ -1,6 +0,0 @@ -# DownloadsAPI.js -component {c6587afa-0696-469f-9eff-9dac0dd727fe} DownloadsAPI.js -contract @mozilla.org/downloads/manager;1 {c6587afa-0696-469f-9eff-9dac0dd727fe} - -component {96b81b99-aa96-439d-8c59-92eeed34705f} DownloadsAPI.js -contract @mozilla.org/downloads/download;1 {96b81b99-aa96-439d-8c59-92eeed34705f} diff --git a/dom/downloads/DownloadsIPC.jsm b/dom/downloads/DownloadsIPC.jsm deleted file mode 100644 index 0e290abf41..0000000000 --- a/dom/downloads/DownloadsIPC.jsm +++ /dev/null @@ -1,224 +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 Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; - -this.EXPORTED_SYMBOLS = ["DownloadsIPC"]; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/Promise.jsm"); - -XPCOMUtils.defineLazyServiceGetter(this, "cpmm", - "@mozilla.org/childprocessmessagemanager;1", - "nsIMessageSender"); - -/** - * This module lives in the child process and receives the ipc messages - * from the parent. It saves the download's state and redispatch changes - * to DOM objects using an observer notification. - * - * This module needs to be loaded once and only once per process. - */ - -function debug(aStr) { -#ifdef MOZ_DEBUG - dump("-*- DownloadsIPC.jsm : " + aStr + "\n"); -#endif -} - -const ipcMessages = ["Downloads:Added", - "Downloads:Removed", - "Downloads:Changed", - "Downloads:GetList:Return", - "Downloads:Remove:Return", - "Downloads:Pause:Return", - "Downloads:Resume:Return", - "Downloads:Adopt:Return"]; - -this.DownloadsIPC = { - downloads: {}, - - init: function() { - debug("init"); - Services.obs.addObserver(this, "xpcom-shutdown", false); - ipcMessages.forEach((aMessage) => { - cpmm.addMessageListener(aMessage, this); - }); - - // We need to get the list of current downloads. - this.ready = false; - this.getListPromises = []; - this.downloadPromises = {}; - cpmm.sendAsyncMessage("Downloads:GetList", {}); - this._promiseId = 0; - }, - - notifyChanges: function(aId) { - // TODO: use the subject instead of stringifying. - if (this.downloads[aId]) { - debug("notifyChanges notifying changes for " + aId); - Services.obs.notifyObservers(null, "downloads-state-change-" + aId, - JSON.stringify(this.downloads[aId])); - } else { - debug("notifyChanges failed for " + aId) - } - }, - - _updateDownloadsArray: function(aDownloads) { - this.downloads = []; - // We actually have an array of downloads. - aDownloads.forEach((aDownload) => { - this.downloads[aDownload.id] = aDownload; - }); - }, - - receiveMessage: function(aMessage) { - let download = aMessage.data; - debug("message: " + aMessage.name); - switch(aMessage.name) { - case "Downloads:GetList:Return": - this._updateDownloadsArray(download); - - if (!this.ready) { - this.getListPromises.forEach(aPromise => - aPromise.resolve(this.downloads)); - this.getListPromises.length = 0; - } - this.ready = true; - break; - case "Downloads:Added": - this.downloads[download.id] = download; - this.notifyChanges(download.id); - break; - case "Downloads:Removed": - if (this.downloads[download.id]) { - this.downloads[download.id] = download; - this.notifyChanges(download.id); - delete this.downloads[download.id]; - } - break; - case "Downloads:Changed": - // Only update properties that actually changed. - let cached = this.downloads[download.id]; - if (!cached) { - debug("No download found for " + download.id); - return; - } - let props = ["totalBytes", "currentBytes", "url", "path", "state", - "contentType", "startTime"]; - let changed = false; - - props.forEach((aProp) => { - if (download[aProp] && (download[aProp] != cached[aProp])) { - cached[aProp] = download[aProp]; - changed = true; - } - }); - - // Updating the error property. We always get a 'state' change as - // well. - cached.error = download.error; - - if (changed) { - this.notifyChanges(download.id); - } - break; - case "Downloads:Remove:Return": - case "Downloads:Pause:Return": - case "Downloads:Resume:Return": - case "Downloads:Adopt:Return": - if (this.downloadPromises[download.promiseId]) { - if (!download.error) { - this.downloadPromises[download.promiseId].resolve(download); - } else { - this.downloadPromises[download.promiseId].reject(download); - } - delete this.downloadPromises[download.promiseId]; - } - break; - } - }, - - /** - * Returns a promise that is resolved with the list of current downloads. - */ - getDownloads: function() { - debug("getDownloads()"); - let deferred = Promise.defer(); - if (this.ready) { - debug("Returning existing list."); - deferred.resolve(this.downloads); - } else { - this.getListPromises.push(deferred); - } - return deferred.promise; - }, - - /** - * Void function to trigger removal of completed downloads. - */ - clearAllDone: function() { - debug("clearAllDone"); - cpmm.sendAsyncMessage("Downloads:ClearAllDone", {}); - }, - - promiseId: function() { - return this._promiseId++; - }, - - remove: function(aId) { - debug("remove " + aId); - let deferred = Promise.defer(); - let pId = this.promiseId(); - this.downloadPromises[pId] = deferred; - cpmm.sendAsyncMessage("Downloads:Remove", - { id: aId, promiseId: pId }); - return deferred.promise; - }, - - pause: function(aId) { - debug("pause " + aId); - let deferred = Promise.defer(); - let pId = this.promiseId(); - this.downloadPromises[pId] = deferred; - cpmm.sendAsyncMessage("Downloads:Pause", - { id: aId, promiseId: pId }); - return deferred.promise; - }, - - resume: function(aId) { - debug("resume " + aId); - let deferred = Promise.defer(); - let pId = this.promiseId(); - this.downloadPromises[pId] = deferred; - cpmm.sendAsyncMessage("Downloads:Resume", - { id: aId, promiseId: pId }); - return deferred.promise; - }, - - adoptDownload: function(aJsonDownload) { - debug("adoptDownload"); - let deferred = Promise.defer(); - let pId = this.promiseId(); - this.downloadPromises[pId] = deferred; - cpmm.sendAsyncMessage("Downloads:Adopt", - { jsonDownload: aJsonDownload, promiseId: pId }); - return deferred.promise; - }, - - observe: function(aSubject, aTopic, aData) { - if (aTopic == "xpcom-shutdown") { - ipcMessages.forEach((aMessage) => { - cpmm.removeMessageListener(aMessage, this); - }); - } - } -}; - -DownloadsIPC.init(); diff --git a/dom/downloads/moz.build b/dom/downloads/moz.build deleted file mode 100644 index 07bda1c4f3..0000000000 --- a/dom/downloads/moz.build +++ /dev/null @@ -1,21 +0,0 @@ -# -*- Mode: python; 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/. - -if CONFIG["MOZ_B2G"]: - MOCHITEST_MANIFESTS += ['tests/mochitest.ini'] - -EXTRA_COMPONENTS += [ - 'DownloadsAPI.manifest', -] - -EXTRA_PP_COMPONENTS += [ - 'DownloadsAPI.js', -] - -EXTRA_PP_JS_MODULES += [ - 'DownloadsAPI.jsm', - 'DownloadsIPC.jsm', -] diff --git a/dom/downloads/tests/clear_all_done_helper.js b/dom/downloads/tests/clear_all_done_helper.js deleted file mode 100644 index 62fa1a2f30..0000000000 --- a/dom/downloads/tests/clear_all_done_helper.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * A helper to clear out the existing downloads known to the mozDownloadManager - * / downloads.js. - * - * It exists because previously mozDownloadManager.clearAllDone() thought that - * when it returned that all the completed downloads would be cleared out. It - * was wrong and this led to various intermittent test failurse. In discussion - * on https://bugzil.la/979446#c13 and onwards, it was decided that - * clearAllDone() was in the wrong and that the jsdownloads API it depends on - * was not going to change to make it be in the right. - * - * The existing uses of clearAllDone() in tests seemed to be about: - * - Exploding if there was somehow still a download in progress - * - Clearing out the download list at the start of a test so that calls to - * getDownloads() wouldn't have to worry about existing downloads, etc. - * - * From discussion, the right way to handle clearing is to wait for the expected - * removal events to occur for the existing downloads. So that's what we do. - * We still generate a test failure if there are any in-progress downloads. - * - * @param {Boolean} [getDownloads=false] - * If true, invoke getDownloads after clearing the download list and return - * its value. - */ -function clearAllDoneHelper(getDownloads) { - var clearedPromise = new Promise(function(resolve, reject) { - function gotDownloads(downloads) { - // If there are no downloads, we're already done. - if (downloads.length === 0) { - resolve(); - return; - } - - // Track the set of expected downloads that will be finalized. - var expectedIds = new Set(); - function changeHandler(evt) { - var download = evt.download; - if (download.state === "finalized") { - expectedIds.delete(download.id); - if (expectedIds.size === 0) { - resolve(); - } - } - } - downloads.forEach(function(download) { - if (download.state === "downloading") { - ok(false, "A download is still active: " + download.path); - reject("Active download"); - } - download.onstatechange = changeHandler; - expectedIds.add(download.id); - }); - navigator.mozDownloadManager.clearAllDone(); - } - function gotBadNews(err) { - ok(false, "Problem clearing all downloads: " + err); - reject(err); - } - navigator.mozDownloadManager.getDownloads().then(gotDownloads, gotBadNews); - }); - if (!getDownloads) { - return clearedPromise; - } - return clearedPromise.then(function() { - return navigator.mozDownloadManager.getDownloads(); - }); -} diff --git a/dom/downloads/tests/mochitest.ini b/dom/downloads/tests/mochitest.ini deleted file mode 100644 index e13e4d8870..0000000000 --- a/dom/downloads/tests/mochitest.ini +++ /dev/null @@ -1,15 +0,0 @@ -[DEFAULT] -# The actual requirement for mozDownloadManager is MOZ_GONK because of -# the nsIVolumeService dependency. Until https://bugzil.la/1130264 is -# addressed, there is no way for mulet to run these tests. -run-if = toolkit == 'gonk' -support-files = - serve_file.sjs - clear_all_done_helper.js - -[test_downloads_navigator_object.html] -[test_downloads_basic.html] -[test_downloads_large.html] -[test_downloads_bad_file.html] -[test_downloads_pause_remove.html] -[test_downloads_pause_resume.html] diff --git a/dom/downloads/tests/serve_file.sjs b/dom/downloads/tests/serve_file.sjs deleted file mode 100644 index d0171d7ca0..0000000000 --- a/dom/downloads/tests/serve_file.sjs +++ /dev/null @@ -1,170 +0,0 @@ -// Serves a file with a given mime type and size at an optionally given rate. - -function getQuery(request) { - var query = {}; - request.queryString.split('&').forEach(function (val) { - var [name, value] = val.split('='); - query[name] = unescape(value); - }); - return query; -} - -function handleResponse() { - // Is this a rate limited response? - if (this.state.rate > 0) { - // Calculate how many bytes we have left to send. - var bytesToWrite = this.state.totalBytes - this.state.sentBytes; - - // Do we have any bytes left to send? If not we'll just fall thru and - // cancel our repeating timer and finalize the response. - if (bytesToWrite > 0) { - // Figure out how many bytes to send, based on the rate limit. - bytesToWrite = - (bytesToWrite > this.state.rate) ? this.state.rate : bytesToWrite; - - for (let i = 0; i < bytesToWrite; i++) { - try { - this.response.bodyOutputStream.write("0", 1); - } catch (e) { - // Connection was closed by client. - if (e == Components.results.NS_ERROR_NOT_AVAILABLE) { - // There's no harm in calling this multiple times. - this.response.finish(); - - // It's possible that our timer wasn't cancelled in time - // and we'll be called again. - if (this.timer) { - this.timer.cancel(); - this.timer = null; - } - - return; - } - } - } - - // Update the number of bytes we've sent to the client. - this.state.sentBytes += bytesToWrite; - - // Wait until the next call to do anything else. - return; - } - } - else { - // Not rate limited, write it all out. - for (let i = 0; i < this.state.totalBytes; i++) { - this.response.write("0"); - } - } - - // Finalize the response. - this.response.finish(); - - // All done sending, go ahead and cancel our repeating timer. - this.timer.cancel(); - - // Clear the timer. - this.timer = null; -} - -function handleRequest(request, response) { - var query = getQuery(request); - - // sending at a specific rate requires our response to be asynchronous so - // we handle all requests asynchronously. See handleResponse(). - response.processAsync(); - - // Default status when responding. - var version = "1.1"; - var statusCode = 200; - var description = "OK"; - - // Default values for content type, size and rate. - var contentType = "text/plain"; - var contentRange = null; - var size = 1024; - var rate = 0; - - // optional content type to be used by our response. - if ("contentType" in query) { - contentType = query["contentType"]; - } - - // optional size (in bytes) for generated file. - if ("size" in query) { - size = parseInt(query["size"]); - } - - // optional range request check. - if (request.hasHeader("range")) { - version = "1.1"; - statusCode = 206; - description = "Partial Content"; - - // We'll only support simple range byte style requests. - var [offset, total] = request.getHeader("range").slice("bytes=".length).split("-"); - // Enforce valid Number values. - offset = parseInt(offset); - offset = isNaN(offset) ? 0 : offset; - // Same. - total = parseInt(total); - total = isNaN(total) ? 0 : total; - - // We'll need to original total size as part of the Content-Range header - // value in our response. - var originalSize = size; - - // If we have a total size requested, we must make sure to send that number - // of bytes only (minus the start offset). - if (total && total < size) { - size = total - offset; - } else if (offset) { - // Looks like we just have a byte offset to deal with. - size = size - offset; - } - - // We specifically need to add a Content-Range header to all responses for - // requests that include a range request header. - contentRange = "bytes " + offset + "-" + (size - 1) + "/" + originalSize; - } - - // optional rate (in bytes/s) at which to send the file. - if ("rate" in query) { - rate = parseInt(query["rate"]); - } - - // The context for the responseHandler. - var context = { - response: response, - state: { - contentType: contentType, - totalBytes: size, - sentBytes: 0, - rate: rate - }, - timer: null - }; - - // The notify implementation for the timer. - context.notify = handleResponse.bind(context); - - context.timer = - Components.classes["@mozilla.org/timer;1"] - .createInstance(Components.interfaces.nsITimer); - - // generate the content. - response.setStatusLine(version, statusCode, description); - response.setHeader("Content-Type", contentType, false); - if (contentRange) { - response.setHeader("Content-Range", contentRange, false); - } - response.setHeader("Content-Length", size.toString(), false); - - // initialize the timer and start writing out the response. - context.timer.initWithCallback( - context, - 1000, - Components.interfaces.nsITimer.TYPE_REPEATING_SLACK - ); - -} diff --git a/dom/downloads/tests/test_downloads_bad_file.html b/dom/downloads/tests/test_downloads_bad_file.html deleted file mode 100644 index a2b3992e63..0000000000 --- a/dom/downloads/tests/test_downloads_bad_file.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=960749 ---> -<head> - <title>Test for Bug 960749 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=960749">Mozilla Bug 960749</a> -<p id="display"></p> -<div id="content" style="display: none"> -</div> -<a href="serve_file.sjs?contentType=application/octet-stream&size=1024" download=".<.EVIL.>\ / : * ? " |file.bin" id="download1">Download #1</a> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -// Testing a simple download, waiting for it to be done. - -SimpleTest.waitForExplicitFinish(); - -var index = -1; -var expected = "_.EVIL.__ _ _ _ _ _ _file.bin"; - -function next() { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -function checkTargetFilename(download) { - ok(download.path.endsWith(expected), - "Download path leaf name '" + download.path + - "' should match '" + expected + "' filename."); - - SimpleTest.finish(); -} - -function downloadChange(evt) { - var download = evt.download; - - if (download.state === "succeeded") { - checkTargetFilename(download); - } -} - -function downloadStart(evt) { - var download = evt.download; - download.onstatechange = downloadChange; -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - // Setup the event listeners. - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: true, context: document} - ], function() { - navigator.mozDownloadManager.ondownloadstart = downloadStart; - next(); - }); - }, - - // Click on the <a download> to start the download. - function() { - document.getElementById("download1").click(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> - diff --git a/dom/downloads/tests/test_downloads_basic.html b/dom/downloads/tests/test_downloads_basic.html deleted file mode 100644 index 051a1faa1b..0000000000 --- a/dom/downloads/tests/test_downloads_basic.html +++ /dev/null @@ -1,128 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=938023 ---> -<head> - <title>Test for Bug 938023 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> -<p id="display"></p> -<div id="content" style="display: none"> -</div> -<a href="serve_file.sjs?contentType=application/octet-stream&size=1024" download="test.bin" id="download1">Download #1</a> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -// Testing a simple download, waiting for it to be done. - -SimpleTest.waitForExplicitFinish(); - -var index = -1; -var todayDate = new Date(); -var baseServeURL = "http://mochi.test:8888/tests/dom/downloads/tests/"; -var lastKnownCurrentBytes = 0; - -function next() { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -function checkConsistentDownloadAttributes(download) { - var href = document.getElementById("download1").getAttribute("href"); - var expectedServeURL = baseServeURL + href; - var destinationRegEx = /test\(?[0-9]*\)?\.bin$/; - - // bug 945323: Download path isn't honoring download attribute - ok(destinationRegEx.test(download.path), - "Download path '" + download.path + - "' should match '" + destinationRegEx + "' regexp."); - - ok(download.startTime >= todayDate, - "Download start time should be greater than or equal to today"); - - is(download.error, null, "Download does not have an error"); - - is(download.url, expectedServeURL, - "Download URL = " + expectedServeURL); - ok(download.id !== null, "Download id is defined"); - is(download.contentType, "application/octet-stream", - "Download content type is application/octet-stream"); -} - -function downloadChange(evt) { - var download = evt.download; - checkConsistentDownloadAttributes(download); - is(download.totalBytes, 1024, "Download total size is 1024 bytes"); - - if (download.state === "succeeded") { - is(download.currentBytes, 1024, "Download current size is 1024 bytes"); - SimpleTest.finish(); - } else if (download.state === "downloading") { - // Note that this case may or may not trigger, depending on whether the - // download is initially reported with 0 bytes (we should happen) or with - // 1024 bytes (we should not happen). If we do happen, an additional 8 - // TEST-PASS events should be logged. - ok(download.currentBytes > lastKnownCurrentBytes, - "Download current size is larger than last download change event"); - lastKnownCurrentBytes = download.currentBytes; - } else { - ok(false, "Unexpected download state = " + download.state); - } -} - -function downloadStart(evt) { - var download = evt.download; - checkConsistentDownloadAttributes(download); - - // We used to check that the currentBytes was 0. This was incorrect. It - // is very common to first hear about the download already at 1024 bytes. - is(download.state, "downloading", "Download state is downloading"); - - download.onstatechange = downloadChange; -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - // Setup the event listeners. - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: true, context: document} - ], function() { - navigator.mozDownloadManager.ondownloadstart = downloadStart; - next(); - }); - }, - - // Click on the <a download> to start the download. - function() { - document.getElementById("download1").click(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> - diff --git a/dom/downloads/tests/test_downloads_large.html b/dom/downloads/tests/test_downloads_large.html deleted file mode 100644 index 9f7f73c199..0000000000 --- a/dom/downloads/tests/test_downloads_large.html +++ /dev/null @@ -1,110 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=938023 ---> -<head> - <title>Test for Bug 938023 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="clear_all_done_helper.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> -<p id="display"></p> -<div id="content" style="display: none"> -</div> -<a href="serve_file.sjs?contentType=application/octet-stream&size=102400" download="test.bin" id="download1">Large Download</a> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -// Testing downloading a file, then checking getDownloads() and clearAllDone(). - -SimpleTest.waitForExplicitFinish(); - -var index = -1; - -function next(args) { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](args); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -// Catch all error function. -function error() { - ok(false, "API failure"); - SimpleTest.finish(); -} - -function getDownloads(downloads) { - ok(downloads.length == 1, "One downloads after getDownloads"); - clearAllDoneHelper(true).then(clearAllDone, error); -} - -function clearAllDone(downloads) { - ok(downloads.length == 0, "No downloads after clearAllDone"); - SimpleTest.finish(); -} - -function downloadChange(evt) { - var download = evt.download; - - if (download.state == "succeeded") { - ok(download.totalBytes == 102400, "Download size is 100k bytes."); - navigator.mozDownloadManager.getDownloads().then(getDownloads, error); - } -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - // Setup permission and clear current list. - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: true, context: document} - ], function() { - clearAllDoneHelper(true).then(next, error); - }); - }, - - function(downloads) { - ok(downloads.length == 0, "Start with an empty download list."); - next(); - }, - - // Setup the event listeners. - function() { - navigator.mozDownloadManager.ondownloadstart = - function(evt) { - ok(true, "Download started"); - evt.download.addEventListener("statechange", downloadChange); - } - next(); - }, - - // Click on the <a download> to start the download. - function() { - document.getElementById("download1").click(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> diff --git a/dom/downloads/tests/test_downloads_navigator_object.html b/dom/downloads/tests/test_downloads_navigator_object.html deleted file mode 100644 index 1c38388b71..0000000000 --- a/dom/downloads/tests/test_downloads_navigator_object.html +++ /dev/null @@ -1,75 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=938023 ---> -<head> - <title>Test for Bug 938023 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> -<p id="display"></p> -<div id="content" style="display: none"> -<iframe></iframe> -</div> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -SimpleTest.waitForExplicitFinish(); - -var index = -1; - -function next() { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: 0, context: document} - ], function() { - is(frames[0].navigator.mozDownloadManager, null, "navigator.mozDownloadManager is null when the page doesn't have permissions"); - next(); - }); - }, - - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", false]] - }, function() { - is(navigator.mozDownloadManager, undefined, "navigator.mozDownloadManager is undefined"); - next(); - }); - }, - - function() { - SimpleTest.finish(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> diff --git a/dom/downloads/tests/test_downloads_pause_remove.html b/dom/downloads/tests/test_downloads_pause_remove.html deleted file mode 100644 index 3b410a6671..0000000000 --- a/dom/downloads/tests/test_downloads_pause_remove.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=938023 ---> -<head> - <title>Test for Bug 938023 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="clear_all_done_helper.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> -<p id="display"></p> -<div id="content" style="display: none"> -</div> -<a href="serve_file.sjs?contentType=application/octet-stream&size=102400&rate=1024" download="test.bin" id="download1">Large Download</a> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -// Testing pausing a download and then removing it. - -SimpleTest.waitForExplicitFinish(); - -var index = -1; - -function next(args) { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](args); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -var pausing = false; - -// Catch all error function. -function error() { - ok(false, "API failure"); - SimpleTest.finish(); -} - -function checkDownloadList(downloads) { - ok(downloads.length == 0, "No downloads left"); - SimpleTest.finish(); -} - -function checkRemoved(download) { - ok(download.state == "finalized", "Download removed."); - navigator.mozDownloadManager.getDownloads() - .then(checkDownloadList, error); -} - -function downloadChange(evt) { - var download = evt.download; - - if (download.state == "downloading" && !pausing) { - pausing = true; - download.pause(); - } else if (download.state == "stopped") { - ok(pausing, "Download stopped by pause()"); - navigator.mozDownloadManager.remove(download) - .then(checkRemoved, error); - } -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - // Setup permission and clear current list. - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: true, context: document} - ], function() { - clearAllDoneHelper(true).then(next, error); - }); - }, - - function(downloads) { - ok(downloads.length == 0, "Start with an empty download list."); - next(); - }, - - // Setup the event listeners. - function() { - navigator.mozDownloadManager.ondownloadstart = - function(evt) { - ok(true, "Download started"); - evt.download.addEventListener("statechange", downloadChange); - } - next(); - }, - - // Click on the <a download> to start the download. - function() { - document.getElementById("download1").click(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> diff --git a/dom/downloads/tests/test_downloads_pause_resume.html b/dom/downloads/tests/test_downloads_pause_resume.html deleted file mode 100644 index 76e249e5ac..0000000000 --- a/dom/downloads/tests/test_downloads_pause_resume.html +++ /dev/null @@ -1,121 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=938023 ---> -<head> - <title>Test for Bug 938023 Downloads API</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="clear_all_done_helper.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> -<p id="display"></p> -<div id="content" style="display: none"> -</div> -<a href="serve_file.sjs?contentType=application/octet-stream&size=102400&rate=1024" download="test.bin" id="download1">Large Download</a> -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.7"> - -// Testing pausing a download and then resuming it. - -SimpleTest.waitForExplicitFinish(); - -var index = -1; - -function next(args) { - index += 1; - if (index >= steps.length) { - ok(false, "Shouldn't get here!"); - return; - } - try { - steps[index](args); - } catch(ex) { - ok(false, "Caught exception", ex); - } -} - -var pausing = false; -var resuming = false; - -// Catch all error function. -function error() { - ok(false, "API failure"); - SimpleTest.finish(); -} - -function checkDownloadList(downloads) { - ok(downloads.length == 0, "No downloads left"); - SimpleTest.finish(); -} - -function checkResumeSucceeded(download) { - ok(download.state == "succeeded", "Download resumed successfully."); - clearAllDoneHelper(true).then(checkDownloadList, error); -} - -function downloadChange(evt) { - var download = evt.download; - - info("got download event, state: " + download.state + - " current bytes: " + download.currentBytes + - " pausing?: " + pausing + " resuming?: " + resuming); - if (download.state == "downloading" && !pausing) { - pausing = true; - download.pause(); - } else if (download.state == "stopped" && !resuming) { - resuming = true; - ok(pausing, "Download stopped by pause()"); - download.resume() - .then(function() { checkResumeSucceeded(download); }, error); - } -} - -var steps = [ - // Start by setting the pref to true. - function() { - SpecialPowers.pushPrefEnv({ - set: [["dom.mozDownloads.enabled", true]] - }, next); - }, - - // Setup permission and clear current list. - function() { - SpecialPowers.pushPermissions([ - {type: "downloads", allow: true, context: document} - ], function() { - clearAllDoneHelper(true).then(next, error); - }); - }, - - function(downloads) { - ok(downloads.length == 0, "Start with an empty download list."); - next(); - }, - - // Setup the event listeners. - function() { - navigator.mozDownloadManager.ondownloadstart = - function(evt) { - ok(true, "Download started"); - evt.download.addEventListener("statechange", downloadChange); - } - next(); - }, - - // Click on the <a download> to start the download. - function() { - document.getElementById("download1").click(); - } -]; - -next(); - -</script> -</pre> -</body> -</html> diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index a8c48ede80..ae8bf1b1a3 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -13,9 +13,6 @@ #include "mozilla/DOMEventTargetHelper.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" -#ifdef MOZ_B2G -#include "mozilla/Hal.h" -#endif // #ifdef MOZ_B2G #include "mozilla/HalSensor.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/JSEventHandler.h" @@ -359,14 +356,6 @@ EventListenerManager::AddEventListenerInternal( } else if (aTypeAtom == nsGkAtoms::onorientationchange) { EnableDevice(eOrientationChange); #endif -#ifdef MOZ_B2G - } else if (aTypeAtom == nsGkAtoms::onmoztimechange) { - EnableDevice(eTimeChange); - } else if (aTypeAtom == nsGkAtoms::onmoznetworkupload) { - EnableDevice(eNetworkUpload); - } else if (aTypeAtom == nsGkAtoms::onmoznetworkdownload) { - EnableDevice(eNetworkDownload); -#endif // MOZ_B2G } else if (aTypeAtom == nsGkAtoms::ontouchstart || aTypeAtom == nsGkAtoms::ontouchend || aTypeAtom == nsGkAtoms::ontouchmove || @@ -495,11 +484,6 @@ EventListenerManager::IsDeviceType(EventMessage aEventMessage) #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) case eOrientationChange: #endif -#ifdef MOZ_B2G - case eTimeChange: - case eNetworkUpload: - case eNetworkDownload: -#endif return true; default: break; @@ -550,15 +534,6 @@ EventListenerManager::EnableDevice(EventMessage aEventMessage) window->EnableOrientationChangeListener(); break; #endif -#ifdef MOZ_B2G - case eTimeChange: - window->EnableTimeChangeNotifications(); - break; - case eNetworkUpload: - case eNetworkDownload: - window->EnableNetworkEvent(aEventMessage); - break; -#endif default: NS_WARNING("Enabling an unknown device sensor."); break; @@ -605,15 +580,6 @@ EventListenerManager::DisableDevice(EventMessage aEventMessage) window->DisableOrientationChangeListener(); break; #endif -#ifdef MOZ_B2G - case eTimeChange: - window->DisableTimeChangeNotifications(); - break; - case eNetworkUpload: - case eNetworkDownload: - window->DisableNetworkEvent(aEventMessage); - break; -#endif // MOZ_B2G default: NS_WARNING("Disabling an unknown device sensor."); break; diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 509863e6ce..3f0af9fe9d 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -637,22 +637,6 @@ WINDOW_ONLY_EVENT(appinstalled, EventNameType_None, eBasicEventClass) - -#ifdef MOZ_B2G -WINDOW_ONLY_EVENT(moztimechange, - eTimeChange, - EventNameType_None, - eBasicEventClass) -WINDOW_ONLY_EVENT(moznetworkupload, - eNetworkUpload, - EventNameType_None, - eBasicEventClass) -WINDOW_ONLY_EVENT(moznetworkdownload, - eNetworkDownload, - EventNameType_None, - eBasicEventClass) -#endif // MOZ_B2G - TOUCH_EVENT(touchstart, eTouchStart, EventNameType_All, diff --git a/dom/events/KeyNameList.h b/dom/events/KeyNameList.h index 35fbe2d5f3..361122ec78 100644 --- a/dom/events/KeyNameList.h +++ b/dom/events/KeyNameList.h @@ -32,10 +32,6 @@ DEFINE_KEYNAME_INTERNAL(PrintableKey, "MozPrintableKey") DEFINE_KEYNAME_INTERNAL(SoftLeft, "MozSoftLeft") DEFINE_KEYNAME_INTERNAL(SoftRight, "MozSoftRight") -#ifdef MOZ_B2G -DEFINE_KEYNAME_INTERNAL(HomeScreen, "MozHomeScreen") -#endif // #ifdef MOZ_B2G - /****************************************************************************** * Modifier Keys *****************************************************************************/ diff --git a/dom/events/TouchEvent.cpp b/dom/events/TouchEvent.cpp index cc9684eb37..9b7a74ac28 100644 --- a/dom/events/TouchEvent.cpp +++ b/dom/events/TouchEvent.cpp @@ -203,7 +203,7 @@ TouchEvent::PrefEnabled(nsIDocShell* aDocShell) enabled = false; } else { if (sPrefCacheValue == 2) { -#if defined(MOZ_B2G) || defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) // Touch support is always enabled on B2G and android. enabled = true; #elif defined(XP_WIN) || MOZ_WIDGET_GTK == 3 diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 52062c4b9b..d09bc31030 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -959,13 +959,6 @@ UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc, nsCOMPtr<nsIContentPrefCallback2> prefCallback = new UploadLastDir::ContentPrefCallback(aFilePicker, aFpCallback); -#ifdef MOZ_B2G - if (XRE_IsContentProcess()) { - prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR); - return NS_OK; - } -#endif - // Attempt to get the CPS, if it's not present we'll fallback to use the Desktop folder nsCOMPtr<nsIContentPrefService2> contentPrefService = do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID); @@ -990,12 +983,6 @@ UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir) return NS_OK; } -#ifdef MOZ_B2G - if (XRE_IsContentProcess()) { - return NS_OK; - } -#endif - nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI(); NS_PRECONDITION(docURI, "docURI is null"); @@ -6013,7 +6000,7 @@ HTMLInputElement::ChooseDirectory(ErrorResult& aRv) // "Pick Folder..." button on platforms that don't have a directory picker // we have to redirect to the file picker here. InitFilePicker( -#if defined(ANDROID) || defined(MOZ_B2G) +#if defined(ANDROID) // No native directory picker - redirect to plain file picker FILE_PICKER_FILE #else diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index b0800728f5..39e039c0fb 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -3694,8 +3694,6 @@ UpgradeSchemaFrom18_0To19_0(mozIStorageConnection* aConnection) return NS_OK; } -#if !defined(MOZ_B2G) - class NormalJSContext; class UpgradeFileIdsFunction final @@ -3731,8 +3729,6 @@ private: nsIVariant** aResult) override; }; -#endif // MOZ_B2G - nsresult UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory, mozIStorageConnection* aConnection) @@ -3744,20 +3740,6 @@ UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory, "UpgradeSchemaFrom19_0To20_0", js::ProfileEntry::Category::STORAGE); -#if defined(MOZ_B2G) - - // We don't have to do the upgrade of file ids on B2G. The old format was - // only used by the previous single process implementation and B2G was - // always multi process. This is a nice optimization since the upgrade needs - // to deserialize all structured clones which reference a stored file or - // a mutable file. - nsresult rv = aConnection->SetSchemaVersion(MakeSchemaVersion(20, 0)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - -#else // MOZ_B2G - nsCOMPtr<mozIStorageStatement> stmt; nsresult rv = aConnection->CreateStatement(NS_LITERAL_CSTRING( "SELECT count(*) " @@ -3856,8 +3838,6 @@ UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory, return rv; } -#endif // MOZ_B2G - return NS_OK; } @@ -19664,8 +19644,6 @@ AutoProgressHandler::OnProgress(mozIStorageConnection* aConnection, NS_IMPL_ISUPPORTS(CompressDataBlobsFunction, mozIStorageFunction) NS_IMPL_ISUPPORTS(EncodeKeysFunction, mozIStorageFunction) -#if !defined(MOZ_B2G) - nsresult UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory, mozIStorageConnection* aConnection) @@ -19760,8 +19738,6 @@ UpgradeFileIdsFunction::OnFunctionCall(mozIStorageValueArray* aArguments, return NS_OK; } -#endif // MOZ_B2G - // static void DatabaseOperationBase::GetBindingClauseForKeyRange( diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index cf62f49c37..a6d6c5f064 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -859,10 +859,6 @@ public: } }; -// We don't need to upgrade database on B2G. See the comment in ActorsParent.cpp, -// UpgradeSchemaFrom18_0To19_0() -#if !defined(MOZ_B2G) - class UpgradeDeserializationHelper { public: @@ -929,8 +925,6 @@ public: } }; -#endif // MOZ_B2G - template <class Traits> JSObject* CommonStructuredCloneReadCallback(JSContext* aCx, @@ -1263,8 +1257,6 @@ IDBObjectStore::DeserializeIndexValue(JSContext* aCx, return true; } -#if !defined(MOZ_B2G) - // static bool IDBObjectStore::DeserializeUpgradeValue(JSContext* aCx, @@ -1301,8 +1293,6 @@ IDBObjectStore::DeserializeUpgradeValue(JSContext* aCx, return true; } -#endif // MOZ_B2G - #ifdef DEBUG void diff --git a/dom/indexedDB/IDBObjectStore.h b/dom/indexedDB/IDBObjectStore.h index 7a255a4afc..994931afa5 100644 --- a/dom/indexedDB/IDBObjectStore.h +++ b/dom/indexedDB/IDBObjectStore.h @@ -101,12 +101,10 @@ public: StructuredCloneReadInfo& aCloneReadInfo, JS::MutableHandle<JS::Value> aValue); -#if !defined(MOZ_B2G) static bool DeserializeUpgradeValue(JSContext* aCx, StructuredCloneReadInfo& aCloneReadInfo, JS::MutableHandle<JS::Value> aValue); -#endif static const JSClass* DummyPropClass() diff --git a/dom/inputmethod/HardwareKeyHandler.cpp b/dom/inputmethod/HardwareKeyHandler.cpp deleted file mode 100644 index 737c30e5b5..0000000000 --- a/dom/inputmethod/HardwareKeyHandler.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "HardwareKeyHandler.h" -#include "mozilla/BasicEvents.h" -#include "mozilla/ClearOnShutdown.h" -#include "mozilla/dom/KeyboardEvent.h" -#include "mozilla/dom/TabParent.h" -#include "mozilla/EventDispatcher.h" -#include "mozilla/EventStateManager.h" -#include "mozilla/TextEvents.h" -#include "nsDeque.h" -#include "nsFocusManager.h" -#include "nsFrameLoader.h" -#include "nsIContent.h" -#include "nsIDOMHTMLDocument.h" -#include "nsIDOMHTMLElement.h" -#include "nsPIDOMWindow.h" -#include "nsPresContext.h" -#include "nsPresShell.h" - -namespace mozilla { - -using namespace dom; - -NS_IMPL_ISUPPORTS(HardwareKeyHandler, nsIHardwareKeyHandler) - -StaticRefPtr<HardwareKeyHandler> HardwareKeyHandler::sInstance; - -HardwareKeyHandler::HardwareKeyHandler() - : mInputMethodAppConnected(false) -{ -} - -HardwareKeyHandler::~HardwareKeyHandler() -{ -} - -NS_IMETHODIMP -HardwareKeyHandler::OnInputMethodAppConnected() -{ - if (NS_WARN_IF(mInputMethodAppConnected)) { - return NS_ERROR_UNEXPECTED; - } - - mInputMethodAppConnected = true; - - return NS_OK; -} - -NS_IMETHODIMP -HardwareKeyHandler::OnInputMethodAppDisconnected() -{ - if (NS_WARN_IF(!mInputMethodAppConnected)) { - return NS_ERROR_UNEXPECTED; - } - - mInputMethodAppConnected = false; - return NS_OK; -} - -NS_IMETHODIMP -HardwareKeyHandler::RegisterListener(nsIHardwareKeyEventListener* aListener) -{ - // Make sure the listener is not nullptr and there is no available - // hardwareKeyEventListener now - if (NS_WARN_IF(!aListener)) { - return NS_ERROR_NULL_POINTER; - } - - if (NS_WARN_IF(mHardwareKeyEventListener)) { - return NS_ERROR_ALREADY_INITIALIZED; - } - - mHardwareKeyEventListener = do_GetWeakReference(aListener); - - if (NS_WARN_IF(!mHardwareKeyEventListener)) { - return NS_ERROR_NULL_POINTER; - } - - return NS_OK; -} - -NS_IMETHODIMP -HardwareKeyHandler::UnregisterListener() -{ - // Clear the HardwareKeyEventListener - mHardwareKeyEventListener = nullptr; - return NS_OK; -} - -bool -HardwareKeyHandler::ForwardKeyToInputMethodApp(nsINode* aTarget, - WidgetKeyboardEvent* aEvent, - nsEventStatus* aEventStatus) -{ - MOZ_ASSERT(aTarget, "No target provided"); - MOZ_ASSERT(aEvent, "No event provided"); - - // No need to forward hardware key event to IME - // if key's defaultPrevented is true - if (aEvent->mFlags.mDefaultPrevented) { - return false; - } - - // No need to forward hardware key event to IME if IME is disabled - if (!mInputMethodAppConnected) { - return false; - } - - // No need to forward hardware key event to IME - // if this key event is generated by IME itself(from nsITextInputProcessor) - if (aEvent->mIsSynthesizedByTIP) { - return false; - } - - // No need to forward hardware key event to IME - // if the key event is handling or already handled - if (aEvent->mInputMethodAppState != WidgetKeyboardEvent::eNotHandled) { - return false; - } - - // No need to forward hardware key event to IME - // if there is no nsIHardwareKeyEventListener in use - nsCOMPtr<nsIHardwareKeyEventListener> - keyHandler(do_QueryReferent(mHardwareKeyEventListener)); - if (!keyHandler) { - return false; - } - - // Set the flags to specify the keyboard event is in forwarding phase. - aEvent->mInputMethodAppState = WidgetKeyboardEvent::eHandling; - - // For those keypress events coming after their heading keydown's reply - // already arrives, they should be dispatched directly instead of - // being stored into the event queue. Otherwise, without the heading keydown - // in the event queue, the stored keypress will never be withdrawn to be fired. - if (aEvent->mMessage == eKeyPress && mEventQueue.IsEmpty()) { - DispatchKeyPress(aTarget, *aEvent, *aEventStatus); - return true; - } - - // Push the key event into queue for reuse when its reply arrives. - KeyboardInfo* copiedInfo = - new KeyboardInfo(aTarget, - *aEvent, - aEventStatus ? *aEventStatus : nsEventStatus_eIgnore); - - // No need to forward hardware key event to IME if the event queue is full - if (!mEventQueue.Push(copiedInfo)) { - delete copiedInfo; - return false; - } - - // We only forward keydown and keyup event to input-method-app - // because input-method-app will generate keypress by itself. - if (aEvent->mMessage == eKeyPress) { - return true; - } - - // Create a keyboard event to pass into - // nsIHardwareKeyEventListener.onHardwareKey - nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget); - nsPresContext* presContext = GetPresContext(aTarget); - RefPtr<KeyboardEvent> keyboardEvent = - NS_NewDOMKeyboardEvent(eventTarget, presContext, aEvent->AsKeyboardEvent()); - // Duplicate the internal event data in the heap for the keyboardEvent, - // or the internal data from |aEvent| in the stack may be destroyed by others. - keyboardEvent->DuplicatePrivateData(); - - // Forward the created keyboard event to input-method-app - bool isSent = false; - keyHandler->OnHardwareKey(keyboardEvent, &isSent); - - // Pop the pending key event if it can't be forwarded - if (!isSent) { - mEventQueue.RemoveFront(); - } - - return isSent; -} - -NS_IMETHODIMP -HardwareKeyHandler::OnHandledByInputMethodApp(const nsAString& aType, - uint16_t aDefaultPrevented) -{ - // We can not handle this reply because the pending events had been already - // removed from the forwarding queue before this reply arrives. - if (mEventQueue.IsEmpty()) { - return NS_OK; - } - - RefPtr<KeyboardInfo> keyInfo = mEventQueue.PopFront(); - - // Only allow keydown and keyup to call this method - if (NS_WARN_IF(aType.EqualsLiteral("keydown") && - keyInfo->mEvent.mMessage != eKeyDown) || - NS_WARN_IF(aType.EqualsLiteral("keyup") && - keyInfo->mEvent.mMessage != eKeyUp)) { - return NS_ERROR_INVALID_ARG; - } - - // The value of defaultPrevented depends on whether or not - // the key is consumed by input-method-app - SetDefaultPrevented(keyInfo->mEvent, aDefaultPrevented); - - // Set the flag to specify the reply phase - keyInfo->mEvent.mInputMethodAppState = WidgetKeyboardEvent::eHandled; - - // Check whether the event is still valid to be fired - if (CanDispatchEvent(keyInfo->mTarget, keyInfo->mEvent)) { - // If the key's defaultPrevented is true, it means that the - // input-method-app has already consumed this key, - // so we can dispatch |mozbrowserafterkey*| directly if - // preference "dom.beforeAfterKeyboardEvent.enabled" is enabled. - if (keyInfo->mEvent.mFlags.mDefaultPrevented) { - DispatchAfterKeyEvent(keyInfo->mTarget, keyInfo->mEvent); - // Otherwise, it means that input-method-app doesn't handle this key, - // so we need to dispatch it to its current event target. - } else { - DispatchToTargetApp(keyInfo->mTarget, - keyInfo->mEvent, - keyInfo->mStatus); - } - } - - // No need to do further processing if the event is not keydown - if (keyInfo->mEvent.mMessage != eKeyDown) { - return NS_OK; - } - - // Update the latest keydown data: - // Release the holding reference to the previous keydown's data and - // add a reference count to the current keydown's data. - mLatestKeyDownInfo = keyInfo; - - // Handle the pending keypress event once keydown's reply arrives: - // It may have many keypress events per keydown on some platforms, - // so we use loop to dispatch keypress events. - // (But Gonk dispatch only one keypress per keydown) - // However, if there is no keypress after this keydown, - // then those following keypress will be handled in - // ForwardKeyToInputMethodApp directly. - for (KeyboardInfo* keypressInfo; - !mEventQueue.IsEmpty() && - (keypressInfo = mEventQueue.PeekFront()) && - keypressInfo->mEvent.mMessage == eKeyPress; - mEventQueue.RemoveFront()) { - DispatchKeyPress(keypressInfo->mTarget, - keypressInfo->mEvent, - keypressInfo->mStatus); - } - - return NS_OK; -} - -bool -HardwareKeyHandler::DispatchKeyPress(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus) -{ - MOZ_ASSERT(aTarget, "No target provided"); - MOZ_ASSERT(aEvent.mMessage == eKeyPress, "Event is not keypress"); - - // No need to dispatch keypress to the event target - // if the keydown event is consumed by the input-method-app. - if (mLatestKeyDownInfo && - mLatestKeyDownInfo->mEvent.mFlags.mDefaultPrevented) { - return false; - } - - // No need to dispatch keypress to the event target - // if the previous keydown event is modifier key's - if (mLatestKeyDownInfo && - mLatestKeyDownInfo->mEvent.IsModifierKeyEvent()) { - return false; - } - - // No need to dispatch keypress to the event target - // if it's invalid to be dispatched - if (!CanDispatchEvent(aTarget, aEvent)) { - return false; - } - - // Set the flag to specify the reply phase. - aEvent.mInputMethodAppState = WidgetKeyboardEvent::eHandled; - - // Dispatch the pending keypress event - bool ret = DispatchToTargetApp(aTarget, aEvent, aStatus); - - // Re-trigger EventStateManager::PostHandleKeyboardEvent for keypress - PostHandleKeyboardEvent(aTarget, aEvent, aStatus); - - return ret; -} - -void -HardwareKeyHandler::DispatchAfterKeyEvent(nsINode* aTarget, - WidgetKeyboardEvent& aEvent) -{ - MOZ_ASSERT(aTarget, "No target provided"); - - if (!PresShell::BeforeAfterKeyboardEventEnabled() || - aEvent.mMessage == eKeyPress) { - return; - } - - nsCOMPtr<nsIPresShell> presShell = GetPresShell(aTarget); - if (NS_WARN_IF(presShell)) { - presShell->DispatchAfterKeyboardEvent(aTarget, - aEvent, - aEvent.mFlags.mDefaultPrevented); - } -} - -bool -HardwareKeyHandler::DispatchToTargetApp(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus) -{ - MOZ_ASSERT(aTarget, "No target provided"); - - // Get current focused element as the event target - nsCOMPtr<nsIContent> currentTarget = GetCurrentTarget(); - if (NS_WARN_IF(!currentTarget)) { - return false; - } - - // The event target should be set to the current focused element. - // However, it might have security issue if the event is dispatched to - // the unexpected application, and it might cause unexpected operation - // in the new app. - nsCOMPtr<nsPIDOMWindowOuter> originalRootWindow = GetRootWindow(aTarget); - nsCOMPtr<nsPIDOMWindowOuter> currentRootWindow = GetRootWindow(currentTarget); - if (currentRootWindow != originalRootWindow) { - NS_WARNING("The root window is changed during the event is dispatching"); - return false; - } - - // If the current focused element is still in the same app, - // then we can use it as the current target to dispatch event. - nsCOMPtr<nsIPresShell> presShell = GetPresShell(currentTarget); - if (!presShell) { - return false; - } - - if (!presShell->CanDispatchEvent(&aEvent)) { - return false; - } - - // In-process case: the event target is in the current process - if (!PresShell::IsTargetIframe(currentTarget)) { - DispatchToCurrentProcess(presShell, currentTarget, aEvent, aStatus); - - if (presShell->CanDispatchEvent(&aEvent)) { - DispatchAfterKeyEvent(aTarget, aEvent); - } - - return true; - } - - // OOP case: the event target is in the child process - return DispatchToCrossProcess(aTarget, aEvent); - - // After the oop target receives the event from TabChild::RecvRealKeyEvent - // and return the result through TabChild::SendDispatchAfterKeyboardEvent, - // the |mozbrowserafterkey*| will be fired from - // TabParent::RecvDispatchAfterKeyboardEvent, so we don't need to dispatch - // |mozbrowserafterkey*| by ourselves in this module. -} - -void -HardwareKeyHandler::DispatchToCurrentProcess(nsIPresShell* presShell, - nsIContent* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus) -{ - EventDispatcher::Dispatch(aTarget, presShell->GetPresContext(), - &aEvent, nullptr, &aStatus, nullptr); -} - -bool -HardwareKeyHandler::DispatchToCrossProcess(nsINode* aTarget, - WidgetKeyboardEvent& aEvent) -{ - nsCOMPtr<nsIFrameLoaderOwner> remoteLoaderOwner = do_QueryInterface(aTarget); - if (NS_WARN_IF(!remoteLoaderOwner)) { - return false; - } - - RefPtr<nsFrameLoader> remoteFrameLoader = - remoteLoaderOwner->GetFrameLoader(); - if (NS_WARN_IF(!remoteFrameLoader)) { - return false; - } - - uint32_t eventMode; - remoteFrameLoader->GetEventMode(&eventMode); - if (eventMode == nsIFrameLoader::EVENT_MODE_DONT_FORWARD_TO_CHILD) { - return false; - } - - PBrowserParent* remoteBrowser = remoteFrameLoader->GetRemoteBrowser(); - TabParent* remote = static_cast<TabParent*>(remoteBrowser); - if (NS_WARN_IF(!remote)) { - return false; - } - - return remote->SendRealKeyEvent(aEvent); -} - -void -HardwareKeyHandler::PostHandleKeyboardEvent(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus) -{ - MOZ_ASSERT(aTarget, "No target provided"); - - nsPresContext* presContext = GetPresContext(aTarget); - - RefPtr<mozilla::EventStateManager> esm = presContext->EventStateManager(); - bool dispatchedToChildProcess = PresShell::IsTargetIframe(aTarget); - esm->PostHandleKeyboardEvent(&aEvent, aStatus, dispatchedToChildProcess); -} - -void -HardwareKeyHandler::SetDefaultPrevented(WidgetKeyboardEvent& aEvent, - uint16_t aDefaultPrevented) { - if (aDefaultPrevented & DEFAULT_PREVENTED) { - aEvent.mFlags.mDefaultPrevented = true; - } - - if (aDefaultPrevented & DEFAULT_PREVENTED_BY_CHROME) { - aEvent.mFlags.mDefaultPreventedByChrome = true; - } - - if (aDefaultPrevented & DEFAULT_PREVENTED_BY_CONTENT) { - aEvent.mFlags.mDefaultPreventedByContent = true; - } -} - -bool -HardwareKeyHandler::CanDispatchEvent(nsINode* aTarget, - WidgetKeyboardEvent& aEvent) -{ - nsCOMPtr<nsIPresShell> presShell = GetPresShell(aTarget); - if (NS_WARN_IF(!presShell)) { - return false; - } - return presShell->CanDispatchEvent(&aEvent); -} - -already_AddRefed<nsPIDOMWindowOuter> -HardwareKeyHandler::GetRootWindow(nsINode* aNode) -{ - // Get nsIPresShell's pointer first - nsCOMPtr<nsIPresShell> presShell = GetPresShell(aNode); - if (NS_WARN_IF(!presShell)) { - return nullptr; - } - nsCOMPtr<nsPIDOMWindowOuter> rootWindow = presShell->GetRootWindow(); - return rootWindow.forget(); -} - -already_AddRefed<nsIContent> -HardwareKeyHandler::GetCurrentTarget() -{ - nsFocusManager* fm = nsFocusManager::GetFocusManager(); - if (NS_WARN_IF(!fm)) { - return nullptr; - } - - nsCOMPtr<mozIDOMWindowProxy> focusedWindow; - fm->GetFocusedWindow(getter_AddRefs(focusedWindow)); - if (NS_WARN_IF(!focusedWindow)) { - return nullptr; - } - - auto* ourWindow = nsPIDOMWindowOuter::From(focusedWindow); - - nsCOMPtr<nsPIDOMWindowOuter> rootWindow = ourWindow->GetPrivateRoot(); - if (NS_WARN_IF(!rootWindow)) { - return nullptr; - } - - nsCOMPtr<nsPIDOMWindowOuter> focusedFrame; - nsCOMPtr<nsIContent> focusedContent = - fm->GetFocusedDescendant(rootWindow, true, getter_AddRefs(focusedFrame)); - - // If there is no focus, then we use document body instead - if (NS_WARN_IF(!focusedContent || !focusedContent->GetPrimaryFrame())) { - nsIDocument* document = ourWindow->GetExtantDoc(); - if (NS_WARN_IF(!document)) { - return nullptr; - } - - focusedContent = document->GetRootElement(); - - nsCOMPtr<nsIDOMHTMLDocument> htmlDocument = do_QueryInterface(document); - if (htmlDocument) { - nsCOMPtr<nsIDOMHTMLElement> body; - htmlDocument->GetBody(getter_AddRefs(body)); - nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body); - if (bodyContent) { - focusedContent = bodyContent; - } - } - } - - return focusedContent ? focusedContent.forget() : nullptr; -} - -nsPresContext* -HardwareKeyHandler::GetPresContext(nsINode* aNode) -{ - // Get nsIPresShell's pointer first - nsCOMPtr<nsIPresShell> presShell = GetPresShell(aNode); - if (NS_WARN_IF(!presShell)) { - return nullptr; - } - - // then use nsIPresShell to get nsPresContext's pointer - return presShell->GetPresContext(); -} - -already_AddRefed<nsIPresShell> -HardwareKeyHandler::GetPresShell(nsINode* aNode) -{ - nsIDocument* doc = aNode->OwnerDoc(); - if (NS_WARN_IF(!doc)) { - return nullptr; - } - - nsCOMPtr<nsIPresShell> presShell = doc->GetShell(); - if (NS_WARN_IF(!presShell)) { - return nullptr; - } - - return presShell.forget(); -} - -/* static */ -already_AddRefed<HardwareKeyHandler> -HardwareKeyHandler::GetInstance() -{ - if (!XRE_IsParentProcess()) { - return nullptr; - } - - if (!sInstance) { - sInstance = new HardwareKeyHandler(); - ClearOnShutdown(&sInstance); - } - - RefPtr<HardwareKeyHandler> service = sInstance.get(); - return service.forget(); -} - -} // namespace mozilla diff --git a/dom/inputmethod/HardwareKeyHandler.h b/dom/inputmethod/HardwareKeyHandler.h deleted file mode 100644 index 7520c40cd6..0000000000 --- a/dom/inputmethod/HardwareKeyHandler.h +++ /dev/null @@ -1,224 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_HardwareKeyHandler_h_ -#define mozilla_HardwareKeyHandler_h_ - -#include "mozilla/EventForwards.h" // for nsEventStatus -#include "mozilla/StaticPtr.h" -#include "mozilla/TextEvents.h" -#include "nsCOMPtr.h" -#include "nsDeque.h" -#include "nsIHardwareKeyHandler.h" -#include "nsIWeakReferenceUtils.h" // for nsWeakPtr - -class nsIContent; -class nsINode; -class nsIPresShell; -class nsPIDOMWindowOuter; -class nsPresContext; - -namespace mozilla { - -// This module will copy the events' data into its event queue for reuse -// after receiving input-method-app's reply, so we use the following struct -// for storing these information. -// RefCounted<T> is a helper class for adding reference counting mechanism. -struct KeyboardInfo : public RefCounted<KeyboardInfo> -{ - MOZ_DECLARE_REFCOUNTED_TYPENAME(KeyboardInfo) - - nsINode* mTarget; - WidgetKeyboardEvent mEvent; - nsEventStatus mStatus; - - KeyboardInfo(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus aStatus) - : mTarget(aTarget) - , mEvent(aEvent) - , mStatus(aStatus) - { - } -}; - -// The following is the type-safe wrapper around nsDeque -// for storing events' data. -// The T must be one class that supports reference counting mechanism. -// The EventQueueDeallocator will be called in nsDeque::~nsDeque() or -// nsDeque::Erase() to deallocate the objects. nsDeque::Erase() will remove -// and delete all items in the queue. See more from nsDeque.h. -template <class T> -class EventQueueDeallocator : public nsDequeFunctor -{ - virtual void* operator() (void* aObject) - { - RefPtr<T> releaseMe = dont_AddRef(static_cast<T*>(aObject)); - return nullptr; - } -}; - -// The type-safe queue to be used to store the KeyboardInfo data -template <class T> -class EventQueue : private nsDeque -{ -public: - EventQueue() - : nsDeque(new EventQueueDeallocator<T>()) - { - }; - - ~EventQueue() - { - Clear(); - } - - inline size_t GetSize() - { - return nsDeque::GetSize(); - } - - bool IsEmpty() - { - return !nsDeque::GetSize(); - } - - inline bool Push(T* aItem) - { - MOZ_ASSERT(aItem); - NS_ADDREF(aItem); - size_t sizeBefore = GetSize(); - nsDeque::Push(aItem); - if (GetSize() != sizeBefore + 1) { - NS_RELEASE(aItem); - return false; - } - return true; - } - - inline already_AddRefed<T> PopFront() - { - RefPtr<T> rv = dont_AddRef(static_cast<T*>(nsDeque::PopFront())); - return rv.forget(); - } - - inline void RemoveFront() - { - RefPtr<T> releaseMe = PopFront(); - } - - inline T* PeekFront() - { - return static_cast<T*>(nsDeque::PeekFront()); - } - - void Clear() - { - while (GetSize() > 0) { - RemoveFront(); - } - } -}; - -class HardwareKeyHandler : public nsIHardwareKeyHandler -{ -public: - HardwareKeyHandler(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIHARDWAREKEYHANDLER - - static already_AddRefed<HardwareKeyHandler> GetInstance(); - - virtual bool ForwardKeyToInputMethodApp(nsINode* aTarget, - WidgetKeyboardEvent* aEvent, - nsEventStatus* aEventStatus) override; - -private: - virtual ~HardwareKeyHandler(); - - // Return true if the keypress is successfully dispatched. - // Otherwise, return false. - bool DispatchKeyPress(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus); - - void DispatchAfterKeyEvent(nsINode* aTarget, WidgetKeyboardEvent& aEvent); - - void DispatchToCurrentProcess(nsIPresShell* aPresShell, - nsIContent* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus); - - bool DispatchToCrossProcess(nsINode* aTarget, WidgetKeyboardEvent& aEvent); - - // This method will dispatch not only key* event to its event target, - // no mather it's in the current process or in its child process, - // but also mozbrowserafterkey* to the corresponding target if it needs. - // Return true if the key is successfully dispatched. - // Otherwise, return false. - bool DispatchToTargetApp(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus); - - // This method will be called after dispatching keypress to its target, - // if the input-method-app doesn't handle the key. - // In normal dispatching path, EventStateManager::PostHandleKeyboardEvent - // will be called when event is keypress. - // However, the ::PostHandleKeyboardEvent mentioned above will be aborted - // when we try to forward key event to the input-method-app. - // If the input-method-app consumes the key, then we don't need to do anything - // because the input-method-app will generate a new key event by itself. - // On the other hand, if the input-method-app doesn't consume the key, - // then we need to dispatch the key event by ourselves - // and call ::PostHandleKeyboardEvent again after the event is forwarded. - // Note that the EventStateManager::PreHandleEvent is already called before - // forwarding, so we don't need to call it in this module. - void PostHandleKeyboardEvent(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus& aStatus); - - void SetDefaultPrevented(WidgetKeyboardEvent& aEvent, - uint16_t aDefaultPrevented); - - // Check whether the event is valid to be fired. - // This method should be called every time before dispatching next event. - bool CanDispatchEvent(nsINode* aTarget, - WidgetKeyboardEvent& aEvent); - - already_AddRefed<nsPIDOMWindowOuter> GetRootWindow(nsINode* aNode); - - already_AddRefed<nsIContent> GetCurrentTarget(); - - nsPresContext* GetPresContext(nsINode* aNode); - - already_AddRefed<nsIPresShell> GetPresShell(nsINode* aNode); - - static StaticRefPtr<HardwareKeyHandler> sInstance; - - // The event queue is used to store the forwarded keyboard events. - // Those stored events will be dispatched if input-method-app doesn't - // consume them. - EventQueue<KeyboardInfo> mEventQueue; - - // Hold the pointer to the latest keydown's data - RefPtr<KeyboardInfo> mLatestKeyDownInfo; - - // input-method-app needs to register a listener by - // |nsIHardwareKeyHandler.registerListener| to receive - // the hardware keyboard event, and |nsIHardwareKeyHandler.registerListener| - // will set an nsIHardwareKeyEventListener to mHardwareKeyEventListener. - // Then, mHardwareKeyEventListener is used to forward the event - // to the input-method-app. - nsWeakPtr mHardwareKeyEventListener; - - // To keep tracking the input-method-app is active or disabled. - bool mInputMethodAppConnected; -}; - -} // namespace mozilla - -#endif // #ifndef mozilla_HardwareKeyHandler_h_ diff --git a/dom/inputmethod/Keyboard.jsm b/dom/inputmethod/Keyboard.jsm index 22f87ffbcf..51506c41fa 100644 --- a/dom/inputmethod/Keyboard.jsm +++ b/dom/inputmethod/Keyboard.jsm @@ -24,12 +24,7 @@ XPCOMUtils.defineLazyGetter(this, "appsService", function() { }); XPCOMUtils.defineLazyGetter(this, "hardwareKeyHandler", function() { -#ifdef MOZ_B2G - return Cc["@mozilla.org/HardwareKeyHandler;1"] - .getService(Ci.nsIHardwareKeyHandler); -#else return null; -#endif }); var Utils = { @@ -50,17 +45,6 @@ var Utils = { }; this.Keyboard = { -#ifdef MOZ_B2G - // For receving keyboard event fired from hardware before it's dispatched, - // |this| object is used to be the listener to get the forwarded event. - // As the listener, |this| object must implement nsIHardwareKeyEventListener - // and nsSupportsWeakReference. - // Please see nsIHardwareKeyHandler.idl to get more information. - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIHardwareKeyEventListener, - Ci.nsISupportsWeakReference - ]), -#endif _isConnectedToHardwareKeyHandler: false, _formMM: null, // The current web page message manager. _keyboardMM: null, // The keyboard app message manager. diff --git a/dom/inputmethod/moz.build b/dom/inputmethod/moz.build index 504e2ebfc2..84b3cb8ab2 100644 --- a/dom/inputmethod/moz.build +++ b/dom/inputmethod/moz.build @@ -4,29 +4,6 @@ # 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/. -if CONFIG['MOZ_B2G']: - XPIDL_SOURCES += [ - 'nsIHardwareKeyHandler.idl', - ] - - XPIDL_MODULE = 'inputmethod' - - EXPORTS.mozilla += [ - 'HardwareKeyHandler.h', - ] - - SOURCES += [ - 'HardwareKeyHandler.cpp' - ] - - include('/ipc/chromium/chromium-config.mozbuild') - - FINAL_LIBRARY = 'xul' - LOCAL_INCLUDES += [ - '/dom/base', - '/layout/base', - ] - EXTRA_COMPONENTS += [ 'InputMethod.manifest', 'MozKeyboard.js', diff --git a/dom/inputmethod/nsIHardwareKeyHandler.idl b/dom/inputmethod/nsIHardwareKeyHandler.idl deleted file mode 100644 index 5bce4d9805..0000000000 --- a/dom/inputmethod/nsIHardwareKeyHandler.idl +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIDOMKeyEvent; - -%{C++ -#define NS_HARDWARE_KEY_HANDLER_CID \ - { 0xfb45921b, 0xe0a5, 0x45c6, \ - { 0x90, 0xd0, 0xa6, 0x97, 0xa7, 0x72, 0xc4, 0x2a } } -#define NS_HARDWARE_KEY_HANDLER_CONTRACTID \ - "@mozilla.org/HardwareKeyHandler;1" - -#include "mozilla/EventForwards.h" /* For nsEventStatus */ - -namespace mozilla { -class WidgetKeyboardEvent; -} - -using mozilla::WidgetKeyboardEvent; - -class nsINode; -%} - -/** - * This interface is used to be registered to the nsIHardwareKeyHandler through - * |nsIHardwareKeyHandler.registerListener|. - */ -[scriptable, function, uuid(cd5aeee3-b4b9-459d-85e7-c0671c7a8a2e)] -interface nsIHardwareKeyEventListener : nsISupports -{ - /** - * This method will be invoked by nsIHardwareKeyHandler to forward the native - * keyboard event to the active input method - */ - bool onHardwareKey(in nsIDOMKeyEvent aEvent); -}; - -/** - * This interface has two main roles. One is to send a hardware keyboard event - * to the active input method app and the other is to receive its reply result. - * If a keyboard event is triggered from a hardware keyboard when an editor has - * focus, the event target should be the editor. However, the text input - * processor algorithm is implemented in an input method app and it should - * handle the event earlier than the real event target to do the mapping such - * as character conversion according to the language setting or the type of a - * hardware keyboard. - */ -[scriptable, builtinclass, uuid(25b34270-caad-4d18-a910-860351690639)] -interface nsIHardwareKeyHandler : nsISupports -{ - /** - * Flags used to set the defaultPrevented's result. The default result - * from input-method-app should be set to NO_DEFAULT_PREVENTED. - * (It means the forwarded event isn't consumed by input-method-app.) - * If the input-method-app consumes the forwarded event, - * then the result should be set by DEFAULT_PREVENTED* before reply. - */ - const unsigned short NO_DEFAULT_PREVENTED = 0x0000; - const unsigned short DEFAULT_PREVENTED = 0x0001; - const unsigned short DEFAULT_PREVENTED_BY_CHROME = 0x0002; - const unsigned short DEFAULT_PREVENTED_BY_CONTENT = 0x0004; - - /** - * Registers a listener in input-method-app to receive - * the forwarded hardware keyboard events - * - * @param aListener Listener object to be notified for receiving - * the keyboard event fired from hardware - * @note A listener object must implement - * nsIHardwareKeyEventListener and - * nsSupportsWeakReference - * @see nsIHardwareKeyEventListener - * @see nsSupportsWeakReference - */ - void registerListener(in nsIHardwareKeyEventListener aListener); - - /** - * Unregisters the current listener from input-method-app - */ - void unregisterListener(); - - /** - * Notifies nsIHardwareKeyHandler that input-method-app is active. - */ - void onInputMethodAppConnected(); - - /** - * Notifies nsIHardwareKeyHandler that input-method-app is disabled. - */ - void onInputMethodAppDisconnected(); - - /** - * Input-method-app will pass the processing result that the forwarded - * event is handled or not through this method, and the nsIHardwareKeyHandler - * can use this to receive the reply of |forwardKeyToInputMethodApp| - * from the active input method. - * - * The result should contain the original event type and the info whether - * the default is prevented, also, it is prevented by chrome or content. - * - * @param aEventType The type of an original event. - * @param aDefaultPrevented State that |evt.preventDefault| - * is called by content, chrome or not. - */ - void onHandledByInputMethodApp(in DOMString aType, - in unsigned short aDefaultPrevented); - - /** - * Sends the native keyboard events triggered from hardware to the - * active input method before dispatching to its event target. - * This method only forwards keydown and keyup events. - * If the event isn't allowed to be forwarded, we should continue the - * normal event processing. For those forwarded keydown and keyup events - * We will pause the further event processing to wait for the completion - * of the event handling in the active input method app. - * Once |onHandledByInputMethodApp| is called by the input method app, - * the pending event processing can be resumed according to its reply. - * On the other hand, the keypress will never be sent to the input-method-app. - * Depending on whether the keydown's reply arrives before the keypress event - * comes, the keypress event will be handled directly or pushed into - * the event queue to wait for its heading keydown's reply. - * - * This implementation will call |nsIHardwareKeyEventListener.onHardwareKey|, - * which is registered through |nsIHardwareKeyEventListener.registerListener|, - * to forward the events. - * - * Returns true, if the event is handled in this module. - * Returns false, otherwise. - * - * If it returns false, we should continue the normal event processing. - */ - %{C++ - virtual bool ForwardKeyToInputMethodApp(nsINode* aTarget, - WidgetKeyboardEvent* aEvent, - nsEventStatus* aEventStatus) = 0; - %} -}; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index ee0f8090a2..582490d7b5 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2077,7 +2077,7 @@ ContentParent::ContentParent(mozIApplication* aApp, // PID along with the warning. nsDebugImpl::SetMultiprocessMode("Parent"); -#if defined(XP_WIN) && !defined(MOZ_B2G) +#if defined(XP_WIN) // Request Windows message deferral behavior on our side of the PContent // channel. Generally only applies to the situation where we get caught in // a deadlock with the plugin process when sending CPOWs. diff --git a/dom/ipc/TabContext.cpp b/dom/ipc/TabContext.cpp index b36dbc5ebc..362bce3a4a 100644 --- a/dom/ipc/TabContext.cpp +++ b/dom/ipc/TabContext.cpp @@ -358,12 +358,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) case IPCTabContext::TUnsafeIPCTabContext: { // XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow. // It is meant as a temporary solution until service workers can - // provide a TabChild equivalent. Don't allow this on b2g since - // it might be used to escalate privileges. -#ifdef MOZ_B2G - mInvalidReason = "ServiceWorkerClients::OpenWindow is not supported."; - return; -#endif + // provide a TabChild equivalent. if (!Preferences::GetBool("dom.serviceWorkers.enabled", false)) { mInvalidReason = "ServiceWorkers should be enabled."; return; diff --git a/dom/media/AudioStream.cpp b/dom/media/AudioStream.cpp index 82ae3ee866..54cf7b9653 100644 --- a/dom/media/AudioStream.cpp +++ b/dom/media/AudioStream.cpp @@ -333,11 +333,7 @@ AudioStream::Init(uint32_t aNumChannels, uint32_t aRate, params.rate = aRate; params.channels = mOutChannels; #if defined(__ANDROID__) -#if defined(MOZ_B2G) - params.stream_type = CubebUtils::ConvertChannelToCubebType(aAudioChannel); -#else params.stream_type = CUBEB_STREAM_TYPE_MUSIC; -#endif if (params.stream_type == CUBEB_STREAM_TYPE_MAX) { return NS_ERROR_INVALID_ARG; diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp index d1b4bae99d..fe94264eed 100644 --- a/dom/media/CubebUtils.cpp +++ b/dom/media/CubebUtils.cpp @@ -342,33 +342,6 @@ uint32_t MaxNumberOfChannels() return 0; } -#if defined(__ANDROID__) && defined(MOZ_B2G) -cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel) -{ - switch(aChannel) { - case dom::AudioChannel::Normal: - /* FALLTHROUGH */ - case dom::AudioChannel::Content: - return CUBEB_STREAM_TYPE_MUSIC; - case dom::AudioChannel::Notification: - return CUBEB_STREAM_TYPE_NOTIFICATION; - case dom::AudioChannel::Alarm: - return CUBEB_STREAM_TYPE_ALARM; - case dom::AudioChannel::Telephony: - return CUBEB_STREAM_TYPE_VOICE_CALL; - case dom::AudioChannel::Ringer: - return CUBEB_STREAM_TYPE_RING; - case dom::AudioChannel::System: - return CUBEB_STREAM_TYPE_SYSTEM; - case dom::AudioChannel::Publicnotification: - return CUBEB_STREAM_TYPE_SYSTEM_ENFORCED; - default: - NS_ERROR("The value of AudioChannel is invalid"); - return CUBEB_STREAM_TYPE_MAX; - } -} -#endif - void GetCurrentBackend(nsAString& aBackend) { cubeb* cubebContext = GetCubebContext(); diff --git a/dom/media/CubebUtils.h b/dom/media/CubebUtils.h index 171c244b78..fa5fc22948 100644 --- a/dom/media/CubebUtils.h +++ b/dom/media/CubebUtils.h @@ -40,9 +40,6 @@ void ReportCubebBackendUsed(); uint32_t GetCubebPlaybackLatencyInMilliseconds(); Maybe<uint32_t> GetCubebMSGLatencyInFrames(); bool CubebLatencyPrefSet(); -#if defined(__ANDROID__) && defined(MOZ_B2G) -cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel); -#endif void GetCurrentBackend(nsAString& aBackend); } // namespace CubebUtils diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index 40e3b72cfd..cae15eb8c2 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -640,11 +640,7 @@ AudioCallbackDriver::Init() mSampleRate = output.rate = CubebUtils::PreferredSampleRate(); #if defined(__ANDROID__) -#if defined(MOZ_B2G) - output.stream_type = CubebUtils::ConvertChannelToCubebType(mAudioChannel); -#else output.stream_type = CUBEB_STREAM_TYPE_MUSIC; -#endif if (output.stream_type == CUBEB_STREAM_TYPE_MAX) { NS_WARNING("Bad stream type"); return; diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 97a6855d97..44f330e99a 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -73,10 +73,6 @@ #include "browser_logging/WebRtcLog.h" #endif -#ifdef MOZ_B2G -#include "MediaPermissionGonk.h" -#endif - #if defined (XP_WIN) #include "mozilla/WindowsVersion.h" #include <winsock2.h> @@ -1819,10 +1815,6 @@ MediaManager::Get() { __LINE__, NS_LITERAL_STRING("Media shutdown")); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); -#ifdef MOZ_B2G - // Init MediaPermissionManager before sending out any permission requests. - (void) MediaPermissionManager::GetInstance(); -#endif //MOZ_B2G } return sSingleton; } diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 98b8debbeb..0c3021799a 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -791,7 +791,6 @@ RTCPeerConnection.prototype = { return this._havePermission; } if (this._isChrome || - AppConstants.MOZ_B2G || Services.prefs.getBoolPref("media.navigator.permission.disabled")) { return this._havePermission = Promise.resolve(); } diff --git a/dom/media/webrtc/MediaEngine.h b/dom/media/webrtc/MediaEngine.h index ff2a6e25a3..6a69885449 100644 --- a/dom/media/webrtc/MediaEngine.h +++ b/dom/media/webrtc/MediaEngine.h @@ -54,11 +54,8 @@ public: static const int DEFAULT_169_VIDEO_WIDTH = 1280; static const int DEFAULT_169_VIDEO_HEIGHT = 720; -#ifndef MOZ_B2G static const int DEFAULT_SAMPLE_RATE = 32000; -#else - static const int DEFAULT_SAMPLE_RATE = 16000; -#endif + // This allows using whatever rate the graph is using for the // MediaStreamTrack. This is useful for microphone data, we know it's already // at the correct rate for insertion in the MSG. diff --git a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp index 0b8796aa8b..1e2e13d01a 100644 --- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp +++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp @@ -741,9 +741,6 @@ MediaEngineWebRTCMicrophoneSource::AllocChannel() // Check for availability. if (!mAudioInput->SetRecordingDevice(mCapIndex)) { -#ifndef MOZ_B2G - // Because of the permission mechanism of B2G, we need to skip the status - // check here. bool avail = false; mAudioInput->GetRecordingDeviceStatus(avail); if (!avail) { @@ -752,7 +749,6 @@ MediaEngineWebRTCMicrophoneSource::AllocChannel() } return false; } -#endif // MOZ_B2G // Set "codec" to PCM, 32kHz on 1 channel ScopedCustomReleasePtr<webrtc::VoECodec> ptrVoECodec(webrtc::VoECodec::GetInterface(mVoiceEngine)); diff --git a/dom/moz.build b/dom/moz.build index 6242b4fbcd..90ea60cbef 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -115,11 +115,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': if CONFIG['MOZ_SECUREELEMENT']: DIRS += ['secureelement'] -if CONFIG['MOZ_B2G']: - DIRS += [ - 'downloads', - ] - DIRS += ['presentation'] TEST_DIRS += [ diff --git a/dom/notification/DesktopNotification.h b/dom/notification/DesktopNotification.h index e1cb2efbc7..5fd5e4c036 100644 --- a/dom/notification/DesktopNotification.h +++ b/dom/notification/DesktopNotification.h @@ -159,10 +159,6 @@ class AlertServiceObserver: public nsIObserver // forward to parent if (mNotification) { -#ifdef MOZ_B2G - if (NS_FAILED(mNotification->CheckInnerWindowCorrectness())) - return NS_ERROR_NOT_AVAILABLE; -#endif mNotification->HandleAlertServiceNotification(aTopic); } return NS_OK; diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index 979bd915f2..65be02809f 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -817,15 +817,6 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource, { NS_ENSURE_ARG_MAX(aViolatedPolicyIndex, mPolicies.Length() - 1); -#ifdef MOZ_B2G - // load group information (on process-split necko implementations like b2g). - // (fix this in bug 1011086) - if (!mCallingChannelLoadGroup) { - NS_WARNING("Load group required but not present for report sending; cannot send CSP violation reports"); - return NS_ERROR_FAILURE; - } -#endif - dom::CSPReport report; nsresult rv; diff --git a/dom/settings/SettingsService.js b/dom/settings/SettingsService.js deleted file mode 100644 index 09bd3ca722..0000000000 --- a/dom/settings/SettingsService.js +++ /dev/null @@ -1,358 +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 Ci = Components.interfaces; -const Cu = Components.utils; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import('resource://gre/modules/SettingsRequestManager.jsm'); - -/* static functions */ -var DEBUG = false; -var VERBOSE = false; - -try { - DEBUG = - Services.prefs.getBoolPref("dom.mozSettings.SettingsService.debug.enabled"); - VERBOSE = - Services.prefs.getBoolPref("dom.mozSettings.SettingsService.verbose.enabled"); -} catch (ex) { } - -function debug(s) { - dump("-*- SettingsService: " + s + "\n"); -} - -XPCOMUtils.defineLazyServiceGetter(this, "uuidgen", - "@mozilla.org/uuid-generator;1", - "nsIUUIDGenerator"); -XPCOMUtils.defineLazyServiceGetter(this, "cpmm", - "@mozilla.org/childprocessmessagemanager;1", - "nsIMessageSender"); -XPCOMUtils.defineLazyServiceGetter(this, "mrm", - "@mozilla.org/memory-reporter-manager;1", - "nsIMemoryReporterManager"); - -const nsIClassInfo = Ci.nsIClassInfo; -const kXpcomShutdownObserverTopic = "xpcom-shutdown"; - -const SETTINGSSERVICELOCK_CONTRACTID = "@mozilla.org/settingsServiceLock;1"; -const SETTINGSSERVICELOCK_CID = Components.ID("{d7a395a0-e292-11e1-834e-1761d57f5f99}"); -const nsISettingsServiceLock = Ci.nsISettingsServiceLock; - -function makeSettingsServiceRequest(aCallback, aName, aValue) { - return { - callback: aCallback, - name: aName, - value: aValue - }; -}; - -const kLockListeners = ["Settings:Get:OK", "Settings:Get:KO", - "Settings:Clear:OK", "Settings:Clear:KO", - "Settings:Set:OK", "Settings:Set:KO", - "Settings:Finalize:OK", "Settings:Finalize:KO"]; - -function SettingsServiceLock(aSettingsService, aTransactionCallback) { - if (VERBOSE) debug("settingsServiceLock constr!"); - this._open = true; - this._settingsService = aSettingsService; - this._id = uuidgen.generateUUID().toString(); - this._transactionCallback = aTransactionCallback; - this._requests = {}; - let closeHelper = function() { - if (VERBOSE) debug("closing lock " + this._id); - this._open = false; - this.runOrFinalizeQueries(); - }.bind(this); - - this.addListeners(); - - let createLockPayload = { - lockID: this._id, - isServiceLock: true, - windowID: undefined, - lockStack: (new Error).stack - }; - - this.returnMessage("Settings:CreateLock", createLockPayload); - Services.tm.currentThread.dispatch(closeHelper, Ci.nsIThread.DISPATCH_NORMAL); -} - -SettingsServiceLock.prototype = { - get closed() { - return !this._open; - }, - - addListeners: function() { - for (let msg of kLockListeners) { - cpmm.addMessageListener(msg, this); - } - }, - - removeListeners: function() { - for (let msg of kLockListeners) { - cpmm.removeMessageListener(msg, this); - } - }, - - returnMessage: function(aMessage, aData) { - SettingsRequestManager.receiveMessage({ - name: aMessage, - data: aData, - target: undefined, - principal: Services.scriptSecurityManager.getSystemPrincipal() - }); - }, - - runOrFinalizeQueries: function() { - if (!this._requests || Object.keys(this._requests).length == 0) { - this.returnMessage("Settings:Finalize", {lockID: this._id}); - } else { - this.returnMessage("Settings:Run", {lockID: this._id}); - } - }, - - receiveMessage: function(aMessage) { - - let msg = aMessage.data; - // SettingsRequestManager broadcasts changes to all locks in the child. If - // our lock isn't being addressed, just return. - if(msg.lockID != this._id) { - return; - } - if (VERBOSE) debug("receiveMessage (" + this._id + "): " + aMessage.name); - // Finalizing a transaction does not return a request ID since we are - // supposed to fire callbacks. - if (!msg.requestID) { - switch (aMessage.name) { - case "Settings:Finalize:OK": - if (VERBOSE) debug("Lock finalize ok!"); - this.callTransactionHandle(); - break; - case "Settings:Finalize:KO": - if (DEBUG) debug("Lock finalize failed!"); - this.callAbort(); - break; - default: - if (DEBUG) debug("Message type " + aMessage.name + " is missing a requestID"); - } - - this._settingsService.unregisterLock(this._id); - return; - } - - let req = this._requests[msg.requestID]; - if (!req) { - if (DEBUG) debug("Matching request not found."); - return; - } - delete this._requests[msg.requestID]; - switch (aMessage.name) { - case "Settings:Get:OK": - this._open = true; - let settings_names = Object.keys(msg.settings); - if (settings_names.length > 0) { - let name = settings_names[0]; - if (DEBUG && settings_names.length > 1) { - debug("Warning: overloaded setting:" + name); - } - let result = msg.settings[name]; - this.callHandle(req.callback, name, result); - } else { - this.callHandle(req.callback, req.name, null); - } - this._open = false; - break; - case "Settings:Set:OK": - this._open = true; - // We don't pass values back from sets in SettingsManager... - this.callHandle(req.callback, req.name, req.value); - this._open = false; - break; - case "Settings:Get:KO": - case "Settings:Set:KO": - if (DEBUG) debug("error:" + msg.errorMsg); - this.callError(req.callback, msg.error); - break; - default: - if (DEBUG) debug("Wrong message: " + aMessage.name); - } - this.runOrFinalizeQueries(); - }, - - get: function get(aName, aCallback) { - if (VERBOSE) debug("get (" + this._id + "): " + aName); - if (!this._open) { - if (DEBUG) debug("Settings lock not open!\n"); - throw Components.results.NS_ERROR_ABORT; - } - let reqID = uuidgen.generateUUID().toString(); - this._requests[reqID] = makeSettingsServiceRequest(aCallback, aName); - this.returnMessage("Settings:Get", {requestID: reqID, - lockID: this._id, - name: aName}); - }, - - set: function set(aName, aValue, aCallback) { - if (VERBOSE) debug("set: " + aName + " " + aValue); - if (!this._open) { - throw "Settings lock not open"; - } - let reqID = uuidgen.generateUUID().toString(); - this._requests[reqID] = makeSettingsServiceRequest(aCallback, aName, aValue); - let settings = {}; - settings[aName] = aValue; - this.returnMessage("Settings:Set", {requestID: reqID, - lockID: this._id, - settings: settings}); - }, - - callHandle: function callHandle(aCallback, aName, aValue) { - try { - aCallback && aCallback.handle ? aCallback.handle(aName, aValue) : null; - } catch (e) { - if (DEBUG) debug("settings 'handle' for " + aName + " callback threw an exception, dropping: " + e + "\n"); - } - }, - - callAbort: function callAbort(aCallback, aMessage) { - try { - aCallback && aCallback.handleAbort ? aCallback.handleAbort(aMessage) : null; - } catch (e) { - if (DEBUG) debug("settings 'abort' callback threw an exception, dropping: " + e + "\n"); - } - }, - - callError: function callError(aCallback, aMessage) { - try { - aCallback && aCallback.handleError ? aCallback.handleError(aMessage) : null; - } catch (e) { - if (DEBUG) debug("settings 'error' callback threw an exception, dropping: " + e + "\n"); - } - }, - - callTransactionHandle: function callTransactionHandle() { - try { - this._transactionCallback && this._transactionCallback.handle ? this._transactionCallback.handle() : null; - } catch (e) { - if (DEBUG) debug("settings 'Transaction handle' callback threw an exception, dropping: " + e + "\n"); - } - }, - - classID : SETTINGSSERVICELOCK_CID, - QueryInterface : XPCOMUtils.generateQI([nsISettingsServiceLock]) -}; - -const SETTINGSSERVICE_CID = Components.ID("{f656f0c0-f776-11e1-a21f-0800200c9a66}"); - -function SettingsService() -{ - if (VERBOSE) debug("settingsService Constructor"); - this._locks = []; - this._serviceLocks = {}; - this._createdLocks = 0; - this._unregisteredLocks = 0; - this.init(); -} - -SettingsService.prototype = { - - init: function() { - Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false); - mrm.registerStrongReporter(this); - }, - - uninit: function() { - Services.obs.removeObserver(this, kXpcomShutdownObserverTopic); - mrm.unregisterStrongReporter(this); - }, - - observe: function(aSubject, aTopic, aData) { - if (VERBOSE) debug("observe: " + aTopic); - if (aTopic === kXpcomShutdownObserverTopic) { - this.uninit(); - } - }, - - receiveMessage: function(aMessage) { - if (VERBOSE) debug("Entering receiveMessage"); - - let lockID = aMessage.data.lockID; - if (!lockID) { - if (DEBUG) debug("No lock ID"); - return; - } - - if (!(lockID in this._serviceLocks)) { - if (DEBUG) debug("Received message for lock " + lockID + " but no lock"); - return; - } - - if (VERBOSE) debug("Delivering message"); - this._serviceLocks[lockID].receiveMessage(aMessage); - }, - - createLock: function createLock(aCallback) { - if (VERBOSE) debug("Calling createLock"); - var lock = new SettingsServiceLock(this, aCallback); - if (VERBOSE) debug("Created lock " + lock._id); - this.registerLock(lock); - return lock; - }, - - registerLock: function(aLock) { - if (VERBOSE) debug("Registering lock " + aLock._id); - this._locks.push(aLock._id); - this._serviceLocks[aLock._id] = aLock; - this._createdLocks++; - }, - - unregisterLock: function(aLockID) { - let lock_index = this._locks.indexOf(aLockID); - if (lock_index != -1) { - if (VERBOSE) debug("Unregistering lock " + aLockID); - this._locks.splice(lock_index, 1); - this._serviceLocks[aLockID].removeListeners(); - this._serviceLocks[aLockID] = null; - delete this._serviceLocks[aLockID]; - this._unregisteredLocks++; - } - }, - - collectReports: function(aCallback, aData, aAnonymize) { - aCallback.callback("", - "settings-service-locks/alive", - Ci.nsIMemoryReporter.KIND_OTHER, - Ci.nsIMemoryReporter.UNITS_COUNT, - this._locks.length, - "The number of service locks that are currently alives.", - aData); - - aCallback.callback("", - "settings-service-locks/created", - Ci.nsIMemoryReporter.KIND_OTHER, - Ci.nsIMemoryReporter.UNITS_COUNT, - this._createdLocks, - "The number of service locks that were created.", - aData); - - aCallback.callback("", - "settings-service-locks/deleted", - Ci.nsIMemoryReporter.KIND_OTHER, - Ci.nsIMemoryReporter.UNITS_COUNT, - this._unregisteredLocks, - "The number of service locks that were deleted.", - aData); - }, - - classID : SETTINGSSERVICE_CID, - QueryInterface : XPCOMUtils.generateQI([Ci.nsISettingsService, - Ci.nsIObserver, - Ci.nsIMemoryReporter]) -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SettingsService, SettingsServiceLock]); diff --git a/dom/settings/SettingsService.manifest b/dom/settings/SettingsService.manifest deleted file mode 100644 index ae464f921b..0000000000 --- a/dom/settings/SettingsService.manifest +++ /dev/null @@ -1,5 +0,0 @@ -component {d7a395a0-e292-11e1-834e-1761d57f5f99} SettingsService.js -contract @mozilla.org/settingsServiceLock;1 {d7a395a0-e292-11e1-834e-1761d57f5f99} - -component {f656f0c0-f776-11e1-a21f-0800200c9a66} SettingsService.js -contract @mozilla.org/settingsService;1 {f656f0c0-f776-11e1-a21f-0800200c9a66} diff --git a/dom/settings/moz.build b/dom/settings/moz.build index 426edcbce8..580a55e6a4 100644 --- a/dom/settings/moz.build +++ b/dom/settings/moz.build @@ -12,12 +12,6 @@ EXTRA_PP_COMPONENTS += [ 'SettingsManager.js' ] -if CONFIG['MOZ_B2G']: - EXTRA_COMPONENTS += [ - 'SettingsService.js', - 'SettingsService.manifest', - ] - EXTRA_JS_MODULES += [ 'SettingsDB.jsm', 'SettingsRequestManager.jsm' diff --git a/dom/settings/tests/chrome.ini b/dom/settings/tests/chrome.ini index 92b1554a00..5b0db9e40f 100644 --- a/dom/settings/tests/chrome.ini +++ b/dom/settings/tests/chrome.ini @@ -4,13 +4,7 @@ support-files = file_loadserver.js file_bug1110872.js file_bug1110872.html - test_settings_service.js - test_settings_service_callback.js -[test_settings_service.xul] -run-if = buildapp == 'b2g' || buildapp == 'mulet' -[test_settings_service_callback.xul] -run-if = buildapp == 'b2g' || buildapp == 'mulet' [test_settings_basics.html] [test_settings_permissions.html] [test_settings_blobs.html] diff --git a/dom/settings/tests/test_settings_service.js b/dom/settings/tests/test_settings_service.js deleted file mode 100644 index 132877a5d4..0000000000 --- a/dom/settings/tests/test_settings_service.js +++ /dev/null @@ -1,138 +0,0 @@ -"use strict"; - -var Cu = Components.utils; -var Cc = Components.classes; -var Ci = Components.interfaces; - -if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/SettingsRequestManager.jsm"); -} - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -SimpleTest.waitForExplicitFinish(); - -XPCOMUtils.defineLazyServiceGetter(this, "SettingsService", - "@mozilla.org/settingsService;1", - "nsISettingsService"); - -var tests = [ - /* Callback tests */ - function() { - let callbackCount = 10; - - let callback = { - handle: function(name, result) { - switch (callbackCount) { - case 10: - case 9: - is(result, true, "result is true"); - break; - case 8: - case 7: - is(result, false, "result is false"); - break; - case 6: - case 5: - is(result, 9, "result is 9"); - break; - case 4: - case 3: - is(result, 9.4, "result is 9.4"); - break; - case 2: - is(result, false, "result is false"); - break; - case 1: - is(result, null, "result is null"); - break; - default: - ok(false, "Unexpected call: " + callbackCount); - } - - --callbackCount; - if (callbackCount === 0) { - next(); - } - }, - - handleError: function(name) { - ok(false, "error: " + name); - } - }; - - let lock = SettingsService.createLock(); - let lock1 = SettingsService.createLock(); - - lock.set("asdf", true, callback, null); - lock1.get("asdf", callback); - lock.get("asdf", callback); - lock.set("asdf", false, callback, null); - lock.get("asdf", callback); - lock.set("int", 9, callback, null); - lock.get("int", callback); - lock.set("doub", 9.4, callback, null); - lock.get("doub", callback); - lock1.get("asdfxxx", callback); - }, - - /* Observer tests */ - function() { - const MOZSETTINGS_CHANGED = "mozsettings-changed"; - const TEST_OBSERVER_KEY = "test.observer.key"; - const TEST_OBSERVER_VALUE = true; - const TEST_OBSERVER_MESSAGE = "test.observer.message"; - - var obs = { - observe: function (subject, topic, data) { - - if (topic !== MOZSETTINGS_CHANGED) { - ok(false, "Event is not mozsettings-changed."); - return; - } - // Data is now stored in subject - if ("wrappedJSObject" in subject) { - ok(true, "JS object wrapped into subject"); - subject = subject.wrappedJSObject; - } - if (subject["key"] != TEST_OBSERVER_KEY) { - return; - } - - function checkProp(name, type, value) { - ok(name in subject, "subject." + name + " is present"); - is(typeof subject[name], type, "subject." + name + " is " + type); - is(subject[name], value, "subject." + name + " is " + value); - } - - checkProp("key", "string", TEST_OBSERVER_KEY); - checkProp("value", "boolean", TEST_OBSERVER_VALUE); - checkProp("isInternalChange", "boolean", true); - - Services.obs.removeObserver(this, MOZSETTINGS_CHANGED); - next(); - } - }; - - Services.obs.addObserver(obs, MOZSETTINGS_CHANGED, false); - - let lock = SettingsService.createLock(); - lock.set(TEST_OBSERVER_KEY, TEST_OBSERVER_VALUE, null); - } -]; - -function next() { - let step = tests.shift(); - if (step) { - try { - step(); - } catch(e) { - ok(false, "Test threw: " + e); - } - } else { - SimpleTest.finish(); - } -} - -next(); diff --git a/dom/settings/tests/test_settings_service.xul b/dom/settings/tests/test_settings_service.xul deleted file mode 100644 index 58a9efad96..0000000000 --- a/dom/settings/tests/test_settings_service.xul +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=678695 ---> -<window title="Mozilla Bug 678695" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=678695" - target="_blank">Mozilla Bug 678695</a> - </body> - - <script type="application/javascript;version=1.7" src="test_settings_service.js" /> -</window> diff --git a/dom/settings/tests/test_settings_service_callback.js b/dom/settings/tests/test_settings_service_callback.js deleted file mode 100644 index a780bb9c32..0000000000 --- a/dom/settings/tests/test_settings_service_callback.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -var Cu = Components.utils; -var Cc = Components.classes; -var Ci = Components.interfaces; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -SimpleTest.waitForExplicitFinish(); - -XPCOMUtils.defineLazyServiceGetter(this, "SettingsService", - "@mozilla.org/settingsService;1", - "nsISettingsService"); - -var tests = [ - function () { - let callback = { - handle: function() { - ok(true, "handle called!"); - next(); - }, - - handleAbort: function(name) { - ok(false, "error: " + name); - next(); - } - } - let lock = SettingsService.createLock(callback); - lock.set("xasdf", true, null, null); - } -]; - -function next() { - let step = tests.shift(); - if (step) { - try { - step(); - } catch(e) { - ok(false, "Test threw: " + e); - } - } else { - SimpleTest.finish(); - } -} - -next(); diff --git a/dom/settings/tests/test_settings_service_callback.xul b/dom/settings/tests/test_settings_service_callback.xul deleted file mode 100644 index 3e4d277515..0000000000 --- a/dom/settings/tests/test_settings_service_callback.xul +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=1012214 ---> -<window title="Mozilla Bug 1012214" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1012214" - target="_blank">Mozilla Bug 1012214</a> - </body> - - <script type="application/javascript;version=1.7" src="test_settings_service_callback.js" /> -</window> diff --git a/dom/webidl/MozApplicationEvent.webidl b/dom/webidl/MozApplicationEvent.webidl deleted file mode 100644 index e46fdca06b..0000000000 --- a/dom/webidl/MozApplicationEvent.webidl +++ /dev/null @@ -1,16 +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/. - */ - -[Constructor(DOMString type, optional MozApplicationEventInit eventInitDict), ChromeOnly] -interface MozApplicationEvent : Event -{ - readonly attribute DOMApplication? application; -}; - -dictionary MozApplicationEventInit : EventInit -{ - DOMApplication? application = null; -}; diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 36b1f0313b..560313680a 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -343,12 +343,6 @@ partial interface Window { attribute EventHandler onuserproximity; attribute EventHandler ondevicelight; -#ifdef MOZ_B2G - attribute EventHandler onmoztimechange; - attribute EventHandler onmoznetworkupload; - attribute EventHandler onmoznetworkdownload; -#endif - void dump(DOMString str); /** diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 8469c90012..b246b410c6 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -779,14 +779,6 @@ if CONFIG['MOZ_PHOENIX'] or CONFIG['MOZ_FENNEC'] or CONFIG['MOZ_XULRUNNER']: 'External.webidl', ] -if CONFIG['MOZ_B2G']: - WEBIDL_FILES += [ - 'MozApplicationEvent.webidl' - ] - GENERATED_EVENTS_WEBIDL_FILES += [ - 'MozApplicationEvent.webidl' - ] - if CONFIG['ACCESSIBILITY']: WEBIDL_FILES += [ 'AccessibleNode.webidl', diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index d3696dd948..c448308121 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -1666,18 +1666,6 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal, id = aID; } -#ifdef MOZ_B2G - // When we do the initial addition of the permissions we don't want to - // inherit session specific permissions from other tabs or apps - // so we ignore them and set the permission to PROMPT_ACTION if it was - // previously allowed or denied by the user. - if (aIgnoreSessionPermissions && - aExpireType == nsIPermissionManager::EXPIRE_SESSION) { - aPermission = nsIPermissionManager::PROMPT_ACTION; - aExpireType = nsIPermissionManager::EXPIRE_NEVER; - } -#endif // MOZ_B2G - entry->GetPermissions().AppendElement(PermissionEntry(id, typeIndex, aPermission, aExpireType, aExpireTime, aModificationTime)); diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 130bce1191..22be44ed68 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -33,9 +33,6 @@ namespace gl { StaticMutex GLLibraryEGL::sMutex; GLLibraryEGL sEGLLibrary; -#ifdef MOZ_B2G -MOZ_THREAD_LOCAL(EGLContext) GLLibraryEGL::sCurrentContext; -#endif // should match the order of EGLExtensions, and be null-terminated. static const char* sEGLExtensionNames[] = { @@ -305,11 +302,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId mozilla::ScopedGfxFeatureReporter reporter("EGL"); -#ifdef MOZ_B2G - if (!sCurrentContext.init()) - MOZ_CRASH("GFX: Tls init failed"); -#endif - #ifdef XP_WIN if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and diff --git a/gfx/gl/GLLibraryEGL.h b/gfx/gl/GLLibraryEGL.h index fa6ea748b6..88fce067ea 100644 --- a/gfx/gl/GLLibraryEGL.h +++ b/gfx/gl/GLLibraryEGL.h @@ -656,32 +656,12 @@ public: static void AfterGLCall(const char* glFunction); #endif -#ifdef MOZ_B2G - EGLContext CachedCurrentContext() { - return sCurrentContext.get(); - } - void UnsetCachedCurrentContext() { - sCurrentContext.set(nullptr); - } - void SetCachedCurrentContext(EGLContext aCtx) { - sCurrentContext.set(aCtx); - } - bool CachedCurrentContextMatches() { - return sCurrentContext.get() == fGetCurrentContext(); - } - -private: - static MOZ_THREAD_LOCAL(EGLContext) sCurrentContext; -public: - -#else EGLContext CachedCurrentContext() { return nullptr; } void UnsetCachedCurrentContext() {} void SetCachedCurrentContext(EGLContext aCtx) { } bool CachedCurrentContextMatches() { return true; } -#endif private: bool mInitialized; diff --git a/gfx/layers/Compositor.cpp b/gfx/layers/Compositor.cpp index ce7eb90084..b623b8de92 100644 --- a/gfx/layers/Compositor.cpp +++ b/gfx/layers/Compositor.cpp @@ -173,9 +173,7 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags, const gfx::Matrix4x4& aTransform, uint32_t aFlashCounter) { -#ifdef MOZ_B2G - int lWidth = 4; -#elif defined(ANDROID) +#if defined(ANDROID) int lWidth = 10; #else int lWidth = 2; diff --git a/gfx/layers/ipc/LayerTransactionChild.cpp b/gfx/layers/ipc/LayerTransactionChild.cpp index 8b60d3b516..f07e2c27f3 100644 --- a/gfx/layers/ipc/LayerTransactionChild.cpp +++ b/gfx/layers/ipc/LayerTransactionChild.cpp @@ -72,15 +72,6 @@ void LayerTransactionChild::ActorDestroy(ActorDestroyReason why) { mDestroyed = true; -#ifdef MOZ_B2G - // Due to poor lifetime management of gralloc (and possibly shmems) we will - // crash at some point in the future when we get destroyed due to abnormal - // shutdown. Its better just to crash here. On desktop though, we have a chance - // of recovering. - if (why == AbnormalShutdown) { - NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild"); - } -#endif } } // namespace layers diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a468592fe9..4db7bc29f1 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2399,11 +2399,10 @@ gfxPlatform::GetTilesSupportInfo(mozilla::widget::InfoObject& aObj) /*static*/ bool gfxPlatform::AsyncPanZoomEnabled() { -#if !defined(MOZ_B2G) && !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT) - // For XUL applications (everything but B2G on mobile and desktop, and - // Firefox on Android) we only want to use APZ when E10S is enabled. If - // we ever get input events off the main thread we can consider relaxing - // this requirement. +#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT) + // For XUL applications (everything but Firefox on Android) we only want + // to use APZ when E10S is enabled. If we ever get input events off the + // main thread we can consider relaxing this requirement. if (!BrowserTabsRemoteAutostart()) { return false; } diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 70e2387d5d..7861f3e2d3 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -27,13 +27,8 @@ using mozilla::Move; // Undo the damage done by mozzconf.h #undef compress -// Logging seems to be somewhat broken on b2g. -#ifdef MOZ_B2G -#define IPC_LOG(...) -#else static mozilla::LazyLogModule sLogModule("ipc"); #define IPC_LOG(...) MOZ_LOG(sLogModule, LogLevel::Debug, (__VA_ARGS__)) -#endif /* * IPC design: diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 9269c2ab6d..1832854398 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -2346,15 +2346,7 @@ ContainerState::GetLayerCreationHint(AnimatedGeometryRoot* aAnimatedGeometryRoot break; } nsIScrollableFrame* scrollable = do_QueryFrame(fParent); - if (scrollable - #ifdef MOZ_B2G - && scrollable->WantAsyncScroll() - #endif - ) { - // WantAsyncScroll() returns false when the frame has overflow:hidden, - // so we won't create tiled layers for overflow:hidden frames even if - // they have a display port. The main purpose of the WantAsyncScroll check - // is to allow the B2G camera app to use hardware composer for compositing. + if (scrollable) { return LayerManager::SCROLLABLE; } } diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 5990402ed5..4016cc0a99 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -51,10 +51,6 @@ #include "nsFrameState.h" #include "Units.h" -#ifdef MOZ_B2G -#include "nsIHardwareKeyHandler.h" -#endif - class nsDocShell; class nsIDocument; class nsIFrame; @@ -1766,11 +1762,6 @@ protected: // moving/sizing loop is running, see bug 491700 for details. nsCOMPtr<nsITimer> mReflowContinueTimer; -#ifdef MOZ_B2G - // Forward hardware key events to the input-method-app - nsCOMPtr<nsIHardwareKeyHandler> mHardwareKeyHandler; -#endif // MOZ_B2G - #ifdef DEBUG nsIFrame* mDrawEventTargetFrame; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 42b39c8607..0b88948c35 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -201,10 +201,6 @@ #include "nsIDocShellTreeOwner.h" #endif -#ifdef MOZ_B2G -#include "nsIHardwareKeyHandler.h" -#endif - #ifdef MOZ_TASK_TRACER #include "GeckoTaskTracer.h" using namespace mozilla::tasktracer; @@ -7236,38 +7232,6 @@ PresShell::HandleKeyboardEvent(nsINode* aTarget, DispatchAfterKeyboardEventInternal(chain, aEvent, aEvent.DefaultPrevented()); } -#ifdef MOZ_B2G -bool -PresShell::ForwardKeyToInputMethodApp(nsINode* aTarget, - WidgetKeyboardEvent& aEvent, - nsEventStatus* aStatus) -{ - if (!XRE_IsParentProcess() || aEvent.mIsSynthesizedByTIP || - aEvent.IsKeyEventOnPlugin()) { - return false; - } - - if (!mHardwareKeyHandler) { - nsresult rv; - mHardwareKeyHandler = - do_GetService("@mozilla.org/HardwareKeyHandler;1", &rv); - if (!NS_SUCCEEDED(rv) || !mHardwareKeyHandler) { - return false; - } - } - - if (mHardwareKeyHandler->ForwardKeyToInputMethodApp(aTarget, - aEvent.AsKeyboardEvent(), - aStatus)) { - // No need to dispatch the forwarded keyboard event to it's child process - aEvent.mFlags.mNoCrossProcessBoundaryForwarding = true; - return true; - } - - return false; -} -#endif // MOZ_B2G - bool PresShell::ForwardKeyToInputMethodAppOrDispatch(bool aIsTargetRemote, nsINode* aTarget, @@ -7275,41 +7239,9 @@ PresShell::ForwardKeyToInputMethodAppOrDispatch(bool aIsTargetRemote, nsEventStatus* aStatus, EventDispatchingCallback* aEventCB) { -#ifndef MOZ_B2G - // No need to forward to input-method-app if the platform isn't run on B2G. EventDispatcher::Dispatch(aTarget, mPresContext, &aEvent, nullptr, aStatus, aEventCB); return false; -#else - // In-process case: the event target is in the current process - if (!aIsTargetRemote) { - if(ForwardKeyToInputMethodApp(aTarget, aEvent, aStatus)) { - return true; - } - - // If the keyboard event isn't forwarded to the input-method-app, - // then it should be dispatched to its event target directly. - EventDispatcher::Dispatch(aTarget, mPresContext, - &aEvent, nullptr, aStatus, aEventCB); - - return false; - } - - // OOP case: the event target is in its child process. - // Dispatch the keyboard event to the iframe that embeds the remote - // event target first. - EventDispatcher::Dispatch(aTarget, mPresContext, - &aEvent, nullptr, aStatus, aEventCB); - - // If the event is defaultPrevented, then there is no need to forward it - // to the input-method-app. - if (aEvent.mFlags.mDefaultPrevented) { - return false; - } - - // Try forwarding to the input-method-app. - return ForwardKeyToInputMethodApp(aTarget, aEvent, aStatus); -#endif // MOZ_B2G } nsresult diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index ad4ede08bb..7a9056a383 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -815,15 +815,6 @@ protected: bool aEmbeddedCancelled, size_t aChainIndex = 0); -#ifdef MOZ_B2G - // This method is used to forward the keyboard event to the input-method-app - // before the event is dispatched to its event target. - // Return true if it's successfully forwarded. Otherwise, return false. - bool ForwardKeyToInputMethodApp(nsINode* aTarget, - mozilla::WidgetKeyboardEvent& aEvent, - nsEventStatus* aStatus); -#endif // MOZ_B2G - // This method tries forwarding key events to the input-method-editor(IME). // If the event isn't be forwarded, then it will be dispathed to its target. // Return true when event is successfully forwarded to the input-method-editor. diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index ab301a6277..ae0db06abd 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -213,11 +213,6 @@ static void Shutdown(); #include "mozilla/TextInputProcessor.h" -#ifdef MOZ_B2G -#include "nsIHardwareKeyHandler.h" -#include "mozilla/HardwareKeyHandler.h" -#endif - using namespace mozilla; using namespace mozilla::dom; using mozilla::dom::power::PowerManagerService; @@ -608,11 +603,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(UDPSocketChild) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(GeckoMediaPluginService, GeckoMediaPluginService::GetGeckoMediaPluginService) -#ifdef MOZ_B2G -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIHardwareKeyHandler, - HardwareKeyHandler::GetInstance) -#endif - #ifdef ACCESSIBILITY #include "xpcAccessibilityService.h" @@ -788,10 +778,6 @@ NS_DEFINE_NAMED_CID(PRESENTATION_TCP_SESSION_TRANSPORT_CID); NS_DEFINE_NAMED_CID(TEXT_INPUT_PROCESSOR_CID); -#ifdef MOZ_B2G -NS_DEFINE_NAMED_CID(NS_HARDWARE_KEY_HANDLER_CID); -#endif - static nsresult CreateWindowCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) @@ -1063,9 +1049,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor }, { &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor }, { &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor }, -#ifdef MOZ_B2G - { &kNS_HARDWARE_KEY_HANDLER_CID, false, nullptr, nsIHardwareKeyHandlerConstructor }, -#endif { nullptr } }; @@ -1210,9 +1193,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID }, { PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID, &kPRESENTATION_TCP_SESSION_TRANSPORT_CID }, { "@mozilla.org/text-input-processor;1", &kTEXT_INPUT_PROCESSOR_CID }, -#ifdef MOZ_B2G - { NS_HARDWARE_KEY_HANDLER_CONTRACTID, &kNS_HARDWARE_KEY_HANDLER_CID }, -#endif { nullptr } }; diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index f664845b6d..ccdc3a0cea 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1266,7 +1266,7 @@ ScrollFrameHelper::HandleScrollbarStyleSwitching() } } -#if defined(MOZ_B2G) || defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) static bool IsFocused(nsIContent* aContent) { // Some content elements, like the GetContent() of a scroll frame @@ -1315,7 +1315,7 @@ ScrollFrameHelper::WantAsyncScroll() const bool isHScrollable = (scrollRange.width >= oneDevPixel) && (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN); -#if defined(MOZ_B2G) || defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) // Mobile platforms need focus to scroll. bool canScrollWithoutScrollbars = IsFocused(mOuter->GetContent()); #else diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index f36819236f..31867ca0ac 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -466,9 +466,7 @@ Preferences::IsServiceAvailable() bool Preferences::InitStaticMembers() { -#ifndef MOZ_B2G MOZ_ASSERT(NS_IsMainThread()); -#endif if (!sShutdown && !sPreferences) { nsCOMPtr<nsIPrefService> prefService = diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 225ba2447f..59476b9de9 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1260,7 +1260,7 @@ pref("javascript.options.wasm", false); pref("javascript.options.wasm_baselinejit", false); pref("javascript.options.native_regexp", true); pref("javascript.options.parallel_parsing", true); -#if !defined(RELEASE_OR_BETA) && !defined(ANDROID) && !defined(MOZ_B2G) && !defined(XP_IOS) +#if !defined(RELEASE_OR_BETA) && !defined(ANDROID) && !defined(XP_IOS) pref("javascript.options.asyncstack", true); #else pref("javascript.options.asyncstack", false); @@ -2144,14 +2144,6 @@ pref("font.name.monospace.x-math", "monospace"); // These fonts are ignored the underline offset, instead of it, the underline is lowered to bottom of its em descent. pref("font.blacklist.underline_offset", "FangSong,Gulim,GulimChe,MingLiU,MingLiU-ExtB,MingLiU_HKSCS,MingLiU-HKSCS-ExtB,MS Gothic,MS Mincho,MS PGothic,MS PMincho,MS UI Gothic,PMingLiU,PMingLiU-ExtB,SimHei,SimSun,SimSun-ExtB,Hei,Kai,Apple LiGothic,Apple LiSung,Osaka"); -#ifdef MOZ_B2G -// Whitelist of fonts that ship with B2G that do not include space lookups in -// default features. This allows us to skip analyzing the GSUB/GPOS tables -// unless features are explicitly enabled. -// Use NSPR_LOG_MODULES=fontinit:5 to dump out details of space lookups -pref("font.whitelist.skip_default_features_space_check", "Fira Sans,Fira Mono"); -#endif - pref("images.dither", "auto"); pref("security.directory", ""); @@ -2521,7 +2513,7 @@ pref("layout.css.text-justify.enabled", true); // Is support for CSS "float: inline-{start,end}" and // "clear: inline-{start,end}" enabled? -#if defined(MOZ_B2G) || !defined(RELEASE_OR_BETA) +#if !defined(RELEASE_OR_BETA) pref("layout.css.float-logical-values.enabled", true); #else pref("layout.css.float-logical-values.enabled", false); @@ -4185,7 +4177,7 @@ pref("gfx.font_rendering.fontconfig.max_generic_substitutions", 3); #endif #endif -#if defined(ANDROID) || defined(MOZ_B2G) +#if defined(ANDROID) pref("font.size.fixed.ar", 12); @@ -4203,73 +4195,10 @@ pref("font.size.fixed.x-unicode", 12); pref("font.default.x-western", "sans-serif"); pref("font.size.fixed.x-western", 12); -# ANDROID || MOZ_B2G +# ANDROID #endif -#if defined(MOZ_B2G) -// Gonk, FxOS Simulator, B2G Desktop and Mulet. - -// TODO: some entries could probably be cleaned up. - -// ar - -pref("font.name.serif.el", "Droid Serif"); // not Charis SIL Compact, only has a few Greek chars -pref("font.name.sans-serif.el", "Fira Sans"); -pref("font.name.monospace.el", "Fira Mono"); - -pref("font.name.serif.he", "Charis SIL Compact"); -pref("font.name.sans-serif.he", "Fira Sans"); -pref("font.name.monospace.he", "Fira Mono"); -pref("font.name-list.sans-serif.he", "Droid Sans Hebrew, Fira Sans"); - -pref("font.name.serif.ja", "Charis SIL Compact"); -pref("font.name.sans-serif.ja", "Fira Sans"); -pref("font.name.monospace.ja", "MotoyaLMaru"); -pref("font.name-list.sans-serif.ja", "Fira Sans, MotoyaLMaru, MotoyaLCedar, Droid Sans Japanese"); -pref("font.name-list.monospace.ja", "MotoyaLMaru, MotoyaLCedar, Fira Mono"); - -pref("font.name.serif.ko", "Charis SIL Compact"); -pref("font.name.sans-serif.ko", "Fira Sans"); -pref("font.name.monospace.ko", "Fira Mono"); - -pref("font.name.serif.th", "Charis SIL Compact"); -pref("font.name.sans-serif.th", "Fira Sans"); -pref("font.name.monospace.th", "Fira Mono"); -pref("font.name-list.sans-serif.th", "Fira Sans, Noto Sans Thai, Droid Sans Thai"); - -pref("font.name.serif.x-cyrillic", "Charis SIL Compact"); -pref("font.name.sans-serif.x-cyrillic", "Fira Sans"); -pref("font.name.monospace.x-cyrillic", "Fira Mono"); - -pref("font.name.serif.x-unicode", "Charis SIL Compact"); -pref("font.name.sans-serif.x-unicode", "Fira Sans"); -pref("font.name.monospace.x-unicode", "Fira Mono"); - -pref("font.name.serif.x-western", "Charis SIL Compact"); -pref("font.name.sans-serif.x-western", "Fira Sans"); -pref("font.name.monospace.x-western", "Fira Mono"); - -pref("font.name.serif.zh-CN", "Charis SIL Compact"); -pref("font.name.sans-serif.zh-CN", "Fira Sans"); -pref("font.name.monospace.zh-CN", "Fira Mono"); -pref("font.name-list.sans-serif.zh-CN", "Fira Sans,Droid Sans Fallback"); - -pref("font.name.serif.zh-HK", "Charis SIL Compact"); -pref("font.name.sans-serif.zh-HK", "Fira Sans"); -pref("font.name.monospace.zh-HK", "Fira Mono"); -pref("font.name-list.sans-serif.zh-HK", "Fira Sans,Droid Sans Fallback"); - -pref("font.name.serif.zh-TW", "Charis SIL Compact"); -pref("font.name.sans-serif.zh-TW", "Fira Sans"); -pref("font.name.monospace.zh-TW", "Fira Mono"); -pref("font.name-list.sans-serif.zh-TW", "Fira Sans,Droid Sans Fallback"); - -pref("font.name.serif.x-math", "Latin Modern Math"); -pref("font.name-list.serif.x-math", "Latin Modern Math, XITS Math, Cambria Math, Libertinus Math, DejaVu Math TeX Gyre, TeX Gyre Bonum Math, TeX Gyre Pagella Math, TeX Gyre Schola, TeX Gyre Termes Math, STIX Math, Asana Math, STIXGeneral, DejaVu Serif, DejaVu Sans, Charis SIL Compact"); -pref("font.name.sans-serif.x-math", "Fira Sans"); -pref("font.name.monospace.x-math", "Fira Mono"); - -#elif defined(ANDROID) +#if defined(ANDROID) // We use the bundled fonts for Firefox for Android pref("font.name-list.emoji", "Noto Color Emoji"); diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp index 046a694190..8aaf4077bb 100644 --- a/modules/libpref/prefapi.cpp +++ b/modules/libpref/prefapi.cpp @@ -573,9 +573,7 @@ nsresult PREF_GetBoolPref(const char *pref_name, bool * return_value, bool get_d nsresult PREF_DeleteBranch(const char *branch_name) { -#ifndef MOZ_B2G MOZ_ASSERT(NS_IsMainThread()); -#endif int len = (int)strlen(branch_name); @@ -636,9 +634,7 @@ PREF_ClearUserPref(const char *pref_name) nsresult PREF_ClearAllUserPrefs() { -#ifndef MOZ_B2G MOZ_ASSERT(NS_IsMainThread()); -#endif if (!gHashTable) return NS_ERROR_NOT_INITIALIZED; @@ -739,18 +735,14 @@ static PrefTypeFlags pref_SetValue(PrefValue* existingValue, PrefTypeFlags flags PrefHashEntry* pref_HashTableLookup(const char *key) { -#ifndef MOZ_B2G MOZ_ASSERT(NS_IsMainThread()); -#endif return static_cast<PrefHashEntry*>(gHashTable->Search(key)); } nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags) { -#ifndef MOZ_B2G MOZ_ASSERT(NS_IsMainThread()); -#endif if (!gHashTable) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozglue/misc/TimeStamp.h b/mozglue/misc/TimeStamp.h index a1a0eb3607..bec3ae591d 100644 --- a/mozglue/misc/TimeStamp.h +++ b/mozglue/misc/TimeStamp.h @@ -216,10 +216,7 @@ public: } double operator/(const BaseTimeDuration& aOther) const { -#ifndef MOZ_B2G - // Bug 1066388 - This fails on B2G ICS Emulator MOZ_ASSERT(aOther.mValue != 0, "Division by zero"); -#endif return ValueCalculator::DivideDouble(mValue, aOther.mValue); } BaseTimeDuration operator%(const BaseTimeDuration& aOther) const diff --git a/netwerk/base/Tickler.h b/netwerk/base/Tickler.h index 573fe6e762..63353a9248 100644 --- a/netwerk/base/Tickler.h +++ b/netwerk/base/Tickler.h @@ -27,7 +27,7 @@ // The tickler only applies to wifi on mobile right now. Hopefully it // can also be restricted to particular handset models in the future. -#if defined(ANDROID) && !defined(MOZ_B2G) +#if defined(ANDROID) #define MOZ_USE_WIFI_TICKLER #endif diff --git a/old-configure.in b/old-configure.in index 4c8cf83ef2..b12ba5b250 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2411,18 +2411,11 @@ if test -n "$WITH_APP_BASENAME" ; then MOZ_APP_BASENAME="$WITH_APP_BASENAME" fi -if test -n "$MOZ_B2G"; then - AC_DEFINE(MOZ_B2G) -fi - # Graphene is a desktop runtime for running applications with a HTML UI. if test -n "$MOZ_GRAPHENE"; then AC_DEFINE(MOZ_GRAPHENE) fi -AC_SUBST(MOZ_B2G) -AC_SUBST(MOZ_B2G_VERSION) - dnl ======================================================== dnl Ensure Android SDK and build-tools versions depending on dnl mobile target. @@ -4466,10 +4459,6 @@ MOZ_ARG_DISABLE_BOOL(startupcache, MOZ_DISABLE_STARTUPCACHE=1, MOZ_DISABLE_STARTUPCACHE=) -dnl bug 988880: disable startup cache on b2g -if test -n "$MOZ_B2G"; then - MOZ_DISABLE_STARTUPCACHE=1 -fi if test -n "$MOZ_DISABLE_STARTUPCACHE"; then AC_DEFINE(MOZ_DISABLE_STARTUPCACHE) fi @@ -5355,10 +5344,6 @@ else MOZ_APP_MAXVERSION=$MOZ_APP_VERSION fi -MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"} -AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION") -AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME") - AC_SUBST(MOZ_APP_NAME) AC_SUBST(MOZ_APP_REMOTINGNAME) AC_SUBST(MOZ_APP_DISPLAYNAME) diff --git a/services/fxaccounts/FxAccountsManager.jsm b/services/fxaccounts/FxAccountsManager.jsm deleted file mode 100644 index 680310ff55..0000000000 --- a/services/fxaccounts/FxAccountsManager.jsm +++ /dev/null @@ -1,654 +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/. */ - -/** - * Temporary abstraction layer for common Fx Accounts operations. - * For now, we will be using this module only from B2G but in the end we might - * want this to be merged with FxAccounts.jsm and let other products also use - * it. - */ - -"use strict"; - -this.EXPORTED_SYMBOLS = ["FxAccountsManager"]; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/FxAccounts.jsm"); -Cu.import("resource://gre/modules/Promise.jsm"); -Cu.import("resource://gre/modules/FxAccountsCommon.js"); - -XPCOMUtils.defineLazyServiceGetter(this, "permissionManager", - "@mozilla.org/permissionmanager;1", - "nsIPermissionManager"); - -this.FxAccountsManager = { - - init: function() { - Services.obs.addObserver(this, ONLOGOUT_NOTIFICATION, false); - Services.obs.addObserver(this, ON_FXA_UPDATE_NOTIFICATION, false); - }, - - observe: function(aSubject, aTopic, aData) { - // Both topics indicate our cache is invalid - this._activeSession = null; - - if (aData == ONVERIFIED_NOTIFICATION) { - log.debug("FxAccountsManager: cache cleared, broadcasting: " + aData); - Services.obs.notifyObservers(null, aData, null); - } - }, - - // We don't really need to save fxAccounts instance but this way we allow - // to mock FxAccounts from tests. - _fxAccounts: fxAccounts, - - // We keep the session details here so consumers don't need to deal with - // session tokens and are only required to handle the email. - _activeSession: null, - - // Are we refreshing our authentication? If so, allow attempts to sign in - // while we are already signed in. - _refreshing: false, - - // We only expose the email and the verified status so far. - get _user() { - if (!this._activeSession || !this._activeSession.email) { - return null; - } - - return { - email: this._activeSession.email, - verified: this._activeSession.verified, - profile: this._activeSession.profile, - } - }, - - _error: function(aError, aDetails) { - log.error(aError); - let reason = { - error: aError - }; - if (aDetails) { - reason.details = aDetails; - } - return Promise.reject(reason); - }, - - _getError: function(aServerResponse) { - if (!aServerResponse || !aServerResponse.error || !aServerResponse.error.errno) { - return; - } - let error = SERVER_ERRNO_TO_ERROR[aServerResponse.error.errno]; - return error; - }, - - _serverError: function(aServerResponse) { - let error = this._getError({ error: aServerResponse }); - return this._error(error ? error : ERROR_SERVER_ERROR, aServerResponse); - }, - - // As with _fxAccounts, we don't really need this method, but this way we - // allow tests to mock FxAccountsClient. By default, we want to return the - // client used by the fxAccounts object because deep down they should have - // access to the same hawk request object which will enable them to share - // local clock skeq data. - _getFxAccountsClient: function() { - return this._fxAccounts.getAccountsClient(); - }, - - _signInSignUp: function(aMethod, aEmail, aPassword, aFetchKeys) { - if (Services.io.offline) { - return this._error(ERROR_OFFLINE); - } - - if (!aEmail) { - return this._error(ERROR_INVALID_EMAIL); - } - - if (!aPassword) { - return this._error(ERROR_INVALID_PASSWORD); - } - - // Check that there is no signed in account first. - if ((!this._refreshing) && this._activeSession) { - return this._error(ERROR_ALREADY_SIGNED_IN_USER, { - user: this._user - }); - } - - let client = this._getFxAccountsClient(); - return this._fxAccounts.getSignedInUser().then( - user => { - if ((!this._refreshing) && user) { - return this._error(ERROR_ALREADY_SIGNED_IN_USER, { - user: this._user - }); - } - return client[aMethod](aEmail, aPassword, aFetchKeys); - } - ).then( - user => { - let error = this._getError(user); - if (!user || !user.uid || !user.sessionToken || error) { - return this._error(error ? error : ERROR_INTERNAL_INVALID_USER, { - user: user - }); - } - - // If the user object includes an email field, it may differ in - // capitalization from what we sent down. This is the server's - // canonical capitalization and should be used instead. - user.email = user.email || aEmail; - - // If we're using server-side sign to refreshAuthentication - // we don't need to update local state; also because of two - // interacting glitches we need to bypass an event emission. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=1031580 - if (this._refreshing) { - return Promise.resolve({user: this._user}); - } - - return this._fxAccounts.setSignedInUser(user).then( - () => { - this._activeSession = user; - log.debug("User signed in: " + JSON.stringify(this._user) + - " - Account created " + (aMethod == "signUp")); - - // There is no way to obtain the key fetch token afterwards - // without login out the user and asking her to log in again. - // Also, key fetch tokens are designed to be short-lived, so - // we need to fetch kB as soon as we have the key fetch token. - if (aFetchKeys) { - this._fxAccounts.getKeys(); - } - - return this._fxAccounts.getSignedInUserProfile().catch(error => { - // Not fetching the profile is sad but the FxA logs will already - // have noise. - return null; - }); - } - ).then(profile => { - if (profile) { - this._activeSession.profile = profile; - } - - return Promise.resolve({ - accountCreated: aMethod === "signUp", - user: this._user - }); - }); - }, - reason => { return this._serverError(reason); } - ); - }, - - /** - * Determine whether the incoming error means that the current account - * has new server-side state via deletion or password change, and if so, - * spawn the appropriate UI (sign in or refresh); otherwise re-reject. - * - * As of May 2014, the only HTTP call triggered by this._getAssertion() - * is to /certificate/sign via: - * FxAccounts.getAssertion() - * FxAccountsInternal.getCertificateSigned() - * FxAccountsClient.signCertificate() - * See the latter method for possible (error code, errno) pairs. - */ - _handleGetAssertionError: function(reason, aAudience, aPrincipal) { - log.debug("FxAccountsManager._handleGetAssertionError()"); - let errno = (reason ? reason.errno : NaN) || NaN; - // If the previously valid email/password pair is no longer valid ... - if (errno == ERRNO_INVALID_AUTH_TOKEN) { - return this._fxAccounts.accountStatus().then( - (exists) => { - // ... if the email still maps to an account, the password - // must have changed, so ask the user to enter the new one ... - if (exists) { - return this.getAccount().then( - (user) => { - return this._refreshAuthentication(aAudience, user.email, - aPrincipal, - true /* logoutOnFailure */); - } - ); - } - // ... otherwise, the account was deleted, so ask for Sign In/Up - return this._localSignOut().then( - () => { - return this._uiRequest(UI_REQUEST_SIGN_IN_FLOW, aAudience, - aPrincipal); - }, - (reason) => { - // reject primary problem, not signout failure - log.error("Signing out in response to server error threw: " + - reason); - return this._error(reason); - } - ); - } - ); - } - return Promise.reject(reason.message ? { error: reason.message } : reason); - }, - - _getAssertion: function(aAudience, aPrincipal) { - return this._fxAccounts.getAssertion(aAudience).then( - (result) => { - if (aPrincipal) { - this._addPermission(aPrincipal); - } - return result; - }, - (reason) => { - return this._handleGetAssertionError(reason, aAudience, aPrincipal); - } - ); - }, - - /** - * "Refresh authentication" means: - * Interactively demonstrate knowledge of the FxA password - * for the currently logged-in account. - * There are two very different scenarios: - * 1) The password has changed on the server. Failure should log - * the current account OUT. - * 2) The person typing can't prove knowledge of the password used - * to log in. Failure should do nothing. - */ - _refreshAuthentication: function(aAudience, aEmail, aPrincipal, - logoutOnFailure=false) { - this._refreshing = true; - return this._uiRequest(UI_REQUEST_REFRESH_AUTH, - aAudience, aPrincipal, aEmail).then( - (assertion) => { - this._refreshing = false; - return assertion; - }, - (reason) => { - this._refreshing = false; - if (logoutOnFailure) { - return this._signOut().then( - () => { - return this._error(reason); - } - ); - } - return this._error(reason); - } - ); - }, - - _localSignOut: function() { - return this._fxAccounts.signOut(true); - }, - - _signOut: function() { - if (!this._activeSession) { - return Promise.resolve(); - } - - // We clear the local session cache as soon as we get the onlogout - // notification triggered within FxAccounts.signOut, so we save the - // session token value to be able to remove the remote server session - // in case that we have network connection. - let sessionToken = this._activeSession.sessionToken; - - return this._localSignOut().then( - () => { - // At this point the local session should already be removed. - - // The client can create new sessions up to the limit (100?). - // Orphaned tokens on the server will eventually be garbage collected. - if (Services.io.offline) { - return Promise.resolve(); - } - // Otherwise, we try to remove the remote session. - let client = this._getFxAccountsClient(); - return client.signOut(sessionToken).then( - result => { - let error = this._getError(result); - if (error) { - return this._error(error, result); - } - log.debug("Signed out"); - return Promise.resolve(); - }, - reason => { - return this._serverError(reason); - } - ); - } - ); - }, - - _uiRequest: function(aRequest, aAudience, aPrincipal, aParams) { - if (Services.io.offline) { - return this._error(ERROR_OFFLINE); - } - let ui = Cc["@mozilla.org/fxaccounts/fxaccounts-ui-glue;1"] - .createInstance(Ci.nsIFxAccountsUIGlue); - if (!ui[aRequest]) { - return this._error(ERROR_UI_REQUEST); - } - - if (!aParams || !Array.isArray(aParams)) { - aParams = [aParams]; - } - - return ui[aRequest].apply(this, aParams).then( - result => { - // Even if we get a successful result from the UI, the account will - // most likely be unverified, so we cannot get an assertion. - if (result && result.verified) { - return this._getAssertion(aAudience, aPrincipal); - } - - return this._error(ERROR_UNVERIFIED_ACCOUNT, { - user: result - }); - }, - error => { - return this._error(ERROR_UI_ERROR, error); - } - ); - }, - - _addPermission: function(aPrincipal) { - // This will fail from tests cause we are running them in the child - // process until we have chrome tests in b2g. Bug 797164. - try { - permissionManager.addFromPrincipal(aPrincipal, FXACCOUNTS_PERMISSION, - Ci.nsIPermissionManager.ALLOW_ACTION); - } catch (e) { - log.warn("Could not add permission " + e); - } - }, - - // -- API -- - - signIn: function(aEmail, aPassword, aFetchKeys) { - return this._signInSignUp("signIn", aEmail, aPassword, aFetchKeys); - }, - - signUp: function(aEmail, aPassword, aFetchKeys) { - return this._signInSignUp("signUp", aEmail, aPassword, aFetchKeys); - }, - - signOut: function() { - if (!this._activeSession) { - // If there is no cached active session, we try to get it from the - // account storage. - return this.getAccount().then( - result => { - if (!result) { - return Promise.resolve(); - } - return this._signOut(); - } - ); - } - return this._signOut(); - }, - - resendVerificationEmail: function() { - return this._fxAccounts.resendVerificationEmail().then( - (result) => { - return result; - }, - (error) => { - return this._error(ERROR_SERVER_ERROR, error); - } - ); - }, - - getAccount: function() { - // We check first if we have session details cached. - if (this._activeSession) { - // If our cache says that the account is not yet verified, - // we kick off verification before returning what we have. - if (!this._activeSession.verified) { - this.verificationStatus(this._activeSession); - } - log.debug("Account " + JSON.stringify(this._user)); - return Promise.resolve(this._user); - } - - // If no cached information, we try to get it from the persistent storage. - return this._fxAccounts.getSignedInUser().then( - user => { - if (!user || !user.email) { - log.debug("No signed in account"); - return Promise.resolve(null); - } - - this._activeSession = user; - // If we get a stored information of a not yet verified account, - // we kick off verification before returning what we have. - if (!user.verified) { - this.verificationStatus(user); - // Trying to get the profile for unverified users will fail, so we - // don't even try in that case. - log.debug("Account ", this._user); - return Promise.resolve(this._user); - } - - return this._fxAccounts.getSignedInUserProfile().then(profile => { - if (profile) { - this._activeSession.profile = profile; - } - log.debug("Account ", this._user); - return Promise.resolve(this._user); - }).catch(error => { - // FxAccounts logs already inform about the error. - log.debug("Account ", this._user); - return Promise.resolve(this._user); - }); - } - ); - }, - - queryAccount: function(aEmail) { - log.debug("queryAccount " + aEmail); - if (Services.io.offline) { - return this._error(ERROR_OFFLINE); - } - - let deferred = Promise.defer(); - - if (!aEmail) { - return this._error(ERROR_INVALID_EMAIL); - } - - let client = this._getFxAccountsClient(); - return client.accountExists(aEmail).then( - result => { - log.debug("Account " + result ? "" : "does not" + " exists"); - let error = this._getError(result); - if (error) { - return this._error(error, result); - } - - return Promise.resolve({ - registered: result - }); - }, - reason => { this._serverError(reason); } - ); - }, - - verificationStatus: function() { - log.debug("verificationStatus"); - if (!this._activeSession || !this._activeSession.sessionToken) { - this._error(ERROR_NO_TOKEN_SESSION); - } - - // There is no way to unverify an already verified account, so we just - // return the account details of a verified account - if (this._activeSession.verified) { - log.debug("Account already verified"); - return; - } - - if (Services.io.offline) { - log.warn("Offline; skipping verification."); - return; - } - - let client = this._getFxAccountsClient(); - client.recoveryEmailStatus(this._activeSession.sessionToken).then( - data => { - let error = this._getError(data); - if (error) { - this._error(error, data); - } - // If the verification status has changed, update state. - if (this._activeSession.verified != data.verified) { - this._activeSession.verified = data.verified; - this._fxAccounts.setSignedInUser(this._activeSession); - this._fxAccounts.getSignedInUserProfile().then(profile => { - if (profile) { - this._activeSession.profile = profile; - } - }).catch(error => { - // FxAccounts logs already inform about the error. - }); - } - log.debug(JSON.stringify(this._user)); - }, - reason => { this._serverError(reason); } - ); - }, - - /* - * Try to get an assertion for the given audience. Here we implement - * the heart of the response to navigator.mozId.request() on device. - * (We can also be called via the IAC API, but it's request() that - * makes this method complex.) The state machine looks like this, - * ignoring simple errors: - * If no one is signed in, and we aren't suppressing the UI: - * trigger the sign in flow. - * else if we were asked to refresh and the grace period is up: - * trigger the refresh flow. - * else: - * request user permission to share an assertion if we don't have it - * already and ask the core code for an assertion, which might itself - * trigger either the sign in or refresh flows (if our account - * changed on the server). - * - * aOptions can include: - * refreshAuthentication - (bool) Force re-auth. - * silent - (bool) Prevent any UI interaction. - * I.e., try to get an automatic assertion. - */ - getAssertion: function(aAudience, aPrincipal, aOptions) { - if (!aAudience) { - return this._error(ERROR_INVALID_AUDIENCE); - } - - let principal = aPrincipal; - log.debug("FxAccountsManager.getAssertion() aPrincipal: ", - principal.origin, principal.appId, - principal.isInIsolatedMozBrowserElement); - - return this.getAccount().then( - user => { - if (user) { - // Three have-user cases to consider. First: are we unverified? - if (!user.verified) { - return this._error(ERROR_UNVERIFIED_ACCOUNT, { - user: user - }); - } - // Second case: do we need to refresh? - if (aOptions && - (typeof(aOptions.refreshAuthentication) != "undefined")) { - let gracePeriod = aOptions.refreshAuthentication; - if (typeof(gracePeriod) !== "number" || isNaN(gracePeriod)) { - return this._error(ERROR_INVALID_REFRESH_AUTH_VALUE); - } - // Forcing refreshAuth to silent is a contradiction in terms, - // though it might succeed silently if we didn't reject here. - if (aOptions.silent) { - return this._error(ERROR_NO_SILENT_REFRESH_AUTH); - } - let secondsSinceAuth = (Date.now() / 1000) - - this._activeSession.authAt; - if (secondsSinceAuth > gracePeriod) { - return this._refreshAuthentication(aAudience, user.email, - principal, - false /* logoutOnFailure */); - } - } - // Third case: we are all set *locally*. Probably we just return - // the assertion, but the attempt might lead to the server saying - // we are deleted or have a new password, which will trigger a flow. - // Also we need to check if we have permission to get the assertion, - // otherwise we need to show the forceAuth UI to let the user know - // that the RP with no fxa permissions is trying to obtain an - // assertion. Once the user authenticates herself in the forceAuth UI - // the permission will be remembered by default. - let permission = permissionManager.testPermissionFromPrincipal( - principal, - FXACCOUNTS_PERMISSION - ); - if (permission == Ci.nsIPermissionManager.PROMPT_ACTION && - !this._refreshing) { - return this._refreshAuthentication(aAudience, user.email, - principal, - false /* logoutOnFailure */); - } else if (permission == Ci.nsIPermissionManager.DENY_ACTION && - !this._refreshing) { - return this._error(ERROR_PERMISSION_DENIED); - } else if (this._refreshing) { - // If we are blocked asking for a password we should not continue - // the getAssertion process. - return Promise.resolve(null); - } - return this._getAssertion(aAudience, principal); - } - log.debug("No signed in user"); - if (aOptions && aOptions.silent) { - return Promise.resolve(null); - } - return this._uiRequest(UI_REQUEST_SIGN_IN_FLOW, aAudience, principal); - } - ); - }, - - getKeys: function() { - let syncEnabled = false; - try { - syncEnabled = Services.prefs.getBoolPref("services.sync.enabled"); - } catch(e) { - dump("Sync is disabled, so you won't get the keys. " + e + "\n"); - } - - if (!syncEnabled) { - return Promise.reject(ERROR_SYNC_DISABLED); - } - - return this.getAccount().then( - user => { - if (!user) { - log.debug("No signed in user"); - return Promise.resolve(null); - } - - if (!user.verified) { - return this._error(ERROR_UNVERIFIED_ACCOUNT, { - user: user - }); - } - - return this._fxAccounts.getKeys(); - } - ); - } -}; - -FxAccountsManager.init(); diff --git a/services/fxaccounts/FxAccountsStorage.jsm b/services/fxaccounts/FxAccountsStorage.jsm index 43e2d21a0c..4362cdf5bd 100644 --- a/services/fxaccounts/FxAccountsStorage.jsm +++ b/services/fxaccounts/FxAccountsStorage.jsm @@ -17,6 +17,8 @@ Cu.import("resource://gre/modules/FxAccountsCommon.js"); Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://services-common/utils.js"); +var haveLoginManager = true; + // A helper function so code can check what fields are able to be stored by // the storage manager without having a reference to a manager instance. function FxAccountsStorageManagerCanStoreField(fieldName) { @@ -602,8 +604,3 @@ LoginManagerStorage.prototype = { }), } -// A global variable to indicate if the login manager is available - it doesn't -// exist on b2g. Defined here as the use of preprocessor directives skews line -// numbers in the runtime, meaning stack-traces etc end up off by a few lines. -// Doing it at the end of the file makes that less of a pita. -var haveLoginManager = !AppConstants.MOZ_B2G; diff --git a/services/fxaccounts/moz.build b/services/fxaccounts/moz.build index 30c8944c2d..b1cd3b59c2 100644 --- a/services/fxaccounts/moz.build +++ b/services/fxaccounts/moz.build @@ -30,6 +30,3 @@ EXTRA_JS_MODULES += [ 'FxAccountsWebChannel.jsm', ] -# For now, we will only be using the FxA manager in B2G. -if CONFIG['MOZ_B2G']: - EXTRA_JS_MODULES += ['FxAccountsManager.jsm'] diff --git a/startupcache/moz.build b/startupcache/moz.build index 24068cb7e8..f7e930b5b3 100644 --- a/startupcache/moz.build +++ b/startupcache/moz.build @@ -4,8 +4,7 @@ # 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/. -if not CONFIG['MOZ_B2G']: - TEST_DIRS += ['test'] +TEST_DIRS += ['test'] XPIDL_SOURCES += [ 'nsIStartupCache.idl', diff --git a/testing/marionette/assert.js b/testing/marionette/assert.js index d1a55bd7cc..b2d228d0ef 100644 --- a/testing/marionette/assert.js +++ b/testing/marionette/assert.js @@ -15,7 +15,7 @@ Cu.import("chrome://marionette/content/error.js"); this.EXPORTED_SYMBOLS = ["assert"]; const isFennec = () => AppConstants.platform == "android"; -const isB2G = () => AppConstants.MOZ_B2G; +const isB2G = () => false; const isFirefox = () => Services.appinfo.name == "Firefox"; /** Shorthands for common assertions made in Marionette. */ diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 8f1ff7465c..e97ad89c40 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -1529,11 +1529,7 @@ SpecialPowersAPI.prototype = { }, get isB2G() { -#ifdef MOZ_B2G - return true; -#else return false; -#endif }, addSystemEventListener: function(target, type, listener, useCapture) { diff --git a/testing/testsuite-targets.mk b/testing/testsuite-targets.mk index 8b1d7d50d7..ebe0d06cf0 100644 --- a/testing/testsuite-targets.mk +++ b/testing/testsuite-targets.mk @@ -18,10 +18,6 @@ ifneq (1_WINNT,$(MOZ_PGO)_$(OS_ARCH)) BUILD_GTEST=1 endif -ifdef MOZ_B2G -BUILD_GTEST= -endif - ifndef MOZ_PHOENIX BUILD_GTEST= endif diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm index 7439d9d11e..4069bca746 100644 --- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm +++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ -300,12 +300,7 @@ this.DownloadIntegration = { aDownload.hasBlockedData) { return true; } -#ifdef MOZ_B2G - // On B2G we keep a few days of history. - let maxTime = Date.now() - - Services.prefs.getIntPref("dom.downloads.max_retention_days") * 24 * 60 * 60 * 1000; - return aDownload.startTime > maxTime; -#elif defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) // On Android we store all history. return true; #else diff --git a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm index f5102b4a89..5bd351ee97 100644 --- a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm +++ b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm @@ -106,12 +106,7 @@ XPCOMUtils.defineLazyGetter(DownloadUIHelper, "strings", function () { */ this.DownloadPrompter = function (aParent) { - if (AppConstants.MOZ_B2G) { - // On B2G there is no prompter implementation. - this._prompter = null; - } else { - this._prompter = Services.ww.getNewPrompter(aParent); - } + this._prompter = Services.ww.getNewPrompter(aParent); } this.DownloadPrompter.prototype = { diff --git a/toolkit/identity/FirefoxAccounts.jsm b/toolkit/identity/FirefoxAccounts.jsm index 54efaf3b45..1d2ed04397 100644 --- a/toolkit/identity/FirefoxAccounts.jsm +++ b/toolkit/identity/FirefoxAccounts.jsm @@ -35,18 +35,11 @@ var log = Log.repository.getLogger("Identity.FxAccounts"); log.level = LOG_LEVEL; log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter())); -#ifdef MOZ_B2G -XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsManager", - "resource://gre/modules/FxAccountsManager.jsm", - "FxAccountsManager"); -Cu.import("resource://gre/modules/FxAccountsCommon.js"); -#else -log.warn("The FxAccountsManager is only functional in B2G at this time."); +log.warn("The FxAccountsManager has been removed."); var FxAccountsManager = null; var ONVERIFIED_NOTIFICATION = null; var ONLOGIN_NOTIFICATION = null; var ONLOGOUT_NOTIFICATION = null; -#endif function FxAccountsService() { Services.obs.addObserver(this, "quit-application-granted", false); diff --git a/toolkit/modules/AppConstants.jsm b/toolkit/modules/AppConstants.jsm index b4201ec673..c500b21e83 100644 --- a/toolkit/modules/AppConstants.jsm +++ b/toolkit/modules/AppConstants.jsm @@ -130,14 +130,6 @@ this.AppConstants = Object.freeze({ false, #endif -# MOZ_B2G covers both device and desktop b2g - MOZ_B2G: -#ifdef MOZ_B2G - true, -#else - false, -#endif - XP_UNIX: #ifdef XP_UNIX true, @@ -204,13 +196,6 @@ this.AppConstants = Object.freeze({ false, #endif - MOZ_B2G_RIL: -#ifdef MOZ_B2G_RIL - true, -#else - false, -#endif - MOZ_GRAPHENE: #ifdef MOZ_GRAPHENE true, @@ -300,8 +285,6 @@ this.AppConstants = Object.freeze({ INSTALL_LOCALE: "@AB_CD@", MOZ_WIDGET_TOOLKIT: "@MOZ_WIDGET_TOOLKIT@", ANDROID_PACKAGE_NAME: "@ANDROID_PACKAGE_NAME@", - MOZ_B2G_VERSION: @MOZ_B2G_VERSION@, - MOZ_B2G_OS_NAME: @MOZ_B2G_OS_NAME@, DEBUG_JS_MODULES: "@DEBUG_JS_MODULES@", diff --git a/toolkit/mozapps/webextensions/nsBlocklistService.js b/toolkit/mozapps/webextensions/nsBlocklistService.js index 0af90430cb..268c197fcb 100644 --- a/toolkit/mozapps/webextensions/nsBlocklistService.js +++ b/toolkit/mozapps/webextensions/nsBlocklistService.js @@ -907,10 +907,6 @@ Blocklist.prototype = { this._handleEmItemNode); break; case "pluginItems": - // We don't support plugins on b2g. - if (AppConstants.MOZ_B2G) { - return; - } this._pluginEntries = this._processItemNodes(element.childNodes, "pluginItem", this._handlePluginItemNode); break; @@ -1151,8 +1147,7 @@ Blocklist.prototype = { /* See nsIBlocklistService */ getPluginBlocklistState: function(plugin, appVersion, toolkitVersion) { - if (AppConstants.platform == "android" || - AppConstants.MOZ_B2G) { + if (AppConstants.platform == "android") { return Ci.nsIBlocklistService.STATE_NOT_BLOCKED; } if (!this._isBlocklistLoaded()) @@ -1314,10 +1309,6 @@ Blocklist.prototype = { }, _blocklistUpdated: function(oldAddonEntries, oldPluginEntries) { - if (AppConstants.MOZ_B2G) { - return; - } - var addonList = []; // A helper function that reverts the prefs passed to default values. diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 04e2e1ebfd..f2d0b1b0f2 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -126,10 +126,6 @@ nsXREDirProvider::Initialize(nsIFile *aXULAppDir, } } -#ifdef MOZ_B2G - LoadAppBundleDirs(); -#endif - return NS_OK; } @@ -761,38 +757,6 @@ nsXREDirProvider::LoadExtensionBundleDirectories() } } -#ifdef MOZ_B2G -void -nsXREDirProvider::LoadAppBundleDirs() -{ - nsCOMPtr<nsIFile> dir; - bool persistent = false; - nsresult rv = GetFile(XRE_APP_DISTRIBUTION_DIR, &persistent, getter_AddRefs(dir)); - if (NS_FAILED(rv)) - return; - - dir->AppendNative(NS_LITERAL_CSTRING("bundles")); - - nsCOMPtr<nsISimpleEnumerator> e; - rv = dir->GetDirectoryEntries(getter_AddRefs(e)); - if (NS_FAILED(rv)) - return; - - nsCOMPtr<nsIDirectoryEnumerator> files = do_QueryInterface(e); - if (!files) - return; - - nsCOMPtr<nsIFile> subdir; - while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(subdir))) && subdir) { - mAppBundleDirectories.AppendObject(subdir); - - nsCOMPtr<nsIFile> manifest = - CloneAndAppend(subdir, "chrome.manifest"); - XRE_AddManifestLocation(NS_APP_LOCATION, manifest); - } -} -#endif - static const char *const kAppendPrefDir[] = { "defaults", "preferences", nullptr }; #ifdef DEBUG_bsmedberg diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h index 1190cc7081..655f664e6d 100644 --- a/toolkit/xre/nsXREDirProvider.h +++ b/toolkit/xre/nsXREDirProvider.h @@ -124,11 +124,6 @@ protected: // Calculate and register extension and theme bundle directories. void LoadExtensionBundleDirectories(); -#ifdef MOZ_B2G - // Calculate and register app-bundled extension directories. - void LoadAppBundleDirs(); -#endif - void Append(nsIFile* aDirectory); nsCOMPtr<nsIDirectoryServiceProvider> mAppProvider; diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index ea370aa37c..5a6b380285 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -385,16 +385,6 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * bool allowContentDispositionToForceExternalHandling = true; -#ifdef MOZ_B2G - - // On B2G, OMA content files should never be handled by an external handler - // (even if the server specifies Content-Disposition: attachment) because the - // data should never be stored on an unencrypted form. - allowContentDispositionToForceExternalHandling = - !mContentType.LowerCaseEqualsASCII("application/vnd.oma.drm.message"); - -#endif - if (NS_SUCCEEDED(rv) && (disposition == nsIChannel::DISPOSITION_ATTACHMENT) && allowContentDispositionToForceExternalHandling) { forceExternalHandling = true; diff --git a/widget/NativeKeyToDOMKeyName.h b/widget/NativeKeyToDOMKeyName.h index e060a313ce..c00cdb2b6a 100644 --- a/widget/NativeKeyToDOMKeyName.h +++ b/widget/NativeKeyToDOMKeyName.h @@ -80,15 +80,9 @@ #undef KEY_MAP_ANDROID #define KEY_MAP_ANDROID(aCPPKeyName, aNativeKey) \ NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) -#ifndef MOZ_B2G #undef KEY_MAP_ANDROID_EXCEPT_B2G #define KEY_MAP_ANDROID_EXCEPT_B2G(aCPPKeyName, aNativeKey) \ NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) -#else // #ifndef MOZ_B2G -#undef KEY_MAP_B2G -#define KEY_MAP_B2G(aCPPKeyName, aNativeKey) \ - NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) -#endif // #ifndef MOZ_B2G #else #endif /****************************************************************************** diff --git a/widget/moz.build b/widget/moz.build index 5138a89ef3..b156346eb7 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -236,8 +236,7 @@ if toolkit == 'gtk3': 'nsIApplicationChooser.idl', ] -if not CONFIG['MOZ_B2G']: - DEFINES['MOZ_CROSS_PROCESS_IME'] = True +DEFINES['MOZ_CROSS_PROCESS_IME'] = True include('/ipc/chromium/chromium-config.mozbuild') |