Backed out changeset 6d880e4979bb (bug 947570) for mochitest-bc bustage. a=test-only
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 13 Dec 2013 11:54:37 -0500
changeset 167690 68b9b190c22b08b0115e046ca2ec395b4f2fec8c
parent 167689 6d880e4979bb431ce3151a086f9a31b476c4109c
child 167691 d70f382c7a59de9465d2832daf7e2c3a78875ccf
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs947570
milestone27.0
backs out6d880e4979bb431ce3151a086f9a31b476c4109c
Backed out changeset 6d880e4979bb (bug 947570) for mochitest-bc bustage. a=test-only DONTBUILD
browser/components/sessionstore/test/browser_597071.js
browser/components/sessionstore/test/head.js
--- a/browser/components/sessionstore/test/browser_597071.js
+++ b/browser/components/sessionstore/test/browser_597071.js
@@ -1,38 +1,53 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function test() {
+  /** Test for Bug 597071 **/
+
+  waitForExplicitFinish();
 
-/**
- * Bug 597071 - Closed windows should only be resurrected when there is a single
- * popup window
- */
-add_task(function test_close_last_nonpopup_window() {
-  // Purge the list of closed windows.
-  while (ss.getClosedWindowCount()) {
-    ss.forgetClosedWindow(0);
-  }
+  // set the pref to 1 greater than it currently is so we have room for an extra
+  // closed window
+  let closedWindowCount = ss.getClosedWindowCount();
+  Services.prefs.setIntPref("browser.sessionstore.max_windows_undo",
+                            closedWindowCount + 1);
 
-  let oldState = ss.getWindowState(window);
+  let currentState = ss.getBrowserState();
+  let popupState = { windows:[
+    { tabs:[ {entries:[] }], isPopup: true, hidden: "toolbar" }
+  ] };
 
-  let popupState = {windows: [
-    {tabs: [{entries: []}], isPopup: true, hidden: "toolbar"}
-  ]};
-
-  // Set this window to be a popup.
+  // set this window to be a popup.
   ss.setWindowState(window, JSON.stringify(popupState), true);
 
-  // Open a new window with a tab.
-  let win = yield promiseNewWindowLoaded({private: false});
-  let tab = win.gBrowser.addTab("http://example.com/");
-  yield promiseBrowserLoaded(tab.linkedBrowser);
+  // open a new non-popup window
+  let newWin = openDialog(location, "", "chrome,all,dialog=no", "http://example.com");
+  newWin.addEventListener("load", function(aEvent) {
+    newWin.removeEventListener("load", arguments.callee, false);
+
+    newWin.gBrowser.addEventListener("load", function(aEvent) {
+      newWin.gBrowser.removeEventListener("load", arguments.callee, true);
+
+      newWin.gBrowser.addTab().linkedBrowser.stop();
+
+      // make sure sessionstore sees this window
+      let state = JSON.parse(ss.getBrowserState());
+      is(state.windows.length, 2, "sessionstore knows about this window");
 
-  // Make sure sessionstore sees this window.
-  let state = JSON.parse(ss.getBrowserState());
-  is(state.windows.length, 2, "sessionstore knows about this window");
+      newWin.close();
+      newWin.addEventListener("unload", function(aEvent) {
+        newWin.removeEventListener("unload", arguments.callee, false);
+
+        is(ss.getClosedWindowCount(), closedWindowCount + 1,
+           "increased closed window count");
 
-  // Closed the window and check the closed window count.
-  yield promiseWindowClosed(win);
-  is(ss.getClosedWindowCount(), 1, "correct closed window count");
+        Services.prefs.clearUserPref("browser.sessionstore.max_windows_undo");
+        ss.setBrowserState(currentState);
+        executeSoon(finish);
 
-  // Cleanup.
-  ss.setWindowState(window, oldState, true);
-});
+      }, false);
+    }, true);
+  }, false);
+}
+
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -388,41 +388,18 @@ function closeAllButPrimaryWindow() {
  * further if parts of the window's initialization process take more time than
  * expected (e.g. reading a big session state from disk).
  */
 function whenNewWindowLoaded(aOptions, aCallback) {
   let win = OpenBrowserWindow(aOptions);
   whenDelayedStartupFinished(win, () => aCallback(win));
   return win;
 }
-function promiseNewWindowLoaded(aOptions) {
-  let deferred = Promise.defer();
-  whenNewWindowLoaded(aOptions, deferred.resolve);
-  return deferred.promise;
-}
 
 /**
- * Chrome windows aren't closed synchronously. Provide a helper method to close
- * a window and wait until we received the "domwindowclosed" notification for it.
- */
-function promiseWindowClosed(win) {
-  let deferred = Promise.defer();
-
-  Services.obs.addObserver(function obs(subject, topic) {
-    if (subject == win) {
-      Services.obs.removeObserver(obs, topic);
-      deferred.resolve();
-    }
-  }, "domwindowclosed", false);
-
-  win.close();
-  return deferred.promise;
-}
-
-+/**
  * This waits for the browser-delayed-startup-finished notification of a given
  * window. It indicates that the windows has loaded completely and is ready to
  * be used for testing.
  */
 function whenDelayedStartupFinished(aWindow, aCallback) {
   Services.obs.addObserver(function observer(aSubject, aTopic) {
     if (aWindow == aSubject) {
       Services.obs.removeObserver(observer, aTopic);