From 23b546c1a45fa0fd4778d5cbdb53704c22b1ebbd Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Tue, 31 Mar 2015 10:00:00 -0400 Subject: [PATCH] Bug 1121671, see if using the TabSwitchDone event will work, r=test-only=change --- .../tests/browser/browser_waitForFocus.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/testing/mochitest/tests/browser/browser_waitForFocus.js b/testing/mochitest/tests/browser/browser_waitForFocus.js index ab81fa0a00d6..f3162f921d9a 100644 --- a/testing/mochitest/tests/browser/browser_waitForFocus.js +++ b/testing/mochitest/tests/browser/browser_waitForFocus.js @@ -23,11 +23,19 @@ function *promiseTabLoadEvent(tab, url) // Load a new blank tab add_task(function *() { - let tab = gBrowser.addTab(); - gBrowser.selectedTab = tab; + let tab; - let browser = gBrowser.getBrowserForTab(tab); + yield new Promise(resolve => { + gBrowser.addEventListener("TabSwitchDone", function onSwitch() { + gBrowser.removeEventListener("TabSwitchDone", onSwitch); + executeSoon(resolve); + }); + tab = gBrowser.selectedTab = gBrowser.addTab(); + }); + gURLBar.focus(); + + let browser = gBrowser.selectedBrowser; yield SimpleTest.promiseFocus(browser.contentWindowAsCPOW, true); is(document.activeElement, browser, "Browser is focused when about:blank is loaded");