Bug 1233803 - Register RemoteWebNavigation as a standard js-implemented XPCOM component. r?felipe
This allows us to add shims to the implementation for add-ons.
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -541,16 +541,19 @@
@RESPATH@/components/NotificationStorage.js
@RESPATH@/components/NotificationStorage.manifest
@RESPATH@/components/AlarmsManager.js
@RESPATH@/components/AlarmsManager.manifest
@RESPATH@/components/Push.js
@RESPATH@/components/Push.manifest
@RESPATH@/components/PushComponents.js
+@RESPATH@/components/remotebrowserutils.manifest
+@RESPATH@/components/RemoteWebNavigation.js
+
@RESPATH@/components/SlowScriptDebug.manifest
@RESPATH@/components/SlowScriptDebug.js
@RESPATH@/components/TVSimulatorService.js
@RESPATH@/components/TVSimulatorService.manifest
#ifndef RELEASE_BUILD
@RESPATH@/components/InterAppComm.manifest
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -40,16 +40,17 @@ DIRS += [
'perf',
'places',
'privatebrowsing',
'processsingleton',
'promiseworker',
'prompts',
'protobuf',
'reader',
+ 'remotebrowserutils',
'reflect',
'sqlite',
'startup',
'statusfilter',
'telemetry',
'thumbnails',
'timermanager',
'typeaheadfind',
rename from toolkit/modules/RemoteWebNavigation.jsm
rename to toolkit/components/remotebrowserutils/RemoteWebNavigation.js
--- a/toolkit/modules/RemoteWebNavigation.jsm
+++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
@@ -1,38 +1,42 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-this.EXPORTED_SYMBOLS = ["RemoteWebNavigation"];
-
const { interfaces: Ci, classes: Cc, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
+ "resource://gre/modules/NetUtil.jsm");
+
function makeURI(url)
{
- return Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService).
- newURI(url, null, null);
+ return Services.io.newURI(url, null, null);
}
function readInputStreamToString(aStream)
{
- Cu.import("resource://gre/modules/NetUtil.jsm");
return NetUtil.readInputStreamToString(aStream, aStream.available());
}
-function RemoteWebNavigation(browser)
+function RemoteWebNavigation()
{
- this.swapBrowser(browser);
+ this.wrappedJSObject = this;
}
RemoteWebNavigation.prototype = {
+ classDescription: "nsIWebNavigation for remote browsers",
+ classID: Components.ID("{4b56964e-cdf3-4bb8-830c-0e2dad3f4ebd}"),
+ contractID: "@mozilla.org/remote-web-navigation;1",
+
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebNavigation, Ci.nsISupports]),
swapBrowser: function(aBrowser) {
if (this._messageManager) {
this._messageManager.removeMessageListener("WebNavigation:setHistory", this);
}
this._browser = aBrowser;
@@ -130,8 +134,10 @@ RemoteWebNavigation.prototype = {
receiveMessage: function(aMessage) {
switch (aMessage.name) {
case "WebNavigation:setHistory":
this._sessionHistory = aMessage.objects.history;
break;
}
}
};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteWebNavigation]);
new file mode 100644
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/moz.build
@@ -0,0 +1,12 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXTRA_COMPONENTS += [
+ 'remotebrowserutils.manifest',
+ 'RemoteWebNavigation.js',
+]
+
+BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
new file mode 100644
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/remotebrowserutils.manifest
@@ -0,0 +1,2 @@
+component {4b56964e-cdf3-4bb8-830c-0e2dad3f4ebd} RemoteWebNavigation.js process=main
+contract @mozilla.org/remote-web-navigation;1 {4b56964e-cdf3-4bb8-830c-0e2dad3f4ebd} process=main
\ No newline at end of file
copy from toolkit/modules/tests/browser/.eslintrc
copy to toolkit/components/remotebrowserutils/tests/browser/.eslintrc
--- a/toolkit/modules/tests/browser/.eslintrc
+++ b/toolkit/components/remotebrowserutils/tests/browser/.eslintrc
@@ -1,5 +1,5 @@
{
"extends": [
- "../../../../testing/mochitest/browser.eslintrc"
+ "../../../../../testing/mochitest/browser.eslintrc"
]
}
copy from toolkit/modules/tests/browser/browser.ini
copy to toolkit/components/remotebrowserutils/tests/browser/browser.ini
--- a/toolkit/modules/tests/browser/browser.ini
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser.ini
@@ -1,37 +1,6 @@
[DEFAULT]
+run-if = e10s
support-files =
dummy_page.html
- metadata_*.html
- testremotepagemanager.html
- file_WebNavigation_page1.html
- file_WebNavigation_page2.html
- file_WebNavigation_page3.html
- file_WebRequest_page1.html
- file_WebRequest_page2.html
- file_image_good.png
- file_image_bad.png
- file_image_redirect.png
- file_style_good.css
- file_style_bad.css
- file_style_redirect.css
- file_script_good.js
- file_script_bad.js
- file_script_redirect.js
- file_script_xhr.js
- WebRequest_dynamic.sjs
- WebRequest_redirection.sjs
-[browser_Battery.js]
-[browser_Deprecated.js]
-[browser_Finder.js]
-skip-if = e10s # Bug ?????? - test already uses content scripts, but still fails only under e10s.
-[browser_Geometry.js]
-[browser_InlineSpellChecker.js]
-[browser_WebNavigation.js]
-[browser_WebRequest.js]
-[browser_WebRequest_cookies.js]
-[browser_WebRequest_filtering.js]
-[browser_PageMetadata.js]
-[browser_RemotePageManager.js]
[browser_RemoteWebNavigation.js]
-[browser_Troubleshoot.js]
rename from toolkit/modules/tests/browser/browser_RemoteWebNavigation.js
rename to toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
copy from toolkit/modules/tests/browser/dummy_page.html
copy to toolkit/components/remotebrowserutils/tests/browser/dummy_page.html
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1174,16 +1174,17 @@
"_webBrowserFind",
"_contentWindow",
"_webNavigation"
];
if (this.isRemoteBrowser) {
fieldsToSwap.push(...[
"_remoteWebNavigation",
+ "_remoteWebNavigationImpl",
"_remoteWebProgressManager",
"_remoteWebProgress",
"_remoteFinder",
"_securityUI",
"_documentURI",
"_documentContentType",
"_contentTitle",
"_characterSet",
@@ -1228,18 +1229,18 @@
// Null the current nsITypeAheadFind instances so that they're
// lazily re-created on access. We need to do this because they
// might have attached the wrong docShell.
this._fastFind = aOtherBrowser._fastFind = null;
}
else {
// Rewire the remote listeners
- this._remoteWebNavigation.swapBrowser(this);
- aOtherBrowser._remoteWebNavigation.swapBrowser(aOtherBrowser);
+ this._remoteWebNavigationImpl.swapBrowser(this);
+ aOtherBrowser._remoteWebNavigationImpl.swapBrowser(aOtherBrowser);
this._remoteWebProgressManager.swapBrowser(this);
aOtherBrowser._remoteWebProgressManager.swapBrowser(aOtherBrowser);
if (this._remoteFinder)
this._remoteFinder.swapBrowser(this);
if (aOtherBrowser._remoteFinder)
aOtherBrowser._remoteFinder.swapBrowser(aOtherBrowser);
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -336,19 +336,20 @@
<constructor>
<![CDATA[
/*
* Don't try to send messages from this function. The message manager for
* the <browser> element may not be initialized yet.
*/
- let jsm = "resource://gre/modules/RemoteWebNavigation.jsm";
- let RemoteWebNavigation = Cu.import(jsm, {}).RemoteWebNavigation;
- this._remoteWebNavigation = new RemoteWebNavigation(this);
+ this._remoteWebNavigation =
+ Cc["@mozilla.org/remote-web-navigation;1"].createInstance(Ci.nsIWebNavigation);
+ this._remoteWebNavigationImpl = this._remoteWebNavigation.wrappedJSObject;
+ this._remoteWebNavigationImpl.swapBrowser(this);
this.messageManager.addMessageListener("Browser:Init", this);
this.messageManager.addMessageListener("DOMTitleChanged", this);
this.messageManager.addMessageListener("ImageDocumentLoaded", this);
this.messageManager.addMessageListener("DocumentInserted", this);
this.messageManager.addMessageListener("FullZoomChange", this);
this.messageManager.addMessageListener("TextZoomChange", this);
this.messageManager.addMessageListener("ZoomChangeUsingMouseWheel", this);
@@ -361,17 +362,17 @@
this.messageManager.addMessageListener("Forms:HideDropDown", this);
this.messageManager.loadFrameScript("chrome://global/content/select-child.js", true);
}
if (!this.hasAttribute("disablehistory")) {
Services.obs.addObserver(this, "browser:purge-session-history", false)
}
- jsm = "resource://gre/modules/RemoteController.jsm";
+ let jsm = "resource://gre/modules/RemoteController.jsm";
let RemoteController = Components.utils.import(jsm, {}).RemoteController;
this._controller = new RemoteController(this);
this.controllers.appendController(this._controller);
]]>
</constructor>
<destructor>
<![CDATA[
@@ -510,18 +511,18 @@
try {
this.messageManager.sendAsyncMessage("Browser:PurgeSessionHistory");
} catch (ex) {
// This can throw if the browser has started to go away.
if (ex.result != Components.results.NS_ERROR_NOT_INITIALIZED) {
throw ex;
}
}
- this.webNavigation.canGoBack = false;
- this.webNavigation.canGoForward = false;
+ this._remoteWebNavigationImpl.canGoBack = false;
+ this._remoteWebNavigationImpl.canGoForward = false;
]]>
</body>
</method>
</implementation>
</binding>
</bindings>
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -153,18 +153,18 @@ RemoteWebProgressManager.prototype = {
}
return [deserialized, aState];
},
setCurrentURI: function (aURI) {
// This function is simpler than nsDocShell::SetCurrentURI since
// it doesn't have to deal with child docshells.
- let webNavigation = this._browser.webNavigation;
- webNavigation._currentURI = aURI;
+ let remoteWebNav = this._browser._remoteWebNavigationImpl;
+ remoteWebNav._currentURI = aURI;
let webProgress = this.topLevelWebProgress;
for (let p of this._progressListeners) {
p.onLocationChange(webProgress, null, aURI);
}
},
_callProgressListeners: function(methodName, ...args) {
@@ -216,23 +216,24 @@ RemoteWebProgressManager.prototype = {
switch (aMessage.name) {
case "Content:StateChange":
this._callProgressListeners("onStateChange", webProgress, request, json.stateFlags, json.status);
break;
case "Content:LocationChange":
let location = newURI(json.location);
let flags = json.flags;
+ let remoteWebNav = this._browser._remoteWebNavigationImpl;
// These properties can change even for a sub-frame navigation.
- this._browser.webNavigation.canGoBack = json.canGoBack;
- this._browser.webNavigation.canGoForward = json.canGoForward;
+ remoteWebNav.canGoBack = json.canGoBack;
+ remoteWebNav.canGoForward = json.canGoForward;
if (isTopLevel) {
- this._browser.webNavigation._currentURI = location;
+ remoteWebNav._currentURI = location;
this._browser._characterSet = json.charset;
this._browser._documentURI = newURI(json.documentURI);
this._browser._contentTitle = json.title;
this._browser._imageDocument = null;
this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
this._browser._contentPrincipal = json.principal;
this._browser._isSyntheticDocument = json.synthetic;
this._browser._innerWindowID = json.innerWindowID;
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -52,17 +52,16 @@ EXTRA_JS_MODULES += [
'Promise.jsm',
'PromiseMessage.jsm',
'PromiseUtils.jsm',
'PropertyListUtils.jsm',
'RemoteController.jsm',
'RemoteFinder.jsm',
'RemotePageManager.jsm',
'RemoteSecurityUI.jsm',
- 'RemoteWebNavigation.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',
'secondscreen/RokuApp.jsm',
'secondscreen/SimpleServiceDiscovery.jsm',
'SelectContentHelper.jsm',
'SelectParentHelper.jsm',
'Services.jsm',
'SessionRecorder.jsm',
--- a/toolkit/modules/tests/browser/browser.ini
+++ b/toolkit/modules/tests/browser/browser.ini
@@ -28,10 +28,9 @@ skip-if = e10s # Bug ?????? - test alrea
[browser_Geometry.js]
[browser_InlineSpellChecker.js]
[browser_WebNavigation.js]
[browser_WebRequest.js]
[browser_WebRequest_cookies.js]
[browser_WebRequest_filtering.js]
[browser_PageMetadata.js]
[browser_RemotePageManager.js]
-[browser_RemoteWebNavigation.js]
[browser_Troubleshoot.js]