Bug 1233803 - Add RemoteWebNavigation sessionHistory shim for addons. r=krizsa

This commit is contained in:
Mike Conley 2016-01-07 09:52:35 -05:00
parent 3a8712ea2c
commit 1f5f37be76

View File

@ -955,6 +955,34 @@ ChromeWindowInterposition.getters._content = function(addon, target) {
return browser.contentWindowAsCPOW;
};
var RemoteWebNavigationInterposition = new Interposition("RemoteWebNavigation");
RemoteWebNavigationInterposition.getters.sessionHistory = function(addon, target) {
CompatWarning.warn("Direct access to browser.sessionHistory will no longer work in the chrome process.",
addon, CompatWarning.warnings.content);
if (target instanceof Ci.nsIDocShell) {
// We must have a non-remote browser, so we can go ahead
// and just return the real sessionHistory.
return target.sessionHistory;
}
let impl = target.wrappedJSObject;
if (!impl) {
return null;
}
let browser = impl._browser;
let remoteChromeGlobal = RemoteAddonsParent.browserToGlobal.get(browser);
if (!remoteChromeGlobal) {
CompatWarning.warn("CPOW for the remote browser docShell hasn't been received yet.");
// We may not have any messages from this tab yet.
return null;
}
return remoteChromeGlobal.docShell.sessionHistory;
}
var RemoteAddonsParent = {
init: function() {
let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
@ -977,6 +1005,7 @@ var RemoteAddonsParent = {
register(Ci.nsIComponentRegistrar, ComponentRegistrarInterposition);
register(Ci.nsIObserverService, ObserverInterposition);
register(Ci.nsIXPCComponents_Utils, ComponentsUtilsInterposition);
register(Ci.nsIWebNavigation, RemoteWebNavigationInterposition);
return result;
},