summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:21:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:21:19 +0000
commit520a92573ce79e3628762e4ce06e284d50c2e548 (patch)
treedd7bece82fdce266f06a6a2a6043264255631ee7 /browser/components/sessionstore/test
parentAdding debian version 115.10.0esr-1~deb12u1. (diff)
downloadfirefox-esr-520a92573ce79e3628762e4ce06e284d50c2e548.tar.xz
firefox-esr-520a92573ce79e3628762e4ce06e284d50c2e548.zip
Merging upstream version 115.11.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test')
-rw-r--r--browser/components/sessionstore/test/browser.ini4
-rw-r--r--browser/components/sessionstore/test/browser_687710_2.js66
-rw-r--r--browser/components/sessionstore/test/browser_705597.js10
-rw-r--r--browser/components/sessionstore/test/browser_707862.js20
-rw-r--r--browser/components/sessionstore/test/browser_async_flushes.js52
-rw-r--r--browser/components/sessionstore/test/browser_async_remove_tab.js30
-rw-r--r--browser/components/sessionstore/test/browser_async_window_flushing.js11
-rw-r--r--browser/components/sessionstore/test/browser_attributes.js59
-rw-r--r--browser/components/sessionstore/test/browser_bfcache_telemetry.js3
-rw-r--r--browser/components/sessionstore/test/browser_docshell_uuid_consistency.js94
-rw-r--r--browser/components/sessionstore/test/browser_history_persist.js138
-rw-r--r--browser/components/sessionstore/test/browser_send_async_message_oom.js75
-rw-r--r--browser/components/sessionstore/test/browser_sessionHistory.js9
-rw-r--r--browser/components/sessionstore/test/head.js41
14 files changed, 142 insertions, 470 deletions
diff --git a/browser/components/sessionstore/test/browser.ini b/browser/components/sessionstore/test/browser.ini
index 85e0c40448..a282c6f268 100644
--- a/browser/components/sessionstore/test/browser.ini
+++ b/browser/components/sessionstore/test/browser.ini
@@ -218,7 +218,6 @@ support-files = file_async_duplicate_tab.html
support-files = file_async_flushes.html
run-if = crashreporter
[browser_async_remove_tab.js]
-skip-if = !sessionHistoryInParent
[browser_async_window_flushing.js]
https_first_disabled = true
skip-if =
@@ -319,7 +318,6 @@ skip-if =
ccov # Bug 1625525
[browser_privatetabs.js]
[browser_purge_shistory.js]
-skip-if = !sessionHistoryInParent # Bug 1271024
[browser_remoteness_flip_on_restore.js]
[browser_reopen_all_windows.js]
https_first_disabled = true
@@ -348,8 +346,6 @@ skip-if =
!fission
os == "linux" # Bug 1716445
[browser_scrollPositionsReaderMode.js]
-[browser_send_async_message_oom.js]
-skip-if = sessionHistoryInParent # Tests that the frame script OOMs, which is unused when SHIP is enabled.
[browser_sessionHistory.js]
https_first_disabled = true
support-files =
diff --git a/browser/components/sessionstore/test/browser_687710_2.js b/browser/components/sessionstore/test/browser_687710_2.js
index 81d3c55379..190b5a718a 100644
--- a/browser/components/sessionstore/test/browser_687710_2.js
+++ b/browser/components/sessionstore/test/browser_687710_2.js
@@ -38,61 +38,31 @@ var state = {
add_task(async function test() {
let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
await promiseTabState(tab, state);
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(tab.linkedBrowser, [], function () {
- function compareEntries(i, j, history) {
- let e1 = history.getEntryAtIndex(i);
- let e2 = history.getEntryAtIndex(j);
- ok(e1.sharesDocumentWith(e2), `${i} should share doc with ${j}`);
- is(e1.childCount, e2.childCount, `Child count mismatch (${i}, ${j})`);
+ function compareEntries(i, j, history) {
+ let e1 = history.getEntryAtIndex(i);
+ let e2 = history.getEntryAtIndex(j);
- for (let c = 0; c < e1.childCount; c++) {
- let c1 = e1.GetChildAt(c);
- let c2 = e2.GetChildAt(c);
+ ok(e1.sharesDocumentWith(e2), `${i} should share doc with ${j}`);
+ is(e1.childCount, e2.childCount, `Child count mismatch (${i}, ${j})`);
- ok(
- c1.sharesDocumentWith(c2),
- `Cousins should share documents. (${i}, ${j}, ${c})`
- );
- }
- }
+ for (let c = 0; c < e1.childCount; c++) {
+ let c1 = e1.GetChildAt(c);
+ let c2 = e2.GetChildAt(c);
- let history = docShell.browsingContext.childSessionHistory.legacySHistory;
-
- is(history.count, 2, "history.count");
- for (let i = 0; i < history.count; i++) {
- for (let j = 0; j < history.count; j++) {
- compareEntries(i, j, history);
- }
- }
- });
- } else {
- function compareEntries(i, j, history) {
- let e1 = history.getEntryAtIndex(i);
- let e2 = history.getEntryAtIndex(j);
-
- ok(e1.sharesDocumentWith(e2), `${i} should share doc with ${j}`);
- is(e1.childCount, e2.childCount, `Child count mismatch (${i}, ${j})`);
-
- for (let c = 0; c < e1.childCount; c++) {
- let c1 = e1.GetChildAt(c);
- let c2 = e2.GetChildAt(c);
-
- ok(
- c1.sharesDocumentWith(c2),
- `Cousins should share documents. (${i}, ${j}, ${c})`
- );
- }
+ ok(
+ c1.sharesDocumentWith(c2),
+ `Cousins should share documents. (${i}, ${j}, ${c})`
+ );
}
+ }
- let history = tab.linkedBrowser.browsingContext.sessionHistory;
+ let history = tab.linkedBrowser.browsingContext.sessionHistory;
- is(history.count, 2, "history.count");
- for (let i = 0; i < history.count; i++) {
- for (let j = 0; j < history.count; j++) {
- compareEntries(i, j, history);
- }
+ is(history.count, 2, "history.count");
+ for (let i = 0; i < history.count; i++) {
+ for (let j = 0; j < history.count; j++) {
+ compareEntries(i, j, history);
}
}
diff --git a/browser/components/sessionstore/test/browser_705597.js b/browser/components/sessionstore/test/browser_705597.js
index d497e46a97..10f4f08863 100644
--- a/browser/components/sessionstore/test/browser_705597.js
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -26,14 +26,8 @@ function test() {
let browser = tab.linkedBrowser;
promiseTabState(tab, tabState).then(() => {
- let entry;
- if (!Services.appinfo.sessionHistoryInParent) {
- let sessionHistory = browser.sessionHistory;
- entry = sessionHistory.legacySHistory.getEntryAtIndex(0);
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
- entry = sessionHistory.getEntryAtIndex(0);
- }
+ let sessionHistory = browser.browsingContext.sessionHistory;
+ let entry = sessionHistory.getEntryAtIndex(0);
whenChildCount(entry, 1, function () {
whenChildCount(entry, 2, function () {
diff --git a/browser/components/sessionstore/test/browser_707862.js b/browser/components/sessionstore/test/browser_707862.js
index 765c63257f..4559362e21 100644
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -26,26 +26,14 @@ function test() {
let browser = tab.linkedBrowser;
promiseTabState(tab, tabState).then(() => {
- let entry;
- if (!Services.appinfo.sessionHistoryInParent) {
- let sessionHistory = browser.sessionHistory;
- entry = sessionHistory.legacySHistory.getEntryAtIndex(0);
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
- entry = sessionHistory.getEntryAtIndex(0);
- }
+ let sessionHistory = browser.browsingContext.sessionHistory;
+ let entry = sessionHistory.getEntryAtIndex(0);
whenChildCount(entry, 1, function () {
whenChildCount(entry, 2, function () {
promiseBrowserLoaded(browser).then(() => {
- let newEntry;
- if (!Services.appinfo.sessionHistoryInParent) {
- let newSessionHistory = browser.sessionHistory;
- newEntry = newSessionHistory.legacySHistory.getEntryAtIndex(0);
- } else {
- let newSessionHistory = browser.browsingContext.sessionHistory;
- newEntry = newSessionHistory.getEntryAtIndex(0);
- }
+ let newSessionHistory = browser.browsingContext.sessionHistory;
+ let newEntry = newSessionHistory.getEntryAtIndex(0);
whenChildCount(newEntry, 0, function () {
// Make sure that we reset the state.
diff --git a/browser/components/sessionstore/test/browser_async_flushes.js b/browser/components/sessionstore/test/browser_async_flushes.js
index e35593dc30..d0bf039ff2 100644
--- a/browser/components/sessionstore/test/browser_async_flushes.js
+++ b/browser/components/sessionstore/test/browser_async_flushes.js
@@ -44,58 +44,6 @@ add_task(async function test_flush() {
gBrowser.removeTab(tab);
});
-add_task(async function test_crash() {
- if (Services.appinfo.sessionHistoryInParent) {
- // This test relies on frame script message ordering. Since the frame script
- // is unused with SHIP, there's no guarantee that we'll crash the frame
- // before we've started the flush.
- ok(true, "Test relies on frame script message ordering.");
- return;
- }
-
- // Create new tab.
- let tab = BrowserTestUtils.addTab(gBrowser, URL);
- gBrowser.selectedTab = tab;
- let browser = tab.linkedBrowser;
- await promiseBrowserLoaded(browser);
-
- // Flush to empty any queued update messages.
- await TabStateFlusher.flush(browser);
-
- // There should be one history entry.
- let { entries } = JSON.parse(ss.getTabState(tab));
- is(entries.length, 1, "there is a single history entry");
-
- // Click the link to navigate.
- await SpecialPowers.spawn(browser, [], async function () {
- return new Promise(resolve => {
- docShell.chromeEventHandler.addEventListener(
- "hashchange",
- () => resolve(),
- { once: true, capture: true }
- );
-
- // Click the link.
- content.document.querySelector("a").click();
- });
- });
-
- // Crash the browser and flush. Both messages are async and will be sent to
- // the content process. The "crash" message makes it first so that we don't
- // get a chance to process the flush. The TabStateFlusher however should be
- // notified so that the flush still completes.
- let promise1 = BrowserTestUtils.crashFrame(browser);
- let promise2 = TabStateFlusher.flush(browser);
- await Promise.all([promise1, promise2]);
-
- // The pending update should be lost.
- ({ entries } = JSON.parse(ss.getTabState(tab)));
- is(entries.length, 1, "still only one history entry");
-
- // Cleanup.
- gBrowser.removeTab(tab);
-});
-
add_task(async function test_remove() {
// Create new tab.
let tab = BrowserTestUtils.addTab(gBrowser, URL);
diff --git a/browser/components/sessionstore/test/browser_async_remove_tab.js b/browser/components/sessionstore/test/browser_async_remove_tab.js
index 6f744ade3c..28c20512f1 100644
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -92,15 +92,7 @@ add_task(async function save_worthy_tabs_remote_final() {
ok(browser.isRemoteBrowser, "browser is still remote");
// Remove the tab before the update arrives.
- let promise = promiseRemoveTabAndSessionState(tab);
-
- // With SHIP, we'll do the final tab state update sooner than we did before.
- if (!Services.appinfo.sessionHistoryInParent) {
- // No tab state worth saving (that we know about yet).
- ok(!isValueInClosedData(r), "closed tab not saved");
- }
-
- await promise;
+ await promiseRemoveTabAndSessionState(tab);
// Turns out there is a tab state worth saving.
ok(isValueInClosedData(r), "closed tab saved");
@@ -117,15 +109,7 @@ add_task(async function save_worthy_tabs_nonremote_final() {
ok(!browser.isRemoteBrowser, "browser is not remote anymore");
// Remove the tab before the update arrives.
- let promise = promiseRemoveTabAndSessionState(tab);
-
- // With SHIP, we'll do the final tab state update sooner than we did before.
- if (!Services.appinfo.sessionHistoryInParent) {
- // No tab state worth saving (that we know about yet).
- ok(!isValueInClosedData(r), "closed tab not saved");
- }
-
- await promise;
+ await promiseRemoveTabAndSessionState(tab);
// Turns out there is a tab state worth saving.
ok(isValueInClosedData(r), "closed tab saved");
@@ -151,15 +135,7 @@ add_task(async function dont_save_empty_tabs_final() {
await entryReplaced;
// Remove the tab before the update arrives.
- let promise = promiseRemoveTabAndSessionState(tab);
-
- // With SHIP, we'll do the final tab state update sooner than we did before.
- if (!Services.appinfo.sessionHistoryInParent) {
- // Tab state deemed worth saving (yet).
- ok(isValueInClosedData(r), "closed tab saved");
- }
-
- await promise;
+ await promiseRemoveTabAndSessionState(tab);
// Turns out we don't want to save the tab state.
ok(!isValueInClosedData(r), "closed tab not saved");
diff --git a/browser/components/sessionstore/test/browser_async_window_flushing.js b/browser/components/sessionstore/test/browser_async_window_flushing.js
index 56781896d8..56cd3ad1e3 100644
--- a/browser/components/sessionstore/test/browser_async_window_flushing.js
+++ b/browser/components/sessionstore/test/browser_async_window_flushing.js
@@ -116,17 +116,10 @@ add_task(async function test_remove_uninteresting_window() {
await SpecialPowers.spawn(browser, [], async function () {
// Epic hackery to make this browser seem suddenly boring.
docShell.setCurrentURIForSessionStore(Services.io.newURI("about:blank"));
-
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- let { sessionHistory } = docShell.QueryInterface(Ci.nsIWebNavigation);
- sessionHistory.legacySHistory.purgeHistory(sessionHistory.count);
- }
});
- if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- let { sessionHistory } = browser.browsingContext;
- sessionHistory.purgeHistory(sessionHistory.count);
- }
+ let { sessionHistory } = browser.browsingContext;
+ sessionHistory.purgeHistory(sessionHistory.count);
// Once this windowClosed Promise resolves, we should have finished
// the flush and revisited our decision to put this window into
diff --git a/browser/components/sessionstore/test/browser_attributes.js b/browser/components/sessionstore/test/browser_attributes.js
index 336573a508..db349a31a2 100644
--- a/browser/components/sessionstore/test/browser_attributes.js
+++ b/browser/components/sessionstore/test/browser_attributes.js
@@ -38,45 +38,68 @@ add_task(async function test() {
ok(tab.hasAttribute("muted"), "tab.muted exists");
// Make sure we do not persist 'image' and 'muted' attributes.
- ss.persistTabAttribute("image");
- ss.persistTabAttribute("muted");
let { attributes } = JSON.parse(ss.getTabState(tab));
ok(!("image" in attributes), "'image' attribute not saved");
ok(!("muted" in attributes), "'muted' attribute not saved");
- ok(!("custom" in attributes), "'custom' attribute not saved");
-
- // Test persisting a custom attribute.
- tab.setAttribute("custom", "foobar");
- ss.persistTabAttribute("custom");
-
- ({ attributes } = JSON.parse(ss.getTabState(tab)));
- is(attributes.custom, "foobar", "'custom' attribute is correct");
-
- // Make sure we're backwards compatible and restore old 'image' attributes.
+ ok(!("customizemode" in attributes), "'customizemode' attribute not saved");
+
+ // Test persisting a customizemode attribute.
+ {
+ let customizationReady = BrowserTestUtils.waitForEvent(
+ gNavToolbox,
+ "customizationready"
+ );
+ gCustomizeMode.enter();
+ await customizationReady;
+ }
+
+ let customizeIcon = gBrowser.getIcon(gBrowser.selectedTab);
+ ({ attributes } = JSON.parse(ss.getTabState(gBrowser.selectedTab)));
+ ok(!("image" in attributes), "'image' attribute not saved");
+ is(attributes.customizemode, "true", "'customizemode' attribute is correct");
+
+ {
+ let afterCustomization = BrowserTestUtils.waitForEvent(
+ gNavToolbox,
+ "aftercustomization"
+ );
+ gCustomizeMode.exit();
+ await afterCustomization;
+ }
+
+ // Test restoring a customizemode tab.
let state = {
- entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }],
- attributes: { custom: "foobaz" },
- image: gBrowser.getIcon(tab),
+ entries: [],
+ attributes: { customizemode: "true", nonpersisted: "true" },
};
+ // Customize mode doesn't like being restored on top of a non-blank tab.
+ // For the moment, it appears it isn't possible to restore customizemode onto
+ // an existing non-blank tab outside of tests, however this may be a latent
+ // bug if we ever try to do that in the future.
+ let principal = Services.scriptSecurityManager.createNullPrincipal({});
+ tab.linkedBrowser.createAboutBlankContentViewer(principal, principal);
+
// Prepare a pending tab waiting to be restored.
let promise = promiseTabRestoring(tab);
ss.setTabState(tab, JSON.stringify(state));
await promise;
ok(tab.hasAttribute("pending"), "tab is pending");
- is(gBrowser.getIcon(tab), state.image, "tab has correct icon");
+ ok(tab.hasAttribute("customizemode"), "tab is in customizemode");
+ ok(!tab.hasAttribute("nonpersisted"), "tab has no nonpersisted attribute");
+ is(gBrowser.getIcon(tab), customizeIcon, "tab has correct icon");
ok(!state.attributes.image, "'image' attribute not saved");
// Let the pending tab load.
gBrowser.selectedTab = tab;
- await promiseTabRestored(tab);
// Ensure no 'image' or 'pending' attributes are stored.
({ attributes } = JSON.parse(ss.getTabState(tab)));
ok(!("image" in attributes), "'image' attribute not saved");
ok(!("pending" in attributes), "'pending' attribute not saved");
- is(attributes.custom, "foobaz", "'custom' attribute is correct");
+ ok(!("nonpersisted" in attributes), "'nonpersisted' attribute not saved");
+ is(attributes.customizemode, "true", "'customizemode' attribute is correct");
// Clean up.
gBrowser.removeTab(tab);
diff --git a/browser/components/sessionstore/test/browser_bfcache_telemetry.js b/browser/components/sessionstore/test/browser_bfcache_telemetry.js
index daa4bcf44e..9e913eb605 100644
--- a/browser/components/sessionstore/test/browser_bfcache_telemetry.js
+++ b/browser/components/sessionstore/test/browser_bfcache_telemetry.js
@@ -39,7 +39,6 @@ async function test_bfcache_telemetry(probeInParent) {
add_task(async () => {
await test_bfcache_telemetry(
- Services.appinfo.sessionHistoryInParent &&
- Services.prefs.getBoolPref("fission.bfcacheInParent")
+ Services.prefs.getBoolPref("fission.bfcacheInParent")
);
});
diff --git a/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
index 2414e04276..42e7678a92 100644
--- a/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
+++ b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
@@ -4,38 +4,18 @@ add_task(async function duplicateTab() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
- if (!Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(tab.linkedBrowser, [], function () {
- let docshell = content.window.docShell.QueryInterface(
- Ci.nsIWebNavigation
- );
- let shEntry = docshell.sessionHistory.legacySHistory.getEntryAtIndex(0);
- is(shEntry.docshellID.toString(), docshell.historyID.toString());
- });
- } else {
- let historyID = tab.linkedBrowser.browsingContext.historyID;
- let shEntry =
- tab.linkedBrowser.browsingContext.sessionHistory.getEntryAtIndex(0);
- is(shEntry.docshellID.toString(), historyID.toString());
- }
+ let historyID = tab.linkedBrowser.browsingContext.historyID;
+ let shEntry =
+ tab.linkedBrowser.browsingContext.sessionHistory.getEntryAtIndex(0);
+ is(shEntry.docshellID.toString(), historyID.toString());
let tab2 = gBrowser.duplicateTab(tab);
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
- if (!Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(tab2.linkedBrowser, [], function () {
- let docshell = content.window.docShell.QueryInterface(
- Ci.nsIWebNavigation
- );
- let shEntry = docshell.sessionHistory.legacySHistory.getEntryAtIndex(0);
- is(shEntry.docshellID.toString(), docshell.historyID.toString());
- });
- } else {
- let historyID = tab2.linkedBrowser.browsingContext.historyID;
- let shEntry =
- tab2.linkedBrowser.browsingContext.sessionHistory.getEntryAtIndex(0);
- is(shEntry.docshellID.toString(), historyID.toString());
- }
+ historyID = tab2.linkedBrowser.browsingContext.historyID;
+ shEntry =
+ tab2.linkedBrowser.browsingContext.sessionHistory.getEntryAtIndex(0);
+ is(shEntry.docshellID.toString(), historyID.toString());
BrowserTestUtils.removeTab(tab);
BrowserTestUtils.removeTab(tab2);
@@ -47,24 +27,10 @@ add_task(async function contentToChromeNavigate() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
- if (!Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(tab.linkedBrowser, [], function () {
- let docshell = content.window.docShell.QueryInterface(
- Ci.nsIWebNavigation
- );
- let sh = docshell.sessionHistory;
- is(sh.count, 1);
- is(
- sh.legacySHistory.getEntryAtIndex(0).docshellID.toString(),
- docshell.historyID.toString()
- );
- });
- } else {
- let historyID = tab.linkedBrowser.browsingContext.historyID;
- let sh = tab.linkedBrowser.browsingContext.sessionHistory;
- is(sh.count, 1);
- is(sh.getEntryAtIndex(0).docshellID.toString(), historyID.toString());
- }
+ let historyID = tab.linkedBrowser.browsingContext.historyID;
+ let sh = tab.linkedBrowser.browsingContext.sessionHistory;
+ is(sh.count, 1);
+ is(sh.getEntryAtIndex(0).docshellID.toString(), historyID.toString());
// Force the browser to navigate to the chrome process.
BrowserTestUtils.loadURIString(tab.linkedBrowser, "about:config");
@@ -74,31 +40,17 @@ add_task(async function contentToChromeNavigate() {
let docShell = tab.linkedBrowser.frameLoader.docShell;
// 'cause we're in the chrome process, we can just directly poke at the shistory.
- if (!Services.appinfo.sessionHistoryInParent) {
- let sh = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
-
- is(sh.count, 2);
- is(
- sh.legacySHistory.getEntryAtIndex(0).docshellID.toString(),
- docShell.historyID.toString()
- );
- is(
- sh.legacySHistory.getEntryAtIndex(1).docshellID.toString(),
- docShell.historyID.toString()
- );
- } else {
- let sh = docShell.browsingContext.sessionHistory;
-
- is(sh.count, 2);
- is(
- sh.getEntryAtIndex(0).docshellID.toString(),
- docShell.historyID.toString()
- );
- is(
- sh.getEntryAtIndex(1).docshellID.toString(),
- docShell.historyID.toString()
- );
- }
+ sh = docShell.browsingContext.sessionHistory;
+
+ is(sh.count, 2);
+ is(
+ sh.getEntryAtIndex(0).docshellID.toString(),
+ docShell.historyID.toString()
+ );
+ is(
+ sh.getEntryAtIndex(1).docshellID.toString(),
+ docShell.historyID.toString()
+ );
BrowserTestUtils.removeTab(tab);
});
diff --git a/browser/components/sessionstore/test/browser_history_persist.js b/browser/components/sessionstore/test/browser_history_persist.js
index b45a2b6779..4b098a9edb 100644
--- a/browser/components/sessionstore/test/browser_history_persist.js
+++ b/browser/components/sessionstore/test/browser_history_persist.js
@@ -25,54 +25,27 @@ add_task(async function check_history_not_persisted() {
browser = tab.linkedBrowser;
await promiseTabState(tab, state);
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(browser, [], function () {
- let sessionHistory =
- docShell.browsingContext.childSessionHistory.legacySHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- });
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- }
+ let sessionHistory = browser.browsingContext.sessionHistory;
+
+ is(sessionHistory.count, 1, "Should be a single history entry");
+ is(
+ sessionHistory.getEntryAtIndex(0).URI.spec,
+ "about:blank",
+ "Should be the right URL"
+ );
// Load a new URL into the tab, it should replace the about:blank history entry
BrowserTestUtils.loadURIString(browser, "about:robots");
await promiseBrowserLoaded(browser, false, "about:robots");
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(browser, [], function () {
- let sessionHistory =
- docShell.browsingContext.childSessionHistory.legacySHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:robots",
- "Should be the right URL"
- );
- });
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:robots",
- "Should be the right URL"
- );
- }
+
+ sessionHistory = browser.browsingContext.sessionHistory;
+
+ is(sessionHistory.count, 1, "Should be a single history entry");
+ is(
+ sessionHistory.getEntryAtIndex(0).URI.spec,
+ "about:robots",
+ "Should be the right URL"
+ );
// Cleanup.
BrowserTestUtils.removeTab(tab);
@@ -99,64 +72,33 @@ add_task(async function check_history_default_persisted() {
tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
browser = tab.linkedBrowser;
await promiseTabState(tab, state);
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(browser, [], function () {
- let sessionHistory =
- docShell.browsingContext.childSessionHistory.legacySHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- });
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
-
- is(sessionHistory.count, 1, "Should be a single history entry");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- }
+
+ let sessionHistory = browser.browsingContext.sessionHistory;
+
+ is(sessionHistory.count, 1, "Should be a single history entry");
+ is(
+ sessionHistory.getEntryAtIndex(0).URI.spec,
+ "about:blank",
+ "Should be the right URL"
+ );
// Load a new URL into the tab, it should replace the about:blank history entry
BrowserTestUtils.loadURIString(browser, "about:robots");
await promiseBrowserLoaded(browser, false, "about:robots");
- if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- await SpecialPowers.spawn(browser, [], function () {
- let sessionHistory =
- docShell.browsingContext.childSessionHistory.legacySHistory;
-
- is(sessionHistory.count, 2, "Should be two history entries");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- is(
- sessionHistory.getEntryAtIndex(1).URI.spec,
- "about:robots",
- "Should be the right URL"
- );
- });
- } else {
- let sessionHistory = browser.browsingContext.sessionHistory;
-
- is(sessionHistory.count, 2, "Should be two history entries");
- is(
- sessionHistory.getEntryAtIndex(0).URI.spec,
- "about:blank",
- "Should be the right URL"
- );
- is(
- sessionHistory.getEntryAtIndex(1).URI.spec,
- "about:robots",
- "Should be the right URL"
- );
- }
+
+ sessionHistory = browser.browsingContext.sessionHistory;
+
+ is(sessionHistory.count, 2, "Should be two history entries");
+ is(
+ sessionHistory.getEntryAtIndex(0).URI.spec,
+ "about:blank",
+ "Should be the right URL"
+ );
+ is(
+ sessionHistory.getEntryAtIndex(1).URI.spec,
+ "about:robots",
+ "Should be the right URL"
+ );
// Cleanup.
BrowserTestUtils.removeTab(tab);
diff --git a/browser/components/sessionstore/test/browser_send_async_message_oom.js b/browser/components/sessionstore/test/browser_send_async_message_oom.js
deleted file mode 100644
index 7e807f2fbd..0000000000
--- a/browser/components/sessionstore/test/browser_send_async_message_oom.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-/* eslint-disable mozilla/no-arbitrary-setTimeout */
-
-const HISTOGRAM_NAME = "FX_SESSION_RESTORE_SEND_UPDATE_CAUSED_OOM";
-
-/**
- * Test that an OOM in sendAsyncMessage in a framescript will be reported
- * to Telemetry.
- */
-
-add_setup(async function () {
- Services.telemetry.canRecordExtended = true;
-});
-
-function frameScript() {
- // Make send[A]syncMessage("SessionStore:update", ...) simulate OOM.
- // Other operations are unaffected.
- let mm = docShell.messageManager;
-
- let wrap = function (original) {
- return function (name, ...args) {
- if (name != "SessionStore:update") {
- return original(name, ...args);
- }
- throw new Components.Exception(
- "Simulated OOM",
- Cr.NS_ERROR_OUT_OF_MEMORY
- );
- };
- };
-
- mm.sendAsyncMessage = wrap(mm.sendAsyncMessage.bind(mm));
- mm.sendSyncMessage = wrap(mm.sendSyncMessage.bind(mm));
-}
-
-add_task(async function () {
- // Capture original state.
- let snapshot = Services.telemetry.getHistogramById(HISTOGRAM_NAME).snapshot();
-
- // Open a browser, configure it to cause OOM.
- let newTab = BrowserTestUtils.addTab(gBrowser, "about:robots");
- let browser = newTab.linkedBrowser;
- await ContentTask.spawn(browser, null, frameScript);
-
- let promiseReported = new Promise(resolve => {
- browser.messageManager.addMessageListener("SessionStore:error", resolve);
- });
-
- // Attempt to flush. This should fail.
- let promiseFlushed = TabStateFlusher.flush(browser);
- promiseFlushed.then(success => {
- if (success) {
- throw new Error("Flush should have failed");
- }
- });
-
- // The frame script should report an error.
- await promiseReported;
-
- // Give us some time to handle that error.
- await new Promise(resolve => setTimeout(resolve, 10));
-
- // By now, Telemetry should have been updated.
- let snapshot2 = Services.telemetry
- .getHistogramById(HISTOGRAM_NAME)
- .snapshot();
- gBrowser.removeTab(newTab);
-
- Assert.ok(snapshot2.sum > snapshot.sum);
-});
-
-add_task(async function cleanup() {
- Services.telemetry.canRecordExtended = false;
-});
diff --git a/browser/components/sessionstore/test/browser_sessionHistory.js b/browser/components/sessionstore/test/browser_sessionHistory.js
index ebdf0055e9..a3eb4abd42 100644
--- a/browser/components/sessionstore/test/browser_sessionHistory.js
+++ b/browser/components/sessionstore/test/browser_sessionHistory.js
@@ -296,12 +296,9 @@ add_task(async function test_slow_subframe_load() {
* Ensure that document wireframes can be persisted when they're enabled.
*/
add_task(async function test_wireframes() {
- // Wireframes only works when Fission and SHIP are enabled.
- if (
- !Services.appinfo.fissionAutostart ||
- !Services.appinfo.sessionHistoryInParent
- ) {
- ok(true, "Skipping test_wireframes when Fission or SHIP is not enabled.");
+ // Wireframes only works when Fission is enabled.
+ if (!Services.appinfo.fissionAutostart) {
+ ok(true, "Skipping test_wireframes when Fission is not enabled.");
return;
}
diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js
index d73c098eea..a43a6ac0a2 100644
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -671,35 +671,9 @@ function setPropertyOfFormField(browserContext, selector, propName, newValue) {
}
function promiseOnHistoryReplaceEntry(browser) {
- if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
- return new Promise(resolve => {
- let sessionHistory = browser.browsingContext?.sessionHistory;
- if (sessionHistory) {
- var historyListener = {
- OnHistoryNewEntry() {},
- OnHistoryGotoIndex() {},
- OnHistoryPurge() {},
- OnHistoryReload() {
- return true;
- },
-
- OnHistoryReplaceEntry() {
- resolve();
- },
-
- QueryInterface: ChromeUtils.generateQI([
- "nsISHistoryListener",
- "nsISupportsWeakReference",
- ]),
- };
-
- sessionHistory.addSHistoryListener(historyListener);
- }
- });
- }
-
- return SpecialPowers.spawn(browser, [], () => {
- return new Promise(resolve => {
+ return new Promise(resolve => {
+ let sessionHistory = browser.browsingContext?.sessionHistory;
+ if (sessionHistory) {
var historyListener = {
OnHistoryNewEntry() {},
OnHistoryGotoIndex() {},
@@ -718,13 +692,8 @@ function promiseOnHistoryReplaceEntry(browser) {
]),
};
- var { sessionHistory } = this.docShell.QueryInterface(
- Ci.nsIWebNavigation
- );
- if (sessionHistory) {
- sessionHistory.legacySHistory.addSHistoryListener(historyListener);
- }
- });
+ sessionHistory.addSHistoryListener(historyListener);
+ }
});
}