Bug 1256468 - sessionHistory shim should QI DocShell to nsIWebNavigation automatically. r?gkrizsanits
MozReview-Commit-ID: 8benvQvcfLO
--- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm
+++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm
@@ -858,17 +858,17 @@ function getContentDocument(addon, brows
function getSessionHistory(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;
+ return remoteChromeGlobal.docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
}
RemoteBrowserElementInterposition.getters.contentDocument = function(addon, target) {
CompatWarning.warn("Direct access to browser.contentDocument will no longer work in the chrome process.",
addon, CompatWarning.warnings.content);
return getContentDocument(addon, target);
};
--- a/toolkit/components/addoncompat/tests/addon/bootstrap.js
+++ b/toolkit/components/addoncompat/tests/addon/bootstrap.js
@@ -56,16 +56,17 @@ function testContentWindow()
let tab = gBrowser.addTab(url);
gBrowser.selectedTab = tab;
let browser = tab.linkedBrowser;
addLoadListener(browser, function handler() {
ok(gWin.content, "content is defined on chrome window");
ok(browser.contentWindow, "contentWindow is defined");
ok(browser.contentDocument, "contentWindow is defined");
is(gWin.content, browser.contentWindow, "content === contentWindow");
+ ok(browser.webNavigation.sessionHistory, "sessionHistory is defined");
ok(browser.contentDocument.getElementById("link"), "link present in document");
// FIXME: Waiting on bug 1073631.
//is(browser.contentWindow.wrappedJSObject.global, 3, "global available on document");
removeTab(tab, resolve);
});