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 394886 6a7fae3bdc345e639bd793d5388db9d6948638da
parent 394885 b866630a4183b38c2c234508b1ca3b80f51d8595
child 394887 52df7ecbca614921cfc86fd51c0582679ec5041d
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1337975
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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", {});