Bug 567531 - browser_461634.js test failing on latest trunk. r+ Neil
authorMisak Khachatryan <misak.bugzilla@gmail.com>
Mon, 24 May 2010 10:31:55 +0500
changeset 5728 24fd84018f885e194947b55ed253607b79df3ba3
parent 5727 0ba4ad0584618ff872702a72c04955c3eddf5c7b
child 5729 23551ff0a6af23c6e15817015af594236b6cb8cf
push idunknown
push userunknown
push dateunknown
bugs567531
Bug 567531 - browser_461634.js test failing on latest trunk. r+ Neil
suite/common/tests/browser/browser_461634.js
--- a/suite/common/tests/browser/browser_461634.js
+++ b/suite/common/tests/browser/browser_461634.js
@@ -32,19 +32,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 function browserWindowsCount() {
   let count = 0;
-  let e = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-                    .getService(Components.interfaces.nsIWindowMediator)
-                    .getEnumerator("navigator:browser");
+  let e = Services.wm.getEnumerator("navigator:browser");
   while (e.hasMoreElements()) {
     if (!e.getNext().closed)
       ++count;
   }
   return count;
 }
 
 function test() {
@@ -75,62 +73,50 @@ function test() {
       return false;
     }
     catch (ex) {
       return ex.name == "NS_ERROR_ILLEGAL_VALUE";
     }
   }
 
   // open a window and add the above closed tab list
-  let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
+  let newWin = openDialog(location, "", "chrome,all,dialog=no");
   newWin.addEventListener("load", function(aEvent) {
-    newWin.getBrowser().removeEventListener("load", arguments.callee, false);
     gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
                             test_state.windows[0]._closedTabs.length);
-    //ss.setWindowState(newWin, JSON.stringify(test_state), true);
-    let browser = newWin.getBrowser();
-    let tab1 = browser.addTab("data:text/html,<title>REMEMBER</title>");
-    let tab2 = browser.addTab("data:text/html,<title>FORGET</title>");
-    let tab3 = browser.addTab("data:text/html,<title>REMEMBER</title>");
-    let tab4 = browser.addTab("data:text/html,<title>FORGET</title>");
-    executeSoon(function() {
-     browser.removeTab(tab1);
-     browser.removeTab(tab2);
-     browser.removeTab(tab3);
-     browser.removeTab(tab4);
-     let closedTabs = JSON.parse(ss.getClosedTabData(newWin));
+    ss.setWindowState(newWin, JSON.stringify(test_state), true);
 
-     is(closedTabs.length, test_state.windows[0]._closedTabs.length,
+    let closedTabs = JSON.parse(ss.getClosedTabData(newWin));
+    is(closedTabs.length, test_state.windows[0]._closedTabs.length,
        "Closed tab list has the expected length");
-     is(countByTitle(closedTabs, "FORGET"),
+    is(countByTitle(closedTabs, FORGET),
        test_state.windows[0]._closedTabs.length - remember_count,
        "The correct amout of tabs are to be forgotten");
-     is(countByTitle(closedTabs, "REMEMBER"), remember_count,
+    is(countByTitle(closedTabs, REMEMBER), remember_count,
        "Everything is set up.");
 
-     // all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
-     ok(testForError(function() ss.forgetClosedTab({}, 0)),
+    // all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
+    ok(testForError(function() ss.forgetClosedTab({}, 0)),
        "Invalid window for forgetClosedTab throws");
-     ok(testForError(function() ss.forgetClosedTab(newWin, -1)),
+    ok(testForError(function() ss.forgetClosedTab(newWin, -1)),
        "Invalid tab for forgetClosedTab throws");
-     ok(testForError(function() ss.forgetClosedTab(newWin, test_state.windows[0]._closedTabs.length + 1)),
+    ok(testForError(function() ss.forgetClosedTab(newWin, test_state.windows[0]._closedTabs.length + 1)),
        "Invalid tab for forgetClosedTab throws");
 
-     // Remove third tab, then first tab
-     ss.forgetClosedTab(newWin, 2);
-     ss.forgetClosedTab(newWin, null);
+    // Remove third tab, then first tab
+    ss.forgetClosedTab(newWin, 2);
+    ss.forgetClosedTab(newWin, null);
 
-     closedTabs = JSON.parse(ss.getClosedTabData(newWin));
-     is(closedTabs.length, remember_count,
-	"The correct amout of tabs was removed");
-     is(countByTitle(closedTabs, "FORGET"), 0,
-	"All tabs specifically forgotten were indeed removed");
-     is(countByTitle(closedTabs, "REMEMBER"), remember_count,
-	"... and tabs not specifically forgotten weren't.");
+    closedTabs = JSON.parse(ss.getClosedTabData(newWin));
+    is(closedTabs.length, remember_count,
+       "The correct amout of tabs was removed");
+    is(countByTitle(closedTabs, FORGET), 0,
+       "All tabs specifically forgotten were indeed removed");
+    is(countByTitle(closedTabs, REMEMBER), remember_count,
+       "... and tabs not specifically forgetten weren't.");
  
-     // clean up
-     newWin.close();
-     is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-     gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
-     finish();
-    });
+    // clean up
+    newWin.close();
+    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
+    gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
+    finish();
   }, false);
 }