diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js b/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js index 79eaa96b79ea..58ac1796b727 100644 --- a/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js @@ -19,23 +19,31 @@ function test() { aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); cache.evictEntries(Ci.nsICache.STORE_ANYWHERE); launchStyleEditorChromeFromWindow(aWindow, function(aChrome) { - aChrome.addChromeListener({ - onEditorAdded: function(aChrome, aEditor) { - if (aEditor.isLoaded) { - checkCache(); - } else { - aEditor.addActionListener({ - onLoad: checkCache - }); - } - } - }); + if (aChrome.isContentAttached) { + onEditorAdded(aChrome, aChrome.editors[0]); + } else { + aChrome.addChromeListener({ + onEditorAdded: onEditorAdded + }); + } }); }, true); aWindow.gBrowser.selectedBrowser.loadURI(testURI); } + function onEditorAdded(aChrome, aEditor) { + aChrome.removeChromeListener(this); + + if (aEditor.isLoaded) { + checkCache(); + } else { + aEditor.addActionListener({ + onLoad: checkCache + }); + } + } + function testOnWindow(options, callback) { let win = OpenBrowserWindow(options); win.addEventListener("load", function onLoad() { diff --git a/browser/devtools/styleeditor/test/head.js b/browser/devtools/styleeditor/test/head.js index d08249dca059..20b32276ff10 100644 --- a/browser/devtools/styleeditor/test/head.js +++ b/browser/devtools/styleeditor/test/head.js @@ -29,9 +29,14 @@ function cleanup() function launchStyleEditorChrome(aCallback, aSheet, aLine, aCol) { - let target = TargetFactory.forTab(gBrowser.selectedTab); + launchStyleEditorChromeFromWindow(window, aCallback, aSheet, aLine, aCol); +} - let panel = gDevTools.getPanelForTarget("styleeditor", target); +function launchStyleEditorChromeFromWindow(aWindow, aCallback, aSheet, aLine, aCol) +{ + let target = TargetFactory.forTab(aWindow.gBrowser.selectedTab); + + let panel = aWindow.gDevTools.getPanelForTarget("styleeditor", target); if (panel && panel.isReady) { gChromeWindow = panel._panelWin; gChromeWindow.styleEditorChrome._alwaysDisableAnimations = true; @@ -40,7 +45,7 @@ function launchStyleEditorChrome(aCallback, aSheet, aLine, aCol) } aCallback(gChromeWindow.styleEditorChrome); } else { - let toolbox = gDevTools.openToolboxForTab(target, "styleeditor"); + let toolbox = aWindow.gDevTools.openToolboxForTab(target, "styleeditor"); toolbox.once("styleeditor-ready", function(event, panel) { gChromeWindow = panel._panelWin; gChromeWindow.styleEditorChrome._alwaysDisableAnimations = true; @@ -52,21 +57,6 @@ function launchStyleEditorChrome(aCallback, aSheet, aLine, aCol) } } -function launchStyleEditorChromeFromWindow(aWindow, aCallback, aSheet, aLine, aCol) -{ - gChromeWindow = aWindow.StyleEditor.openChrome(aSheet, aLine, aCol); - if (gChromeWindow.document.readyState != "complete") { - gChromeWindow.addEventListener("load", function onChromeLoad() { - gChromeWindow.removeEventListener("load", onChromeLoad, true); - gChromeWindow.styleEditorChrome._alwaysDisableAnimations = true; - aCallback(gChromeWindow.styleEditorChrome); - }, true); - } else { - gChromeWindow.styleEditorChrome._alwaysDisableAnimations = true; - aCallback(gChromeWindow.styleEditorChrome); - } -} - function addTabAndLaunchStyleEditorChromeWhenLoaded(aCallback, aSheet, aLine, aCol) { gBrowser.selectedTab = gBrowser.addTab();