diff --git a/browser/components/sessionstore/test/browser/browser_526613.js b/browser/components/sessionstore/test/browser/browser_526613.js index ab3efbe97af..d4c0bd506a9 100644 --- a/browser/components/sessionstore/test/browser/browser_526613.js +++ b/browser/components/sessionstore/test/browser/browser_526613.js @@ -82,11 +82,16 @@ function test() { if (this.pass++ == 1) { is(browserWindowsCount(), 2, "Two windows should exist at this point"); - // executeSoon is needed here in order to let the first window be focused - // (see above) - executeSoon(function() { + // let the first window be focused (see above) + var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); + if (window == fm.activeWindow) { ss.setBrowserState(oldState); - }); + } else { + window.addEventListener("activate", function () { + window.removeEventListener("activate", arguments.callee, false); + ss.setBrowserState(oldState); + }, false); + } } else { is(browserWindowsCount(), 1, "Only one window should exist after cleanup");