Skip to content

Commit

Permalink
Bug 1666783 - Remove nsIDocShell::GetInterface(nsISHistory). r=smaug
Browse files Browse the repository at this point in the history
Also assert that it's never used.

Differential Revision: https://phabricator.services.mozilla.com/D91142
  • Loading branch information
farre committed Sep 24, 2020
1 parent beaadd9 commit b8268ce
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
5 changes: 2 additions & 3 deletions browser/base/content/test/general/browser_bug623893.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ add_task(async function test() {
async function promiseGetIndex(browser) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
return SpecialPowers.spawn(browser, [], function() {
let shistory = docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsISHistory);
let shistory =
docShell.browsingContext.childSessionHistory.legacySHistory;
return shistory.index;
});
}
Expand Down
2 changes: 1 addition & 1 deletion browser/components/sessionstore/test/browser_687710_2.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ add_task(async function test() {
}
}

let history = docShell.sessionHistory.legacySHistory;
let history = docShell.browsingContext.childSessionHistory.legacySHistory;

is(history.count, 2, "history.count");
for (let i = 0; i < history.count; i++) {
Expand Down
12 changes: 8 additions & 4 deletions browser/components/sessionstore/test/browser_history_persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ add_task(async function check_history_not_persisted() {

if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory = docShell.sessionHistory.legacySHistory;
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

is(sessionHistory.count, 1, "Should be a single history entry");
is(
Expand All @@ -52,7 +53,8 @@ add_task(async function check_history_not_persisted() {
await promiseBrowserLoaded(browser);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory = docShell.sessionHistory.legacySHistory;
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

is(sessionHistory.count, 1, "Should be a single history entry");
is(
Expand Down Expand Up @@ -99,7 +101,8 @@ add_task(async function check_history_default_persisted() {
await promiseTabState(tab, state);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory = docShell.sessionHistory.legacySHistory;
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

is(sessionHistory.count, 1, "Should be a single history entry");
is(
Expand All @@ -124,7 +127,8 @@ add_task(async function check_history_default_persisted() {
await promiseBrowserLoaded(browser);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory = docShell.sessionHistory.legacySHistory;
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

is(sessionHistory.count, 2, "Should be two history entries");
is(
Expand Down
11 changes: 4 additions & 7 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,10 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) {
? NS_OK
: NS_NOINTERFACE;
} else if (aIID.Equals(NS_GET_IID(nsISHistory))) {
RefPtr<ChildSHistory> shistory = GetSessionHistory();
if (shistory) {
// XXX(nika): Stop exposing nsISHistory through GetInterface.
nsCOMPtr<nsISHistory> legacy = shistory->LegacySHistory();
legacy.forget(aSink);
return NS_OK;
}
// This is deprecated, you should instead directly get
// ChildSHistory from the browsing context.
MOZ_DIAGNOSTIC_ASSERT(
false, "Do not try to get a nsISHistory interface from nsIDocShell");
return NS_NOINTERFACE;
} else if (aIID.Equals(NS_GET_IID(nsIWebBrowserFind))) {
nsresult rv = EnsureFind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ add_task(async function test_history() {
async function checkHistoryIndex(browser, n) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
return SpecialPowers.spawn(browser, [n], function(n) {
let history = docShell.sessionHistory.legacySHistory;
let history =
docShell.browsingContext.childSessionHistory.legacySHistory;

is(history.index, n, "Should be at the right place in history");
});
Expand All @@ -75,7 +76,7 @@ add_task(async function test_history() {
dummy1,
dummy2,
]) {
let history = docShell.sessionHistory.legacySHistory;
let history = docShell.browsingContext.childSessionHistory.legacySHistory;

is(history.count, 2, "Should be two history items");
is(history.index, 1, "Should be at the right place in history");
Expand Down Expand Up @@ -122,7 +123,8 @@ add_task(async function test_flags() {
count,
index,
]) {
let history = docShell.sessionHistory.legacySHistory;
let history =
docShell.browsingContext.childSessionHistory.legacySHistory;
is(history.count, count, "Should be one history item");
is(history.index, index, "Should be at the right place in history");
let entry = history.getEntryAtIndex(index);
Expand Down

0 comments on commit b8268ce

Please sign in to comment.