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.

--HG--
rename : toolkit/modules/RemoteWebNavigation.jsm => toolkit/components/remotebrowserutils/RemoteWebNavigation.js
rename : toolkit/modules/tests/browser/.eslintrc => toolkit/components/remotebrowserutils/tests/browser/.eslintrc
rename : toolkit/modules/tests/browser/browser.ini => toolkit/components/remotebrowserutils/tests/browser/browser.ini
rename : toolkit/modules/tests/browser/browser_RemoteWebNavigation.js => toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
rename : toolkit/modules/tests/browser/dummy_page.html => toolkit/components/remotebrowserutils/tests/browser/dummy_page.html
extra : commitid : 4W88YStCJVA
extra : rebase_source : 96dddec843c37571627de6b7237c4c96fe0607c0
extra : histedit_source : fba01b49a1191a3502811485f95ee6bea8f3a047
This commit is contained in:
Mike Conley 2016-01-12 16:44:08 -05:00
parent 877e4e8a44
commit c2fca6da5e
14 changed files with 66 additions and 23 deletions

View File

@ -546,6 +546,9 @@
@RESPATH@/components/Push.manifest
@RESPATH@/components/PushComponents.js
@RESPATH@/components/remotebrowserutils.manifest
@RESPATH@/components/RemoteWebNavigation.js
@RESPATH@/components/SlowScriptDebug.manifest
@RESPATH@/components/SlowScriptDebug.js

View File

@ -45,6 +45,7 @@ DIRS += [
'prompts',
'protobuf',
'reader',
'remotebrowserutils',
'reflect',
'sqlite',
'startup',

View File

@ -3,31 +3,35 @@
// 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) {
@ -135,3 +139,5 @@ RemoteWebNavigation.prototype = {
}
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteWebNavigation]);

View File

@ -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']

View File

@ -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

View File

@ -0,0 +1,5 @@
{
"extends": [
"../../../../../testing/mochitest/browser.eslintrc"
]
}

View File

@ -0,0 +1,6 @@
[DEFAULT]
run-if = e10s
support-files =
dummy_page.html
[browser_RemoteWebNavigation.js]

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<p>Page</p>
</body>
</html>

View File

@ -1179,6 +1179,7 @@
if (this.isRemoteBrowser) {
fieldsToSwap.push(...[
"_remoteWebNavigation",
"_remoteWebNavigationImpl",
"_remoteWebProgressManager",
"_remoteWebProgress",
"_remoteFinder",
@ -1233,8 +1234,8 @@
}
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);

View File

@ -341,9 +341,10 @@
* 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);
@ -366,7 +367,7 @@
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);
@ -515,8 +516,8 @@
throw ex;
}
}
this.webNavigation.canGoBack = false;
this.webNavigation.canGoForward = false;
this._remoteWebNavigationImpl.canGoBack = false;
this._remoteWebNavigationImpl.canGoForward = false;
]]>
</body>
</method>

View File

@ -158,8 +158,8 @@ RemoteWebProgressManager.prototype = {
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) {
@ -221,13 +221,14 @@ RemoteWebProgressManager.prototype = {
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;

View File

@ -57,7 +57,6 @@ EXTRA_JS_MODULES += [
'RemoteFinder.jsm',
'RemotePageManager.jsm',
'RemoteSecurityUI.jsm',
'RemoteWebNavigation.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',
'secondscreen/RokuApp.jsm',

View File

@ -33,5 +33,4 @@ skip-if = e10s # Bug ?????? - test already uses content scripts, but still fails
[browser_WebRequest_filtering.js]
[browser_PageMetadata.js]
[browser_RemotePageManager.js]
[browser_RemoteWebNavigation.js]
[browser_Troubleshoot.js]