mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 14:56:07 +00:00
Bug 1320391 - Part 2: Add a test that old PartialSHistories are cleaned up correctly, r=ehsan
MozReview-Commit-ID: 4Jd5UbmdEru --HG-- extra : rebase_source : 42407f987d2b6e7c3ed3a91e9f75e3911e292091
This commit is contained in:
parent
1b315d2194
commit
593da2333f
@ -95,3 +95,5 @@ skip-if = true # Bug 1220415
|
||||
skip-if = !e10s
|
||||
[browser_grouped_shistory_crossproc.js]
|
||||
skip-if = !e10s
|
||||
[browser_grouped_shistory_bfcache_cleaning.js]
|
||||
skip-if = !e10s
|
||||
|
@ -0,0 +1,61 @@
|
||||
add_task(function* () {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.groupedhistory.enabled", true]]
|
||||
});
|
||||
|
||||
// Wait for a process change and then fulfil the promise.
|
||||
function awaitProcessChange(browser) {
|
||||
return new Promise(resolve => {
|
||||
browser.addEventListener("BrowserChangedProcess", function bcp(e) {
|
||||
browser.removeEventListener("BrowserChangedProcess", bcp);
|
||||
ok(true, "The browser changed process!");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function isAlive(tab) {
|
||||
return tab.linkedBrowser &&
|
||||
tab.linkedBrowser.frameLoader &&
|
||||
!tab.linkedBrowser.frameLoader.isDead;
|
||||
}
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
|
||||
// Set up the grouped SHEntry setup
|
||||
let tab2 = gBrowser.loadOneTab("data:text/html,b", {
|
||||
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
|
||||
allowThirdPartyFixup: true,
|
||||
relatedToCurrent: true,
|
||||
isPrerendered: true,
|
||||
});
|
||||
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
browser1.frameLoader.appendPartialSessionHistoryAndSwap(
|
||||
tab2.linkedBrowser.frameLoader);
|
||||
yield awaitProcessChange(browser1);
|
||||
ok(isAlive(tab2));
|
||||
|
||||
// Load some URIs and make sure that we lose the old process once we are 3 history entries away.
|
||||
browser1.loadURI("data:text/html,c", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
browser1.loadURI("data:text/html,d", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
browser1.loadURI("data:text/html,e", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
|
||||
// The 4th navigation should kill the frameloader
|
||||
browser1.loadURI("data:text/html,f", null, null);
|
||||
yield new Promise(resolve => {
|
||||
tab2.addEventListener("TabClose", function f() {
|
||||
tab2.removeEventListener("TabClose", f);
|
||||
ok(true, "The tab is being closed!\n");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
// We don't check for !isAlive() as TabClose is called during
|
||||
// _beginRemoveTab, which means that the frameloader may not be dead yet. We
|
||||
// avoid races by not checking.
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user