Backed out changeset 4537bb4cfb82 (bug 1312571) to back out what it depends on
authorPhil Ringnalda <philringnalda@gmail.com>
Sat, 29 Oct 2016 00:16:01 -0700
changeset 320106 75db19443bc054c4babd9567f837c2618947cc6c
parent 320105 8b1ef926af1c77f31dd32f5112e04b9a00a098d1
child 320107 3c1eddbe382f29d7f377426cf95756563a764b29
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1312571
milestone52.0a1
backs out4537bb4cfb82972e3c88b73e1b7c48e98e667348
Backed out changeset 4537bb4cfb82 (bug 1312571) to back out what it depends on
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_undoCloseById.js
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -206,20 +206,16 @@ this.SessionStore = {
   get canRestoreLastSession() {
     return SessionStoreInternal.canRestoreLastSession;
   },
 
   set canRestoreLastSession(val) {
     SessionStoreInternal.canRestoreLastSession = val;
   },
 
-  get lastClosedObjectType() {
-    return SessionStoreInternal.lastClosedObjectType;
-  },
-
   init: function ss_init() {
     SessionStoreInternal.init();
   },
 
   getBrowserState: function ss_getBrowserState() {
     return SessionStoreInternal.getBrowserState();
   },
 
@@ -503,43 +499,16 @@ var SessionStoreInternal = {
   set canRestoreLastSession(val) {
     // Cheat a bit; only allow false.
     if (!val) {
       LastSession.clear();
     }
   },
 
   /**
-   * Returns a string describing the last closed object, either "tab" or "window".
-   *
-   * This was added to support the sessions.restore WebExtensions API.
-   */
-  get lastClosedObjectType() {
-    if (this._closedWindows.length) {
-      // Since there are closed windows, we need to check if there's a closed tab
-      // in one of the currently open windows that was closed after the
-      // last-closed window.
-      let tabTimestamps = [];
-      let windowsEnum = Services.wm.getEnumerator("navigator:browser");
-      while (windowsEnum.hasMoreElements()) {
-        let window = windowsEnum.getNext();
-        let windowState = this._windows[window.__SSi];
-        if (windowState && windowState._closedTabs[0]) {
-          tabTimestamps.push(windowState._closedTabs[0].closedAt);
-        }
-      }
-      if (!tabTimestamps.length ||
-          (tabTimestamps.sort((a, b) => b - a)[0] < this._closedWindows[0].closedAt)) {
-        return "window";
-      }
-    }
-    return "tab";
-  },
-
-  /**
    * Initialize the sessionstore service.
    */
   init: function () {
     if (this._initialized) {
       throw new Error("SessionStore.init() must only be called once!");
     }
 
     TelemetryTimestamps.add("sessionRestoreInitialized");
--- a/browser/components/sessionstore/test/browser_undoCloseById.js
+++ b/browser/components/sessionstore/test/browser_undoCloseById.js
@@ -31,85 +31,69 @@ add_task(function* test_undoCloseById() 
     SessionStore.forgetClosedTab(window, 0);
   }
 
   // Open a new window.
   let win = yield openWindow("about:robots");
 
   // Open and close a tab.
   yield openAndCloseTab(win, "about:mozilla");
-  is(SessionStore.lastClosedObjectType, "tab", "The last closed object is a tab");
 
   // Record the first closedId created.
   let initialClosedId = SessionStore.getClosedTabData(win, false)[0].closedId;
 
-  // Open and close another window.
-  let win2 = yield openWindow("about:mozilla");
-  yield BrowserTestUtils.closeWindow(win2);  // closedId == initialClosedId + 1
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
-
-  // Open and close another tab in the first window.
-  yield openAndCloseTab(win, "about:robots");  // closedId == initialClosedId + 2
-  is(SessionStore.lastClosedObjectType, "tab", "The last closed object is a tab");
+  // Open and close another tab.
+  yield openAndCloseTab(win, "about:robots");  // closedId == initialClosedId + 1
 
   // Undo closing the second tab.
-  let tab = SessionStore.undoCloseById(initialClosedId + 2);
+  let tab = SessionStore.undoCloseById(initialClosedId + 1);
   yield promiseBrowserLoaded(tab.linkedBrowser);
   is(tab.linkedBrowser.currentURI.spec, "about:robots", "The expected tab was re-opened");
 
-  let notTab = SessionStore.undoCloseById(initialClosedId + 2);
+  let notTab = SessionStore.undoCloseById(initialClosedId + 1);
   is(notTab, undefined, "Re-opened tab cannot be unClosed again by closedId");
 
-  // Now the last closed object should be a window again.
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
-
   // Undo closing the first tab.
   let tab2 = SessionStore.undoCloseById(initialClosedId);
   yield promiseBrowserLoaded(tab2.linkedBrowser);
   is(tab2.linkedBrowser.currentURI.spec, "about:mozilla", "The expected tab was re-opened");
 
   // Close the two tabs we re-opened.
-  yield promiseRemoveTab(tab); // closedId == initialClosedId + 3
-  is(SessionStore.lastClosedObjectType, "tab", "The last closed object is a tab");
-  yield promiseRemoveTab(tab2); // closedId == initialClosedId + 4
-  is(SessionStore.lastClosedObjectType, "tab", "The last closed object is a tab");
+  yield promiseRemoveTab(tab); // closedId == initialClosedId + 2
+  yield promiseRemoveTab(tab2); // closedId == initialClosedId + 3
 
   // Open another new window.
-  let win3 = yield openWindow("about:mozilla");
+  let win2 = yield openWindow("about:mozilla");
 
   // Close both windows.
-  yield BrowserTestUtils.closeWindow(win); // closedId == initialClosedId + 5
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
-  yield BrowserTestUtils.closeWindow(win3); // closedId == initialClosedId + 6
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
+  yield BrowserTestUtils.closeWindow(win); // closedId == initialClosedId + 4
+  yield BrowserTestUtils.closeWindow(win2); // closedId == initialClosedId + 5
 
   // Undo closing the second window.
-  win = SessionStore.undoCloseById(initialClosedId + 6);
+  win = SessionStore.undoCloseById(initialClosedId + 5);
   yield BrowserTestUtils.waitForEvent(win, "load");
 
   // Make sure we wait until this window is restored.
   yield BrowserTestUtils.waitForEvent(win.gBrowser.tabContainer,
                                       "SSTabRestored");
 
   is(win.gBrowser.selectedBrowser.currentURI.spec, "about:mozilla", "The expected window was re-opened");
 
-  let notWin = SessionStore.undoCloseById(initialClosedId + 6);
+  let notWin = SessionStore.undoCloseById(initialClosedId + 5);
   is(notWin, undefined, "Re-opened window cannot be unClosed again by closedId");
 
   // Close the window again.
   yield BrowserTestUtils.closeWindow(win);
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
 
   // Undo closing the first window.
-  win = SessionStore.undoCloseById(initialClosedId + 5);
+  win = SessionStore.undoCloseById(initialClosedId + 4);
 
   yield BrowserTestUtils.waitForEvent(win, "load");
 
   // Make sure we wait until this window is restored.
   yield BrowserTestUtils.waitForEvent(win.gBrowser.tabContainer,
                                       "SSTabRestored");
 
   is(win.gBrowser.selectedBrowser.currentURI.spec, "about:robots", "The expected window was re-opened");
 
   // Close the window again.
   yield BrowserTestUtils.closeWindow(win);
-  is(SessionStore.lastClosedObjectType, "window", "The last closed object is a window");
 });