Bug 1770765 - Session Restore should ignore the Firefox View tab. r=Gijs
authorDão Gottwald <dao@mozilla.com>
Tue, 24 May 2022 13:51:35 +0000
changeset 618746 3b1e18149e1631a55b5c7810b2bd9f47bfa3dcea
parent 618745 5245e3958c34803e8614d92dd3faf9504c2f3759
child 618747 8e090152e950d7f5e78b104da8bc71070c85c6af
push id163387
push userdgottwald@mozilla.com
push dateTue, 24 May 2022 13:54:00 +0000
treeherderautoland@3b1e18149e16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1770765
milestone102.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1770765 - Session Restore should ignore the Firefox View tab. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D147088
browser/components/firefoxview/tests/browser/browser_firefoxview_tab.js
browser/components/sessionstore/SessionStore.jsm
--- a/browser/components/firefoxview/tests/browser/browser_firefoxview_tab.js
+++ b/browser/components/firefoxview/tests/browser/browser_firefoxview_tab.js
@@ -102,8 +102,40 @@ add_task(async function accel_w_behavior
   win.gBrowser.selectedTab = win.gBrowser.visibleTabs[0];
   info(
     "Waiting for Accel+W in the only visible tab to close the window, ignoring the presence of the hidden Firefox View tab"
   );
   let windowClosed = BrowserTestUtils.windowClosed(win);
   EventUtils.synthesizeKey("w", { accelKey: true }, win);
   await windowClosed;
 });
+
+add_task(async function undo_close_tab() {
+  Services.obs.notifyObservers(null, "browser:purge-session-history");
+  is(
+    SessionStore.getClosedTabCount(window),
+    0,
+    "Closed tab count after purging session history"
+  );
+
+  let tab = await BrowserTestUtils.openNewForegroundTab(
+    gBrowser,
+    "about:about"
+  );
+  await TestUtils.waitForTick();
+  gBrowser.removeTab(tab);
+  await TestUtils.waitForTick();
+  is(
+    SessionStore.getClosedTabCount(window),
+    1,
+    "Closing about:about added to the closed tab count"
+  );
+
+  await openFirefoxViewTab();
+  await TestUtils.waitForTick();
+  closeFirefoxViewTab();
+  await TestUtils.waitForTick();
+  is(
+    SessionStore.getClosedTabCount(window),
+    1,
+    "Closing the Firefox View tab did not add to the closed tab count"
+  );
+});
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2529,16 +2529,19 @@ var SessionStoreInternal = {
    *        Tab state.
    */
   maybeSaveClosedTab(aWindow, aTab, tabState) {
     // Don't save private tabs
     let isPrivateWindow = PrivateBrowsingUtils.isWindowPrivate(aWindow);
     if (!isPrivateWindow && tabState.isPrivate) {
       return;
     }
+    if (aTab == aWindow.gFirefoxViewTab) {
+      return;
+    }
 
     let permanentKey = aTab.linkedBrowser.permanentKey;
 
     let tabData = {
       permanentKey,
       state: tabState,
       title: aTab.label,
       image: aWindow.gBrowser.getIcon(aTab),
@@ -4109,16 +4112,19 @@ var SessionStoreInternal = {
 
     let tabbrowser = aWindow.gBrowser;
     let tabs = tabbrowser.tabs;
     let winData = this._windows[aWindow.__SSi];
     let tabsData = (winData.tabs = []);
 
     // update the internal state data for this window
     for (let tab of tabs) {
+      if (tab == aWindow.gFirefoxViewTab) {
+        continue;
+      }
       let tabData = TabState.collect(tab, TAB_CUSTOM_VALUES.get(tab));
       tabMap.set(tab, tabData);
       tabsData.push(tabData);
     }
     winData.selected = tabbrowser.tabbox.selectedIndex + 1;
 
     this._updateWindowFeatures(aWindow);