Bug 1337975 - Fix intermittent tabs.create test_urlbar_focus r=mixedpuppy
authorTomislav Jovanovic <tomica@gmail.com>
Thu, 02 Mar 2017 22:39:06 +0100
changeset 374936 6a7fae3bdc345e639bd793d5388db9d6948638da
parent 374935 b866630a4183b38c2c234508b1ca3b80f51d8595
child 374937 52df7ecbca614921cfc86fd51c0582679ec5041d
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1337975
milestone54.0a1
Bug 1337975 - Fix intermittent tabs.create test_urlbar_focus r=mixedpuppy MozReview-Commit-ID: J16ztP81Zov
browser/components/extensions/test/browser/browser_ext_tabs_create.js
--- a/browser/components/extensions/test/browser/browser_ext_tabs_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_create.js
@@ -162,28 +162,37 @@ add_task(function* test_create_options()
   yield extension.unload();
 
   yield BrowserTestUtils.removeTab(tab);
 });
 
 add_task(function* test_urlbar_focus() {
   const extension = ExtensionTestUtils.loadExtension({
     background() {
+      browser.tabs.onUpdated.addListener(function onUpdated(_, info) {
+        if (info.status === "complete") {
+          browser.test.sendMessage("complete");
+          browser.tabs.onUpdated.removeListener(onUpdated);
+        }
+      });
       browser.test.onMessage.addListener(async (cmd, ...args) => {
         const result = await browser.tabs[cmd](...args);
         browser.test.sendMessage("result", result);
       });
     },
   });
 
   yield extension.startup();
 
   // Test content is focused after opening a regular url
   extension.sendMessage("create", {url: "https://example.com"});
-  const tab1 = yield extension.awaitMessage("result");
+  const [tab1] = yield Promise.all([
+    extension.awaitMessage("result"),
+    extension.awaitMessage("complete"),
+  ]);
 
   is(document.activeElement.tagName, "browser", "Content focused after opening a web page");
 
   extension.sendMessage("remove", tab1.id);
   yield extension.awaitMessage("result");
 
   // Test urlbar is focused after opening an empty tab
   extension.sendMessage("create", {});