Bug 467209: make browser_customize test more robust on CLOSED TREE, patch by Justin Wood <bugspam.Callek@gmail.com>, r=me
authorGavin Sharp <gavin@mozilla.com>
Mon, 01 Dec 2008 23:45:49 -0500
changeset 22142 501f6484deca54807a1c870a69e4630e16e09973
parent 22141 8170fbbdb42686f5bf32d5995507ef56208dcaa7
child 22144 05bef05a0e2738831ac09aa314a025adb7935f17
push id3822
push usergsharp@mozilla.com
push dateTue, 02 Dec 2008 04:46:27 +0000
treeherdermozilla-central@501f6484deca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs467209
milestone1.9.2a1pre
Bug 467209: make browser_customize test more robust on CLOSED TREE, patch by Justin Wood <bugspam.Callek@gmail.com>, r=me
browser/base/content/test/browser_customize.js
--- a/browser/base/content/test/browser_customize.js
+++ b/browser/base/content/test/browser_customize.js
@@ -1,30 +1,32 @@
 function test()
 {
   waitForExplicitFinish();
-  var panel = document.getElementById("customizeToolbarSheetPopup");
-  panel.addEventListener("popupshown", testCustomizePopupShown, false);
+  var frame = document.getElementById("customizeToolbarSheetIFrame");
+  frame.addEventListener("load", testCustomizeFrameLoadedPre, true);
+
   document.getElementById("cmd_CustomizeToolbars").doCommand();
 }
 
-function testCustomizePopupShown()
-{
-  var panel = document.getElementById("customizeToolbarSheetPopup");
-  panel.removeEventListener("popupshown", testCustomizePopupShown, false);
-  panel.addEventListener("popuphidden", testCustomizePopupHidden, false);
-
-  var frame = document.getElementById("customizeToolbarSheetIFrame").contentDocument;
-  frame.addEventListener("load", testCustomizeFrameLoaded, true);
+function testCustomizeFrameLoadedPre(){
+  // This load listener can be called before
+  // customizeToolbarSheet.xul's, which would cause the test
+  // to fail. Use executeSoon to delay running the test until
+  // event dispatch is over (all load event listeners have run).
+  executeSoon(testCustomizeFrameLoaded);
 }
 
 function testCustomizeFrameLoaded()
 {
+  var panel = document.getElementById("customizeToolbarSheetPopup");
+  panel.addEventListener("popuphidden", testCustomizePopupHidden, false);
+
   var frame = document.getElementById("customizeToolbarSheetIFrame");
-  frame.removeEventListener("load", testCustomizeFrameLoaded, true);
+  frame.removeEventListener("load", testCustomizeFrameLoadedPre, true);
 
   var menu = document.getElementById("bookmarksMenuPopup");
   ok("getResult" in menu, "menu has binding");
 
   var framedoc = document.getElementById("customizeToolbarSheetIFrame").contentDocument;
   var b = framedoc.getElementById("donebutton");
 
   framedoc.getElementById("donebutton").doCommand();