зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1705872 - Clear history's epoch in the parent when replacing BC. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D116243
This commit is contained in:
Родитель
9c187bf312
Коммит
ca3c587dfc
|
@ -214,10 +214,10 @@ void CanonicalBrowsingContext::ReplacedBy(
|
|||
|
||||
if (mSessionHistory) {
|
||||
mSessionHistory->SetBrowsingContext(aNewContext);
|
||||
if (mozilla::BFCacheInParent()) {
|
||||
// XXXBFCache Should we clear the epoch always?
|
||||
mSessionHistory->SetEpoch(0, Nothing());
|
||||
}
|
||||
// At this point we will be creating a new ChildSHistory in the child.
|
||||
// That means that the child's epoch will be reset, so it makes sense to
|
||||
// reset the epoch in the parent too.
|
||||
mSessionHistory->SetEpoch(0, Nothing());
|
||||
mSessionHistory.swap(aNewContext->mSessionHistory);
|
||||
RefPtr<ChildSHistory> childSHistory = ForgetChildSHistory();
|
||||
aNewContext->SetChildSHistory(childSHistory);
|
||||
|
|
|
@ -193,3 +193,4 @@ support-files =
|
|||
[browser_bug1648464-1.js]
|
||||
[browser_bug1688368-1.js]
|
||||
[browser_bug1691153.js]
|
||||
[browser_bug1705872.js]
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
"use strict";
|
||||
|
||||
async function doLoadAndGoBack(browser, ext) {
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser);
|
||||
BrowserTestUtils.loadURI(browser, "https://example.com/");
|
||||
await ext.awaitMessage("redir-handled");
|
||||
await loaded;
|
||||
|
||||
let pageShownPromise = BrowserTestUtils.waitForContentEvent(
|
||||
browser,
|
||||
"pageshow",
|
||||
true
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.history.back();
|
||||
});
|
||||
return pageShownPromise;
|
||||
}
|
||||
|
||||
add_task(async function test_back() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: ["webRequest", "webRequestBlocking", "https://example.com/"],
|
||||
web_accessible_resources: ["test.html"],
|
||||
},
|
||||
files: {
|
||||
"test.html":
|
||||
"<!DOCTYPE html><html><head><title>Test add-on</title></head><body></body></html>",
|
||||
},
|
||||
background: () => {
|
||||
let { browser } = this;
|
||||
browser.webRequest.onHeadersReceived.addListener(
|
||||
details => {
|
||||
if (details.statusCode != 200) {
|
||||
return undefined;
|
||||
}
|
||||
browser.test.sendMessage("redir-handled");
|
||||
return { redirectUrl: browser.runtime.getURL("test.html") };
|
||||
},
|
||||
{
|
||||
urls: ["https://example.com/"],
|
||||
types: ["main_frame"],
|
||||
},
|
||||
["blocking"]
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:home", async function(browser) {
|
||||
await doLoadAndGoBack(browser, extension);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
is(
|
||||
content.document.documentURI,
|
||||
"about:home",
|
||||
"Gone back to the right page"
|
||||
);
|
||||
});
|
||||
|
||||
await doLoadAndGoBack(browser, extension);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
is(
|
||||
content.document.documentURI,
|
||||
"about:home",
|
||||
"Gone back to the right page"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
});
|
Загрузка…
Ссылка в новой задаче