Bug 1332868: Fix shutdown race in test_ext_contentscript_permission. r=gabor
authorKris Maglione <maglione.k@gmail.com>
Sat, 21 Jan 2017 15:20:19 -0800
changeset 375610 0cdd083de64d2c7d9cf742ca15546a00e80ec989
parent 375609 b03d23d20564849d72d3c01fd60af98292c8b507
child 375611 5267191b229f425a34f26f0d7a96fd5391f3105d
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1332868
milestone53.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 1332868: Fix shutdown race in test_ext_contentscript_permission. r=gabor MozReview-Commit-ID: EVMcSdU3fTG
toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html
@@ -10,27 +10,28 @@
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_contentscript() {
   function background() {
-    browser.test.onMessage.addListener(url => {
-      browser.tabs.create({url}).then(tab => {
-        return browser.tabs.executeScript(tab.id, {code: "true;"})
-                      .then(() => {
-                        browser.test.sendMessage("executed", true);
-                        browser.tabs.remove([tab.id]);
-                      }, err => {
-                        browser.test.sendMessage("executed", false);
-                        browser.tabs.remove([tab.id]);
-                      });
-      });
+    browser.test.onMessage.addListener(async url => {
+      let tab = await browser.tabs.create({url});
+
+      let executed = true;
+      try {
+        await browser.tabs.executeScript(tab.id, {code: "true;"});
+      } catch (e) {
+        executed = false;
+      }
+
+      await browser.tabs.remove([tab.id]);
+      browser.test.sendMessage("executed", executed);
     });
   }
 
   let extensionData = {
     manifest: {
       permissions: ["<all_urls>"],
     },
     background,