improve browser_354894.js output
authorDão Gottwald <dao@mozilla.com>
Sun, 13 Dec 2009 21:46:15 +0100
changeset 35682 355d9819adba7ba8dce9cf015a1d9ae42cba70b1
parent 35681 a619c3d07cddd361aa39e5231c4dbdbf6f98168f
child 35683 296f74e81dcab9c8d3b64b6892d5236baa7b6b9b
push id10678
push userdgottwald@mozilla.com
push dateSun, 13 Dec 2009 20:50:06 +0000
treeherdermozilla-central@296f74e81dca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.3a1pre
improve browser_354894.js output
browser/components/sessionstore/test/browser/browser_354894.js
dom/tests/browser/browser_focus_steal_from_chrome.js
--- a/browser/components/sessionstore/test/browser/browser_354894.js
+++ b/browser/components/sessionstore/test/browser/browser_354894.js
@@ -100,30 +100,35 @@
  * not enabled on that platform (platform shim; the application is kept running
  * although there are no windows left)
  * @note There is a difference when closing a browser window with
  * BrowserTryToCloseWindow() as opposed to close(). The former will make
  * nsSessionStore restore a window next time it gets a chance and will post
  * notifications. The latter won't.
  */
 
-function browserWindowsCount() {
+function browserWindowsCount(expected, msg) {
   let count = 0;
   let e = Cc["@mozilla.org/appshell/window-mediator;1"]
             .getService(Ci.nsIWindowMediator)
             .getEnumerator("navigator:browser");
   while (e.hasMoreElements()) {
     if (!e.getNext().closed)
       ++count;
   }
-  return count;
+  is(count, expected, msg + " (nsIWindowMediator)");
+  let state = Cc["@mozilla.org/browser/sessionstore;1"]
+                .getService(Ci.nsISessionStore)
+                .getBrowserState();
+  info(state);
+  is(JSON.parse(state).windows.length, expected, msg + " (getBrowserState)");
 }
 
 function test() {
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
+  browserWindowsCount(1, "Only one browser window should be open initially");
 
   waitForExplicitFinish();
 
   // Some urls that might be opened in tabs and/or popups
   // Do not use about:blank:
   // That one is reserved for special purposes in the tests
   const TEST_URLS = ["about:mozilla", "about:buildconfig"];
 
@@ -506,39 +511,35 @@ function test() {
     });
   }
 
   // Execution starts here
 
   setupTestsuite();
   if (navigator.platform.match(/Mac/)) {
     // Mac tests
-    testMacNotifications(
-      function() testNotificationCount(
-        function() {
-          cleanupTestsuite();
-          is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-          finish();
-        }
-      )
-    );
+    testMacNotifications(function () {
+      testNotificationCount(function () {
+        cleanupTestsuite();
+        browserWindowsCount(1, "Only one browser window should be open eventually");
+        finish();
+      });
+    });
   }
   else {
     // Non-Mac Tests
-    testOpenCloseNormal(
-      function() testOpenClosePrivateBrowsing(
-        function() testOpenCloseWindowAndPopup(
-          function() testOpenCloseOnlyPopup(
-            function() testOpenCloseRestoreFromPopup (
-              function() testNotificationCount(
-                function() {
-                  cleanupTestsuite();
-                  is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-                  finish();
-                }
-              )
-            )
-          )
-        )
-      )
-    );
+    testOpenCloseNormal(function () {
+      testOpenClosePrivateBrowsing(function () {
+        testOpenCloseWindowAndPopup(function () {
+          testOpenCloseOnlyPopup(function () {
+            testOpenCloseRestoreFromPopup (function () {
+              testNotificationCount(function () {
+                cleanupTestsuite();
+                browserWindowsCount(1, "Only one browser window should be open eventually");
+                finish();
+              });
+            });
+          });
+        });
+      });
+    });
   }
 }
--- a/dom/tests/browser/browser_focus_steal_from_chrome.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome.js
@@ -161,9 +161,9 @@ function test() {
           "the " + testingList[testingIndex].tagName +
           " element is focused by the " + testingList[testingIndex].methodName +
           " (Test2: content can NOT steal focus)");
 
     runNextTest();
   }
 
   runNextTest();
-}
\ No newline at end of file
+}