Backed out changeset 9f9d69a704e1 (bug 1309880) for landing too early a=backout
authorWes Kocher <wkocher@mozilla.com>
Thu, 27 Oct 2016 12:06:36 -0700
changeset 319803 7f3a92667acf1dbed3f12941e01607e8230b29d8
parent 319802 4bf929bdbc4f7bb4a619c41aa849df6a7204e16b
child 319804 55ac24f3f8ff2fd06655b23e7f0f92d1a9ca9211
push id20748
push userphilringnalda@gmail.com
push dateFri, 28 Oct 2016 03:39:55 +0000
treeherderfx-team@715360440695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1309880
milestone52.0a1
backs out9f9d69a704e15b0288e6710b51d97d13748ff7a8
Backed out changeset 9f9d69a704e1 (bug 1309880) for landing too early a=backout
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser.ini
browser/components/sessionstore/test/browser_undoCloseById.js
browser/components/sessionstore/test/head.js
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -334,20 +334,16 @@ this.SessionStore = {
   navigateAndRestore(tab, loadArguments, historyIndex) {
     return SessionStoreInternal.navigateAndRestore(tab, loadArguments, historyIndex);
   },
 
   getSessionHistory(tab, updatedCallback) {
     return SessionStoreInternal.getSessionHistory(tab, updatedCallback);
   },
 
-  undoCloseById(aClosedId) {
-    return SessionStoreInternal.undoCloseById(aClosedId);
-  },
-
   /**
    * Determines whether the passed version number is compatible with
    * the current version number of the SessionStore.
    *
    * @param version The format and version of the file, as an array, e.g.
    * ["sessionrestore", 1]
    */
   isFormatVersionCompatible(version) {
@@ -377,19 +373,16 @@ var SessionStoreInternal = {
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIDOMEventListener,
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference
   ]),
 
   _globalState: new GlobalState(),
 
-  // A counter to be used to generate a unique ID for each closed tab or window.
-  _nextClosedId: 0,
-
   // During the initial restore and setBrowserState calls tracks the number of
   // windows yet to be restored
   _restoreCount: -1,
 
   // For each <browser> element, records the current epoch.
   _browserEpochs: new WeakMap(),
 
   // Any browsers that fires the oop-browser-crashed event gets stored in
@@ -1433,19 +1426,16 @@ var SessionStoreInternal = {
         });
 
         // If we found no tab closed before our
         // tab then just append it to the list.
         if (index == -1) {
           index = this._closedWindows.length;
         }
 
-        // About to save the closed window, add a unique ID.
-        winData.closedId = this._nextClosedId++;
-
         // Insert tabData at the right position.
         this._closedWindows.splice(index, 0, winData);
         this._capClosedWindows();
       } else if (!shouldStore && alreadyStored) {
         this._closedWindows.splice(winIndex, 1);
       }
     }
   },
@@ -1857,19 +1847,16 @@ var SessionStoreInternal = {
     });
 
     // If we found no tab closed before our
     // tab then just append it to the list.
     if (index == -1) {
       index = closedTabs.length;
     }
 
-    // About to save the closed tab, add a unique ID.
-    tabData.closedId = this._nextClosedId++;
-
     // Insert tabData at the right position.
     closedTabs.splice(index, 0, tabData);
 
     // Truncate the list of closed tabs, if needed.
     if (closedTabs.length > this._max_tabs_undo) {
       closedTabs.splice(this._max_tabs_undo, closedTabs.length);
     }
   },
@@ -2406,52 +2393,16 @@ var SessionStoreInternal = {
   },
 
   persistTabAttribute: function ssi_persistTabAttribute(aName) {
     if (TabAttributes.persist(aName)) {
       this.saveStateDelayed();
     }
   },
 
-
-  /**
-   * Undoes the closing of a tab or window which corresponds
-   * to the closedId passed in.
-   *
-   * @param aClosedId
-   *        The closedId of the tab or window
-   *
-   * @returns a tab or window object
-   */
-  undoCloseById(aClosedId) {
-    // Check for a window first.
-    for (let i = 0, l = this._closedWindows.length; i < l; i++) {
-      if (this._closedWindows[i].closedId == aClosedId) {
-        return this.undoCloseWindow(i);
-      }
-    }
-
-    // Check for a tab.
-    let windowsEnum = Services.wm.getEnumerator("navigator:browser");
-    while (windowsEnum.hasMoreElements()) {
-      let window = windowsEnum.getNext();
-      let windowState = this._windows[window.__SSi];
-      if (windowState) {
-        for (let j = 0, l = windowState._closedTabs.length; j < l; j++) {
-          if (windowState._closedTabs[j].closedId == aClosedId) {
-            return this.undoCloseTab(window, j);
-          }
-        }
-      }
-    }
-
-    // Neither a tab nor a window was found, return undefined and let the caller decide what to do about it.
-    return undefined;
-  },
-
   /**
    * Restores the session state stored in LastSession. This will attempt
    * to merge data into the current session. If a window was opened at startup
    * with pinned tab(s), then the remaining data from the previous session for
    * that window will be opened into that window. Otherwise new windows will
    * be opened.
    */
   restoreLastSession: function ssi_restoreLastSession() {
--- a/browser/components/sessionstore/test/browser.ini
+++ b/browser/components/sessionstore/test/browser.ini
@@ -228,10 +228,9 @@ run-if = e10s
 [browser_parentProcessRestoreHash.js]
 run-if = e10s
 [browser_sessionStoreContainer.js]
 [browser_windowStateContainer.js]
 [browser_1234021.js]
 [browser_remoteness_flip_on_restore.js]
 run-if = e10s
 [browser_background_tab_crash.js]
-run-if = e10s && crashreporter
-[browser_undoCloseById.js]
+run-if = e10s && crashreporter
\ No newline at end of file
deleted file mode 100644
--- a/browser/components/sessionstore/test/browser_undoCloseById.js
+++ /dev/null
@@ -1,96 +0,0 @@
-"use strict";
-
-/**
- * This test is for the undoCloseById function.
- */
-
-Cu.import("resource:///modules/sessionstore/SessionStore.jsm");
-
-function openAndCloseTab(window, url) {
-  let tab = window.gBrowser.addTab(url);
-  yield promiseBrowserLoaded(tab.linkedBrowser, true, url);
-  yield TabStateFlusher.flush(tab.linkedBrowser);
-  yield promiseRemoveTab(tab);
-}
-
-function* openWindow(url) {
-  let win = yield promiseNewWindowLoaded();
-  let flags = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
-  win.gBrowser.selectedBrowser.loadURIWithFlags(url, flags);
-  yield promiseBrowserLoaded(win.gBrowser.selectedBrowser, true, url);
-  return win;
-}
-
-add_task(function* test_undoCloseById() {
-  // Clear the lists of closed windows and tabs.
-  forgetClosedWindows();
-  while (SessionStore.getClosedTabCount(window)) {
-    SessionStore.forgetClosedTab(window, 0);
-  }
-
-  // Open a new window.
-  let win = yield openWindow("about:robots");
-
-  // Open and close a tab.
-  yield openAndCloseTab(win, "about:mozilla");
-
-  // Record the first closedId created.
-  let initialClosedId = SessionStore.getClosedTabData(win, false)[0].closedId;
-
-  // Open and close another tab.
-  yield openAndCloseTab(win, "about:robots");  // closedId == initialClosedId + 1
-
-  // Undo closing the second tab.
-  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 + 1);
-  is(notTab, undefined, "Re-opened tab cannot be unClosed again by closedId");
-
-  // 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 + 2
-  yield promiseRemoveTab(tab2); // closedId == initialClosedId + 3
-
-  // Open another new window.
-  let win2 = yield openWindow("about:mozilla");
-
-  // Close both windows.
-  yield BrowserTestUtils.closeWindow(win); // closedId == initialClosedId + 4
-  yield BrowserTestUtils.closeWindow(win2); // closedId == initialClosedId + 5
-
-  // Undo closing the second window.
-  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 + 5);
-  is(notWin, undefined, "Re-opened window cannot be unClosed again by closedId");
-
-  // Close the window again.
-  yield BrowserTestUtils.closeWindow(win);
-
-  // Undo closing the first window.
-  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);
-});
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -278,18 +278,18 @@ var promiseForEachSessionRestoreFile = T
       if (!(ex instanceof OS.File.Error && ex.becauseNoSuchFile)) {
         throw ex;
       }
     }
     cb(data, key);
   }
 });
 
-function promiseBrowserLoaded(aBrowser, ignoreSubFrames = true, wantLoad = null) {
-  return BrowserTestUtils.browserLoaded(aBrowser, !ignoreSubFrames, wantLoad);
+function promiseBrowserLoaded(aBrowser, ignoreSubFrames = true) {
+  return BrowserTestUtils.browserLoaded(aBrowser, !ignoreSubFrames);
 }
 
 function whenWindowLoaded(aWindow, aCallback = next) {
   aWindow.addEventListener("load", function windowLoadListener() {
     aWindow.removeEventListener("load", windowLoadListener, false);
     executeSoon(function executeWhenWindowLoaded() {
       aCallback(aWindow);
     });