Bug 531227 - Fix window watcher use in browser_bookmarksProperties.js. r=mak
authorDão Gottwald <dao@mozilla.com>
Thu, 26 Nov 2009 12:30:46 +0100
changeset 35247 8ae42c1b8d83dae43bcf78dc53b12577efc9f3c4
parent 35246 77136b3d68fc2d54e269a546682a48c5a0d18b1d
child 35248 12b704972248c52bdf11560d3704549d077f7ded
push id10522
push userdgottwald@mozilla.com
push dateThu, 26 Nov 2009 11:32:41 +0000
treeherdermozilla-central@8ae42c1b8d83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs531227
milestone1.9.3a1pre
Bug 531227 - Fix window watcher use in browser_bookmarksProperties.js. r=mak
browser/components/places/tests/browser/browser_bookmarksProperties.js
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -62,16 +62,19 @@ const ACTION_ADD = 1;
 
 // If action is ACTION_ADD, set type to one of those, to define what do you
 // want to create.
 const TYPE_FOLDER = 0;
 const TYPE_BOOKMARK = 1;
 
 const TEST_URL = "http://www.mozilla.org/";
 
+const DIALOG_URL = "chrome://browser/content/places/bookmarkProperties.xul";
+const DIALOG_URL_MINIMAL_UI = "chrome://browser/content/places/bookmarkProperties2.xul";
+
 var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
          getService(Ci.nsIWindowMediator);
 var win = wm.getMostRecentWindow("navigator:browser");
 var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
          getService(Ci.nsIWindowWatcher);
 
 function add_visit(aURI, aDate) {
   var visitId = PlacesUtils.history
@@ -219,17 +222,18 @@ gTests.push({
 
   run: function() {
     // open tags autocomplete and press enter
     var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
     var self = this;
 
     var windowObserver = {
       observe: function(aSubject, aTopic, aData) {
-        if (aTopic === "domwindowclosed") {
+        if (aTopic === "domwindowclosed" &&
+            aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
           ww.unregisterNotification(this);
           tagsField.popup.removeEventListener("popuphidden", popupListener, true);
           ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
           self.finish();
         }
       }
     };
 
@@ -377,17 +381,18 @@ gTests.push({
 
   run: function() {
     // open tags autocomplete and press enter
     var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
     var self = this;
 
     var windowObserver = {
       observe: function(aSubject, aTopic, aData) {
-        if (aTopic === "domwindowclosed") {
+        if (aTopic === "domwindowclosed" &&
+            aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
           ww.unregisterNotification(this);
           tagsField.popup.removeEventListener("popuphidden", popupListener, true);
           ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
           self.finish();
         }
       }
     };
 
@@ -478,17 +483,18 @@ gTests.push({
   run: function() {
     // Open folder selector.
     var foldersExpander = this.window.document.getElementById("editBMPanel_foldersExpander");
     var folderTree = this.window.document.getElementById("editBMPanel_folderTree");
     var self = this;
 
     var windowObserver = {
       observe: function(aSubject, aTopic, aData) {
-        if (aTopic === "domwindowclosed") {
+        if (aTopic === "domwindowclosed" &&
+            aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
           ww.unregisterNotification(this);
           ok(self._cleanShutdown,
              "Dialog window should not be closed by pressing ESC in folder name textbox");
           self.finish();
         }
       }
     };
     ww.registerNotification(windowObserver);
@@ -538,16 +544,19 @@ function test() {
   runNextTest();
 }
 
 function runNextTest() {
   // Cleanup from previous test.
   if (gCurrentTest) {
     gCurrentTest.cleanup();
     info("End of test: " + gCurrentTest.desc);
+    gCurrentTest = null;
+    executeSoon(runNextTest);
+    return;
   }
 
   if (gTests.length > 0) {
     // Goto next tests.
     gCurrentTest = gTests.shift();
     info("Start of test: " + gCurrentTest.desc);
     gCurrentTest.setup();
     execute_test_in_sidebar();