forked from mirrors/gecko-dev
NOTE: The '__SSi' and '__SS_lastSessionWindowID' properties on windows are kept,
because they are expected to stick around longer during application shutdown.
The benefits is are:
1. Cleaner code - Sessionstore implementation details are not leaked outside its
module.
2. Observing the lifetime of objects becomes unnecessary, because the WeakMaps are
cleaned up when objects are GC'd, making leakage of their references impossible
and Sessionstore can't hold objects hostage anymore.
3. Simplification - all state is now maintained in SessionStore.jsm, which allows
for additional refactoring later on to simplify the implementation further.
MozReview-Commit-ID: C1II8qHkQ6F
--HG--
extra : rebase_source : e5fc6984558bd455a33e275f7060d42c93c21720
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const TAB_STATE = {
|
|
entries: [
|
|
{ url: "about:mozilla", triggeringPrincipal_base64 },
|
|
{ url: "about:robots", triggeringPrincipal_base64 }],
|
|
index: 1,
|
|
};
|
|
|
|
add_task(async function() {
|
|
// Create a background tab.
|
|
let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
|
let browser = tab.linkedBrowser;
|
|
await promiseBrowserLoaded(browser);
|
|
|
|
// The tab shouldn't be restored right away.
|
|
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
|
|
|
|
// Prepare the tab state.
|
|
let promise = promiseTabRestoring(tab);
|
|
ss.setTabState(tab, JSON.stringify(TAB_STATE));
|
|
ok(tab.hasAttribute("pending"), "tab is pending");
|
|
await promise;
|
|
|
|
// Flush to ensure the parent has all data.
|
|
await TabStateFlusher.flush(browser);
|
|
|
|
// Check that the shistory index is the one we restored.
|
|
let tabState = TabState.collect(tab, ss.getInternalObjectState(tab));
|
|
is(tabState.index, TAB_STATE.index, "correct shistory index");
|
|
|
|
// Check we don't collect userTypedValue when we shouldn't.
|
|
ok(!tabState.userTypedValue, "tab didn't have a userTypedValue");
|
|
|
|
// Cleanup.
|
|
gBrowser.removeTab(tab);
|
|
});
|