Bug 726521. (Av1) Port bug 658738 comment 17 (Add missing removeEventListener() calls), Fix a mismatch in browser_394759.js. r=neil.
authorSerge Gautherie <sgautherie.bz@free.fr>
Wed, 15 Feb 2012 21:19:20 +0100
changeset 10847 074ad890780f64b4e3517cc6360f28e682df9af5
parent 10846 c428aa3c9d71c463e74531c591abaf182de583be
child 10848 1b09b680267803b2cc8fbaa842371a779c7096b5
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs726521, 658738
Bug 726521. (Av1) Port bug 658738 comment 17 (Add missing removeEventListener() calls), Fix a mismatch in browser_394759.js. r=neil.
suite/browser/test/browser/browser_bug562649.js
suite/browser/test/browser/browser_page_style_menu.js
suite/common/tests/browser/browser_394759.js
suite/common/tests/browser/browser_528776.js
suite/common/tests/browser/browser_615394-SSWindowState_events.js
--- a/suite/browser/test/browser/browser_bug562649.js
+++ b/suite/browser/test/browser/browser_bug562649.js
@@ -9,15 +9,18 @@ function test() {
   is(gURLBar.value, URI, "location bar value matches test URI");
 
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.removeCurrentTab();
   is(gBrowser.userTypedValue, URI, "userTypedValue matches test URI after switching tabs");
   is(gURLBar.value, URI, "location bar value matches test URI after switching tabs");
 
   waitForExplicitFinish();
-  gBrowser.selectedBrowser.addEventListener("load", function () {
+  gBrowser.selectedBrowser.addEventListener("load", function loadListener() {
+    gBrowser.selectedBrowser.removeEventListener("load", loadListener, true);
+
     is(gBrowser.userTypedValue, null, "userTypedValue is null as the page has loaded");
     is(gURLBar.value, URI, "location bar value matches test URI as the page has loaded");
+
     gBrowser.removeCurrentTab();
     finish();
   }, true);
 }
--- a/suite/browser/test/browser/browser_page_style_menu.js
+++ b/suite/browser/test/browser/browser_page_style_menu.js
@@ -1,14 +1,17 @@
 function test() {
   waitForExplicitFinish();
 
   var tab = gBrowser.addTab();
   gBrowser.selectedTab = tab;
-  tab.linkedBrowser.addEventListener("load", checkPageStyleMenu, true);
+  tab.linkedBrowser.addEventListener("load", function loadListener() {
+    tab.linkedBrowser.removeEventListener("load", loadListener, true);
+    checkPageStyleMenu();
+  }, true);
   let rootDir = getRootDirectory(gTestPath);
   content.location = rootDir + "page_style_sample.html";
 }
 
 function checkPageStyleMenu() {
   var menupopup = document.getElementById("menu_UseStyleSheet")
                           .getElementsByTagName("menupopup")[0];
   stylesheetFillPopup(menupopup);
--- a/suite/common/tests/browser/browser_394759.js
+++ b/suite/common/tests/browser/browser_394759.js
@@ -63,18 +63,19 @@ function test() {
     // make sure that the next closed window will increase getClosedWindowCount
     let max_windows_undo = Services.prefs.getIntPref("browser.sessionstore.max_windows_undo");
     Services.prefs.setIntPref("browser.sessionstore.max_windows_undo", max_windows_undo + 1);
     let closedWindowCount = ss.getClosedWindowCount();
 
     let newWin = openDialog(location, "", "chrome,all,dialog=no", testURL);
     newWin.addEventListener("load", function loadListener1(aEvent) {
       newWin.removeEventListener("load", loadListener1, false);
+
       newWin.getBrowser().selectedBrowser.addEventListener("load", function loadListener2(aEvent) {
-        newWin.getBrowser().selectedBrowser.removeEventListener("load", loadListener2, false);
+        newWin.getBrowser().selectedBrowser.removeEventListener("load", loadListener2, true);
 
         executeSoon(function() {
           newWin.getBrowser().addTab().linkedBrowser.stop();
           executeSoon(function() {
             // mark the window with some unique data to be restored later on
             ss.setWindowValue(newWin, uniqueKey, uniqueValue);
             let textbox = newWin.content.document.getElementById("textbox");
             textbox.value = uniqueText;
@@ -95,16 +96,17 @@ function test() {
             is(ss.getClosedWindowCount(), closedWindowCount,
                "The reopened window was removed from Recently Closed Windows");
 
             // SSTabRestored will fire more than once, so we need to make sure we count them
             let restoredTabs = 0;
             let expectedTabs = data.tabs.length;
             newWin2.addEventListener("load", function loadListener3(aEvent) {
               newWin2.removeEventListener("load", loadListener3, false);
+
               newWin2.getBrowser().tabContainer.addEventListener("SSTabRestored", function sstabrestoredListener4(aEvent) {
                 if (++restoredTabs < expectedTabs)
                   return;
 
                 newWin2.getBrowser().tabContainer.removeEventListener("SSTabRestored", sstabrestoredListener4, true);
 
                 is(newWin2.getBrowser().tabs.length, 2,
                    "The window correctly restored 2 tabs");
@@ -154,32 +156,33 @@ function test() {
       }
       // hack to force window to be considered a popup (toolbar=no didn't work)
       let winData = windowsToOpen.shift();
       let settings = "chrome,dialog=no," +
                      (winData.isPopup ? "all=no" : "all");
       let url = "http://window" + windowsToOpen.length + ".example.com";
       let window = openDialog(location, "_blank", settings, url);
       window.addEventListener("load", function loadListener5(aEvent) {
-        window.removeEventListener("load", loadListener5, true);
+        window.removeEventListener("load", loadListener5, false);
+
         window.gBrowser.addEventListener("load", function loadListener6(aEvent) {
           window.gBrowser.removeEventListener("load", loadListener6, true);
           // the window _should_ have state with a tab of url, but it doesn't
           // always happend before window.close(). addTab ensure we don't treat
           // this window as a stateless window
           window.gBrowser.addTab();
 
           executeSoon(function() {
             window.close();
             executeSoon(function() {
               openWindowRec(windowsToOpen, expectedResults, recCallback);
             });
           });
         }, true);
-      }, true);
+      }, false);
     }
 
     let windowsToOpen = [{isPopup: false},
                          {isPopup: false},
                          {isPopup: true},
                          {isPopup: true},
                          {isPopup: true}];
     let expectedResults = {mac: {popup: 3, normal: 0},
--- a/suite/common/tests/browser/browser_528776.js
+++ b/suite/common/tests/browser/browser_528776.js
@@ -14,15 +14,16 @@ function browserWindowsCount(expected) {
 function test() {
   /** Test for Bug 528776, ported by Bug 548228 **/
 
   waitForExplicitFinish();
 
   browserWindowsCount(1);
 
   var win = openDialog(location, "", "chrome,all,dialog=no");
-  win.addEventListener("load", function(aEvent) {
+  win.addEventListener("load", function loadListener() {
+    win.removeEventListener("load", loadListener, false);
     browserWindowsCount(2);
     win.close();
     browserWindowsCount(1);
     finish();
   }, false);
 }
--- a/suite/common/tests/browser/browser_615394-SSWindowState_events.js
+++ b/suite/common/tests/browser/browser_615394-SSWindowState_events.js
@@ -281,22 +281,22 @@ function test_setWindowState() {
 
   ss.setWindowState(window, JSON.stringify(testState), true);
 }
 
 
 function test_setBrowserState() {
   // We'll track events per window so we are sure that they are each happening once
   // pre window.
-  let newWindow;
   let windowEvents = {};
   windowEvents[getOuterWindowID(window)] = { busyEventCount: 0, readyEventCount: 0 };
 
   // waitForBrowserState does it's own observing for windows, but doesn't attach
   // the listeners we want here, so do it ourselves.
+  let newWindow;
   function windowObserver(aSubject, aTopic, aData) {
     if (aTopic == "domwindowopened") {
       newWindow = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow);
       newWindow.addEventListener("load", function() {
         newWindow.removeEventListener("load", arguments.callee, false);
 
         Services.ww.unregisterNotification(windowObserver);
 
@@ -388,9 +388,8 @@ function test_undoCloseWindow() {
     reopenedWindow.removeEventListener("SSWindowStateReady", onSSWindowStateReady, false);
     reopenedWindow.gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored, false);
 
     reopenedWindow.close();
 
     runNextTest();
   }
 }
-