summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsGlobalWindow.cpp111
-rw-r--r--dom/base/nsGlobalWindow.h12
-rw-r--r--dom/base/nsPIDOMWindow.h18
-rw-r--r--dom/downloads/DownloadsAPI.js517
-rw-r--r--dom/downloads/DownloadsAPI.jsm365
-rw-r--r--dom/downloads/DownloadsAPI.manifest6
-rw-r--r--dom/downloads/DownloadsIPC.jsm224
-rw-r--r--dom/downloads/moz.build21
-rw-r--r--dom/downloads/tests/clear_all_done_helper.js67
-rw-r--r--dom/downloads/tests/mochitest.ini15
-rw-r--r--dom/downloads/tests/serve_file.sjs170
-rw-r--r--dom/downloads/tests/test_downloads_bad_file.html93
-rw-r--r--dom/downloads/tests/test_downloads_basic.html128
-rw-r--r--dom/downloads/tests/test_downloads_large.html110
-rw-r--r--dom/downloads/tests/test_downloads_navigator_object.html75
-rw-r--r--dom/downloads/tests/test_downloads_pause_remove.html117
-rw-r--r--dom/downloads/tests/test_downloads_pause_resume.html121
-rw-r--r--dom/events/EventListenerManager.cpp34
-rw-r--r--dom/events/EventNameList.h16
-rw-r--r--dom/events/KeyNameList.h4
-rw-r--r--dom/events/TouchEvent.cpp2
-rw-r--r--dom/html/HTMLInputElement.cpp15
-rw-r--r--dom/indexedDB/ActorsParent.cpp24
-rw-r--r--dom/indexedDB/IDBObjectStore.cpp10
-rw-r--r--dom/indexedDB/IDBObjectStore.h2
-rw-r--r--dom/inputmethod/HardwareKeyHandler.cpp562
-rw-r--r--dom/inputmethod/HardwareKeyHandler.h224
-rw-r--r--dom/inputmethod/Keyboard.jsm16
-rw-r--r--dom/inputmethod/moz.build23
-rw-r--r--dom/inputmethod/nsIHardwareKeyHandler.idl142
-rw-r--r--dom/ipc/ContentParent.cpp2
-rw-r--r--dom/ipc/TabContext.cpp7
-rw-r--r--dom/media/AudioStream.cpp4
-rw-r--r--dom/media/CubebUtils.cpp27
-rw-r--r--dom/media/CubebUtils.h3
-rw-r--r--dom/media/GraphDriver.cpp4
-rw-r--r--dom/media/MediaManager.cpp8
-rw-r--r--dom/media/PeerConnection.js1
-rw-r--r--dom/media/webrtc/MediaEngine.h5
-rw-r--r--dom/media/webrtc/MediaEngineWebRTCAudio.cpp4
-rw-r--r--dom/moz.build5
-rw-r--r--dom/notification/DesktopNotification.h4
-rw-r--r--dom/security/nsCSPContext.cpp9
-rw-r--r--dom/settings/SettingsService.js358
-rw-r--r--dom/settings/SettingsService.manifest5
-rw-r--r--dom/settings/moz.build6
-rw-r--r--dom/settings/tests/chrome.ini6
-rw-r--r--dom/settings/tests/test_settings_service.js138
-rw-r--r--dom/settings/tests/test_settings_service.xul19
-rw-r--r--dom/settings/tests/test_settings_service_callback.js47
-rw-r--r--dom/settings/tests/test_settings_service_callback.xul19
-rw-r--r--dom/webidl/MozApplicationEvent.webidl16
-rw-r--r--dom/webidl/Window.webidl6
-rw-r--r--dom/webidl/moz.build8
54 files changed, 5 insertions, 3950 deletions
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=".&lt;.EVIL.&gt;\ / : * ? &quot; |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',