Bug 467209: make browser_customize test more robust on CLOSED TREE, patch by Justin Wood <bugspam.Callek@gmail.com>, r=me
--- 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();