Bug 1318583: Part 4 - Ensure the correct browser window is focused for tests that require it. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Tue, 29 Nov 2016 16:58:16 -0800
changeset 324775 c258d5040f12098bfcc9c69a5215e14ffdcd79d6
parent 324774 2bd028b1ed5f8ce717bb620a0ca7a1e4f6be6670
child 324776 fd396493d0409b1f35890c7047188deca5df13fb
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersaswan
bugs1318583
milestone53.0a1
Bug 1318583: Part 4 - Ensure the correct browser window is focused for tests that require it. r=aswan MozReview-Commit-ID: ETAY8gLOrsU
browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
browser/components/extensions/test/browser/browser_ext_commands_execute_browser_action.js
browser/components/extensions/test/browser/browser_ext_omnibox.js
browser/components/extensions/test/browser/browser_ext_webNavigation_urlbar_transitions.js
browser/components/extensions/test/browser/browser_ext_windows_events.js
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
@@ -293,12 +293,14 @@ add_task(function* testBrowserActionMenu
 
     if (win.screenX == left && win.screenY == top) {
       break;
     }
 
     yield delay(100);
   }
 
+  yield SimpleTest.promiseFocus(win);
+
   yield testPopupSize(true, win, "bottom");
 
   yield BrowserTestUtils.closeWindow(win);
 });
--- a/browser/components/extensions/test/browser/browser_ext_commands_execute_browser_action.js
+++ b/browser/components/extensions/test/browser/browser_ext_commands_execute_browser_action.js
@@ -68,16 +68,18 @@ function* testExecuteBrowserActionWithOp
   let extension = ExtensionTestUtils.loadExtension(extensionOptions);
 
   extension.onMessage("send-keys", () => {
     EventUtils.synthesizeKey("j", {altKey: true, shiftKey: true});
   });
 
   yield extension.startup();
 
+  yield SimpleTest.promiseFocus(window);
+
   if (options.inArea) {
     let widget = getBrowserActionWidget(extension);
     CustomizableUI.addWidgetToArea(widget.id, options.inArea);
   }
 
   extension.sendMessage("withPopup", options.withPopup);
 
   if (options.withPopup) {
--- a/browser/components/extensions/test/browser/browser_ext_omnibox.js
+++ b/browser/components/extensions/test/browser/browser_ext_omnibox.js
@@ -217,16 +217,18 @@ add_task(function* () {
       text,
       disposition: "currentTab",
     });
   }
 
   yield setup();
   yield extension.startup();
 
+  yield SimpleTest.promiseFocus(window);
+
   yield testInputEvents();
 
   // Test the heuristic result with default suggestions.
   yield testHeuristicResult("Generated extension", false /* setDefaultSuggestion */);
   yield testHeuristicResult("hello world", true /* setDefaultSuggestion */);
   yield testHeuristicResult("foo bar", true /* setDefaultSuggestion */);
 
   let suggestions = [
--- a/browser/components/extensions/test/browser/browser_ext_webNavigation_urlbar_transitions.js
+++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_urlbar_transitions.js
@@ -100,16 +100,17 @@ add_task(function* test_webnavigation_ur
   let extension = ExtensionTestUtils.loadExtension({
     background: backgroundScript,
     manifest: {
       permissions: ["webNavigation"],
     },
   });
 
   yield extension.startup();
+  yield SimpleTest.promiseFocus(window);
 
   yield extension.awaitMessage("ready");
 
   gURLBar.focus();
   gURLBar.textValue = "http://example.com/?q=typed";
 
   EventUtils.synthesizeKey("VK_RETURN", {altKey: true});
 
@@ -145,16 +146,17 @@ add_task(function* test_webnavigation_ur
   });
 
   yield addBookmark({
     title: "Bookmark To Click",
     url: "http://example.com/?q=bookmark",
   });
 
   yield extension.startup();
+  yield SimpleTest.promiseFocus(window);
 
   yield extension.awaitMessage("ready");
 
   yield promiseAutocompleteResultPopup("Bookmark To Click");
 
   let item = gURLBar.popup.richlistbox.getItemAtIndex(1);
   item.click();
   yield extension.awaitFinish("webNavigation.from_address_bar.auto_bookmark");
@@ -190,16 +192,17 @@ add_task(function* test_webnavigation_ur
 
   yield addBookmark({
     title: "Test Keyword",
     url: "http://example.com/?q=%s",
     keyword: "testkw",
   });
 
   yield extension.startup();
+  yield SimpleTest.promiseFocus(window);
 
   yield extension.awaitMessage("ready");
 
   yield promiseAutocompleteResultPopup("testkw search");
 
   let item = gURLBar.popup.richlistbox.getItemAtIndex(0);
   item.click();
 
@@ -230,16 +233,17 @@ add_task(function* test_webnavigation_ur
   let extension = ExtensionTestUtils.loadExtension({
     background: backgroundScript,
     manifest: {
       permissions: ["webNavigation"],
     },
   });
 
   yield extension.startup();
+  yield SimpleTest.promiseFocus(window);
 
   yield extension.awaitMessage("ready");
 
   yield prepareSearchEngine();
   yield promiseAutocompleteResultPopup("foo");
 
   let item = gURLBar.popup.richlistbox.getItemAtIndex(0);
   item.click();
--- a/browser/components/extensions/test/browser/browser_ext_windows_events.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_events.js
@@ -99,16 +99,18 @@ add_task(function* testWindowsEvents() {
   yield BrowserTestUtils.closeWindow(win2);
 
   winId = yield extension.awaitMessage(`window-removed`);
   is(winId, win2Id, "Got removed event for the correct window ID.");
 
   info(`Close browser window 1`);
   yield BrowserTestUtils.closeWindow(win1);
 
+  currentWindow.focus();
+
   winId = yield extension.awaitMessage(`window-removed`);
   is(winId, win1Id, "Got removed event for the correct window ID.");
 
   winId = yield extension.awaitMessage(`window-focus-changed`);
   is(winId, currentWindowId, "Got focus change event for the correct window ID.");
 
   yield extension.awaitFinish("windows.events");
   yield extension.unload();