Bug 1313956: Async all the tests. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Mon, 07 Nov 2016 21:03:14 -0800
changeset 351796 7f56bd071c220800ca8e27054495fd42c7b3e624
parent 351795 425f66fa9b10348db740b74f9b7c664b0eb0c28a
child 351797 9ae69a2f818dcc3f37a5966b33da433976b03906
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1313956
milestone52.0a1
Bug 1313956: Async all the tests. r=aswan MozReview-Commit-ID: CyNCfEsDD42
browser/components/extensions/test/browser/.eslintrc.js
browser/components/extensions/test/browser/browser_ext_browserAction_context.js
browser/components/extensions/test/browser/browser_ext_incognito_popup.js
browser/components/extensions/test/browser/browser_ext_legacy_extension_context_contentscript.js
browser/components/extensions/test/browser/browser_ext_optionsPage_privileges.js
browser/components/extensions/test/browser/browser_ext_pageAction_context.js
browser/components/extensions/test/browser/browser_ext_pageAction_popup.js
browser/components/extensions/test/browser/browser_ext_pageAction_title.js
browser/components/extensions/test/browser/browser_ext_popup_shutdown.js
browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js
browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage_uninstall.js
browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
browser/components/extensions/test/browser/browser_ext_tabs_audio.js
browser/components/extensions/test/browser/browser_ext_tabs_captureVisibleTab.js
browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
browser/components/extensions/test/browser/browser_ext_tabs_create.js
browser/components/extensions/test/browser/browser_ext_tabs_detectLanguage.js
browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
browser/components/extensions/test/browser/browser_ext_tabs_events.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript_runAt.js
browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js
browser/components/extensions/test/browser/browser_ext_tabs_move.js
browser/components/extensions/test/browser/browser_ext_tabs_move_window.js
browser/components/extensions/test/browser/browser_ext_tabs_onHighlighted.js
browser/components/extensions/test/browser/browser_ext_tabs_query.js
browser/components/extensions/test/browser/browser_ext_tabs_reload.js
browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js
browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js
browser/components/extensions/test/browser/browser_ext_tabs_update_url.js
browser/components/extensions/test/browser/browser_ext_tabs_zoom.js
browser/components/extensions/test/browser/browser_ext_webNavigation_frameId0.js
browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js
browser/components/extensions/test/browser/browser_ext_windows_create.js
browser/components/extensions/test/browser/browser_ext_windows_create_params.js
browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
browser/components/extensions/test/browser/browser_ext_windows_create_url.js
browser/components/extensions/test/browser/browser_ext_windows_events.js
browser/components/extensions/test/browser/browser_ext_windows_size.js
browser/components/extensions/test/browser/browser_ext_windows_update.js
toolkit/components/extensions/.eslintrc.js
toolkit/components/extensions/test/mochitest/.eslintrc.js
toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
toolkit/components/extensions/test/mochitest/test_ext_cookies.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
toolkit/components/extensions/test/mochitest/test_ext_i18n.html
toolkit/components/extensions/test/mochitest/test_ext_notifications.html
toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html
toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html
toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js
toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js
toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js
toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js
toolkit/components/extensions/test/xpcshell/test_ext_extension.js
toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
toolkit/components/extensions/test/xpcshell/test_ext_storage.js
--- a/browser/components/extensions/test/browser/.eslintrc.js
+++ b/browser/components/extensions/test/browser/.eslintrc.js
@@ -24,9 +24,13 @@ module.exports = {  // eslint-disable-li
     "closeContextMenu": true,
     "closeExtensionContextMenu": true,
     "focusWindow": true,
     "makeWidgetId": true,
     "openContextMenu": true,
     "openExtensionContextMenu": true,
     "CustomizableUI": true,
   },
+
+  "rules": {
+    "no-shadow": 0,
+  },
 };
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
@@ -1,45 +1,31 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 function* runTests(options) {
   function background(getTests) {
-    // Gets the current details of the browser action, and returns a
-    // promise that resolves to an object containing them.
-    function getDetails(tabId) {
-      return Promise.all([
-        browser.browserAction.getTitle({tabId}),
-        browser.browserAction.getPopup({tabId}),
-        browser.browserAction.getBadgeText({tabId}),
-        browser.browserAction.getBadgeBackgroundColor({tabId})]
-      ).then(details => {
-        return Promise.resolve({title: details[0],
-                                popup: details[1],
-                                badge: details[2],
-                                badgeBackgroundColor: details[3]});
-      });
-    }
+    async function checkDetails(expecting, tabId) {
+      let title = await browser.browserAction.getTitle({tabId});
+      browser.test.assertEq(expecting.title, title,
+                            "expected value from getTitle");
+
+      let popup = await browser.browserAction.getPopup({tabId});
+      browser.test.assertEq(expecting.popup, popup,
+                            "expected value from getPopup");
 
-    function checkDetails(expecting, tabId) {
-      return getDetails(tabId).then(details => {
-        browser.test.assertEq(expecting.title, details.title,
-                              "expected value from getTitle");
-
-        browser.test.assertEq(expecting.popup, details.popup,
-                              "expected value from getPopup");
+      let badge = await browser.browserAction.getBadgeText({tabId});
+      browser.test.assertEq(expecting.badge, badge,
+                            "expected value from getBadge");
 
-        browser.test.assertEq(expecting.badge, details.badge,
-                              "expected value from getBadge");
-
-        browser.test.assertEq(String(expecting.badgeBackgroundColor),
-                              String(details.badgeBackgroundColor),
-                              "expected value from getBadgeBackgroundColor");
-      });
+      let badgeBackgroundColor = await browser.browserAction.getBadgeBackgroundColor({tabId});
+      browser.test.assertEq(String(expecting.badgeBackgroundColor),
+                            String(badgeBackgroundColor),
+                            "expected value from getBadgeBackgroundColor");
     }
 
     let expectDefaults = expecting => {
       return checkDetails(expecting);
     };
 
     let tabs = [];
     let tests = getTests(tabs, expectDefaults);
@@ -73,28 +59,25 @@ function* runTests(options) {
       }
     }
 
     // Runs the next test in the `tests` array, checks the results,
     // and passes control back to the outer test scope.
     function nextTest() {
       let test = tests.shift();
 
-      test(expecting => {
+      test(async expecting => {
         // Check that the API returns the expected values, and then
         // run the next test.
-        new Promise(resolve => {
-          return browser.tabs.query({active: true, currentWindow: true}, resolve);
-        }).then(tabs => {
-          return checkDetails(expecting, tabs[0].id);
-        }).then(() => {
-          // Check that the actual icon has the expected values, then
-          // run the next test.
-          browser.test.sendMessage("nextTest", expecting, tests.length);
-        });
+        let tabs = await browser.tabs.query({active: true, currentWindow: true});
+        await checkDetails(expecting, tabs[0].id);
+
+        // Check that the actual icon has the expected values, then
+        // run the next test.
+        browser.test.sendMessage("nextTest", expecting, tests.length);
       });
     }
 
     browser.test.onMessage.addListener((msg) => {
       if (msg != "runNextTest") {
         browser.test.fail("Expecting 'runNextTest' message");
       }
 
@@ -236,117 +219,110 @@ add_task(function* testTabSwitchContext(
         {"icon": browser.runtime.getURL("default-2.png"),
          "popup": browser.runtime.getURL("default-2.html"),
          "title": "Default Title 2",
          "badge": "d2",
          "badgeBackgroundColor": [0, 0xff, 0, 0xff]},
       ];
 
       return [
-        expect => {
+        async expect => {
           browser.test.log("Initial state, expect default properties.");
-          expectDefaults(details[0]).then(() => {
-            expect(details[0]);
-          });
+
+          await expectDefaults(details[0]);
+          expect(details[0]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change the icon in the current tab. Expect default properties excluding the icon.");
           browser.browserAction.setIcon({tabId: tabs[0], path: "1.png"});
-          expectDefaults(details[0]).then(() => {
-            expect(details[1]);
-          });
+
+          await expectDefaults(details[0]);
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Create a new tab. Expect default properties.");
-          browser.tabs.create({active: true, url: "about:blank?0"}, tab => {
-            tabs.push(tab.id);
-            expectDefaults(details[0]).then(() => {
-              expect(details[0]);
-            });
-          });
+          let tab = await browser.tabs.create({active: true, url: "about:blank?0"});
+          tabs.push(tab.id);
+
+          await expectDefaults(details[0]);
+          expect(details[0]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change properties. Expect new properties.");
           let tabId = tabs[1];
           browser.browserAction.setIcon({tabId, path: "2.png"});
           browser.browserAction.setPopup({tabId, popup: "2.html"});
           browser.browserAction.setTitle({tabId, title: "Title 2"});
           browser.browserAction.setBadgeText({tabId, text: "2"});
           browser.browserAction.setBadgeBackgroundColor({tabId, color: "#ff0000"});
           browser.browserAction.disable(tabId);
 
-          expectDefaults(details[0]).then(() => {
-            expect(details[2]);
-          });
+          await expectDefaults(details[0]);
+          expect(details[2]);
         },
         expect => {
           browser.test.log("Navigate to a new page. Expect no changes.");
 
           // TODO: This listener should not be necessary, but the |tabs.update|
           // callback currently fires too early in e10s windows.
           browser.tabs.onUpdated.addListener(function listener(tabId, changed) {
             if (tabId == tabs[1] && changed.url) {
               browser.tabs.onUpdated.removeListener(listener);
               expect(details[2]);
             }
           });
 
           browser.tabs.update(tabs[1], {url: "about:blank?1"});
         },
-        expect => {
+        async expect => {
           browser.test.log("Switch back to the first tab. Expect previously set properties.");
-          browser.tabs.update(tabs[0], {active: true}, () => {
-            expect(details[1]);
-          });
+          await browser.tabs.update(tabs[0], {active: true});
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change default values, expect those changes reflected.");
           browser.browserAction.setIcon({path: "default-2.png"});
           browser.browserAction.setPopup({popup: "default-2.html"});
           browser.browserAction.setTitle({title: "Default Title 2"});
           browser.browserAction.setBadgeText({text: "d2"});
           browser.browserAction.setBadgeBackgroundColor({color: [0, 0xff, 0, 0xff]});
           browser.browserAction.disable();
-          expectDefaults(details[3]).then(() => {
-            expect(details[3]);
-          });
+
+          await expectDefaults(details[3]);
+          expect(details[3]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Re-enable by default. Expect enabled.");
           browser.browserAction.enable();
-          expectDefaults(details[4]).then(() => {
-            expect(details[4]);
-          });
+
+          await expectDefaults(details[4]);
+          expect(details[4]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Switch back to tab 2. Expect former value, unaffected by changes to defaults in previous step.");
-          browser.tabs.update(tabs[1], {active: true}, () => {
-            expectDefaults(details[3]).then(() => {
-              expect(details[2]);
-            });
-          });
+          await browser.tabs.update(tabs[1], {active: true});
+
+          await expectDefaults(details[3]);
+          expect(details[2]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Delete tab, switch back to tab 1. Expect previous results again.");
-          browser.tabs.remove(tabs[1], () => {
-            expect(details[4]);
-          });
+          await browser.tabs.remove(tabs[1]);
+          expect(details[4]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Create a new tab. Expect new default properties.");
-          browser.tabs.create({active: true, url: "about:blank?2"}, tab => {
-            tabs.push(tab.id);
-            expect(details[5]);
-          });
+          let tab = await browser.tabs.create({active: true, url: "about:blank?2"});
+          tabs.push(tab.id);
+          expect(details[5]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Delete tab.");
-          browser.tabs.remove(tabs[2], () => {
-            expect(details[4]);
-          });
+          await browser.tabs.remove(tabs[2]);
+          expect(details[4]);
         },
       ];
     },
   });
 });
 
 add_task(function* testDefaultTitle() {
   yield runTests({
@@ -386,46 +362,46 @@ add_task(function* testDefaultTitle() {
         {"title": "",
          "popup": "",
          "badge": "",
          "badgeBackgroundColor": DEFAULT_BADGE_COLOR,
          "icon": browser.runtime.getURL("icon.png")},
       ];
 
       return [
-        expect => {
+        async expect => {
           browser.test.log("Initial state. Expect extension title as default title.");
-          expectDefaults(details[0]).then(() => {
-            expect(details[0]);
-          });
+
+          await expectDefaults(details[0]);
+          expect(details[0]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change the title. Expect new title.");
           browser.browserAction.setTitle({tabId: tabs[0], title: "Foo Title"});
-          expectDefaults(details[0]).then(() => {
-            expect(details[1]);
-          });
+
+          await expectDefaults(details[0]);
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change the default. Expect same properties.");
           browser.browserAction.setTitle({title: "Bar Title"});
-          expectDefaults(details[2]).then(() => {
-            expect(details[1]);
-          });
+
+          await expectDefaults(details[2]);
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Clear the title. Expect new default title.");
           browser.browserAction.setTitle({tabId: tabs[0], title: ""});
-          expectDefaults(details[2]).then(() => {
-            expect(details[2]);
-          });
+
+          await expectDefaults(details[2]);
+          expect(details[2]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Set default title to null string. Expect null string from API, extension title in UI.");
           browser.browserAction.setTitle({title: ""});
-          expectDefaults(details[3]).then(() => {
-            expect(details[3]);
-          });
+
+          await expectDefaults(details[3]);
+          expect(details[3]);
         },
       ];
     },
   });
 });
--- a/browser/components/extensions/test/browser/browser_ext_incognito_popup.js
+++ b/browser/components/extensions/test/browser/browser_ext_incognito_popup.js
@@ -9,91 +9,92 @@ add_task(function* testIncognitoPopup() 
       "browser_action": {
         "default_popup": "popup.html",
       },
       "page_action": {
         "default_popup": "popup.html",
       },
     },
 
-    background() {
+    background: async function() {
       let resolveMessage;
       browser.runtime.onMessage.addListener(msg => {
         if (resolveMessage && msg.message == "popup-details") {
           resolveMessage(msg);
         }
       });
 
       let awaitPopup = windowId => {
         return new Promise(resolve => {
           resolveMessage = resolve;
         }).then(msg => {
           browser.test.assertEq(windowId, msg.windowId, "Got popup message from correct window");
           return msg;
         });
       };
 
-      let testWindow = window => {
-        return browser.tabs.query({active: true, windowId: window.id}).then(([tab]) => {
-          return browser.pageAction.show(tab.id);
-        }).then(() => {
-          browser.test.sendMessage("click-pageAction");
+      let testWindow = async window => {
+        let [tab] = await browser.tabs.query({active: true, windowId: window.id});
+
+        await browser.pageAction.show(tab.id);
+        browser.test.sendMessage("click-pageAction");
 
-          return awaitPopup(window.id);
-        }).then(msg => {
-          browser.test.assertEq(window.incognito, msg.incognito, "Correct incognito status in pageAction popup");
+        let msg = await awaitPopup(window.id);
+        browser.test.assertEq(window.incognito, msg.incognito, "Correct incognito status in pageAction popup");
 
-          browser.test.sendMessage("click-browserAction");
+        browser.test.sendMessage("click-browserAction");
 
-          return awaitPopup(window.id);
-        }).then(msg => {
-          browser.test.assertEq(window.incognito, msg.incognito, "Correct incognito status in browserAction popup");
-        });
+        msg = await awaitPopup(window.id);
+        browser.test.assertEq(window.incognito, msg.incognito, "Correct incognito status in browserAction popup");
       };
 
       const URL = "http://example.com/incognito";
       let windowReady = new Promise(resolve => {
         browser.tabs.onUpdated.addListener(function listener(tabId, changed, tab) {
           if (changed.status == "complete" && tab.url == URL) {
             browser.tabs.onUpdated.removeListener(listener);
             resolve();
           }
         });
       });
 
-      browser.windows.getCurrent().then(window => {
-        return testWindow(window);
-      }).then(() => {
-        return browser.windows.create({incognito: true, url: URL});
-      }).then(window => {
-        return windowReady.then(() => {
-          return testWindow(window);
-        }).then(() => {
-          return browser.windows.remove(window.id);
-        });
-      }).then(() => {
+      try {
+        {
+          let window = await browser.windows.getCurrent();
+
+          await testWindow(window);
+        }
+
+        {
+          let window = await browser.windows.create({incognito: true, url: URL});
+          await windowReady;
+
+          await testWindow(window);
+
+          await browser.windows.remove(window.id);
+        }
+
         browser.test.notifyPass("incognito");
-      }).catch(error => {
+      } catch (error) {
         browser.test.fail(`Error: ${error} :: ${error.stack}`);
         browser.test.notifyFail("incognito");
-      });
+      }
     },
 
     files: {
       "popup.html": '<html><head><meta charset="utf-8"><script src="popup.js"></script></head></html>',
 
-      "popup.js": function() {
-        browser.windows.getCurrent().then(win => {
-          browser.runtime.sendMessage({
-            message: "popup-details",
-            windowId: win.id,
-            incognito: browser.extension.inIncognitoContext,
-          });
-          window.close();
+      "popup.js": async function() {
+        let win = await browser.windows.getCurrent();
+        browser.runtime.sendMessage({
+          message: "popup-details",
+          windowId: win.id,
+          incognito: browser.extension.inIncognitoContext,
         });
+        window.close();
       },
     },
   });
 
   extension.onMessage("click-browserAction", () => {
     clickBrowserAction(extension, Services.wm.getMostRecentWindow("navigator:browser"));
   });
 
--- a/browser/components/extensions/test/browser/browser_ext_legacy_extension_context_contentscript.js
+++ b/browser/components/extensions/test/browser/browser_ext_legacy_extension_context_contentscript.js
@@ -22,27 +22,29 @@ function promiseAddonStartup(extension) 
  * tab info.
  */
 add_task(function* test_legacy_extension_context_contentscript_connection() {
   function backgroundScript() {
     // Extract the assigned uuid from the background page url and send it
     // in a test message.
     let uuid = window.location.hostname;
 
-    browser.test.onMessage.addListener(msg => {
+    browser.test.onMessage.addListener(async msg => {
       if (msg == "open-test-tab") {
-        browser.tabs.create({url: "http://example.com/"})
-          .then(tab => browser.test.sendMessage("get-expected-sender-info", {
-            uuid, tab,
-          }));
+        let tab = await browser.tabs.create({url: "http://example.com/"});
+        browser.test.sendMessage("get-expected-sender-info",
+                                 {uuid, tab});
       } else if (msg == "close-current-tab") {
-        browser.tabs.query({active: true})
-          .then(tabs => browser.tabs.remove(tabs[0].id))
-          .then(() => browser.test.sendMessage("current-tab-closed", true))
-          .catch(() => browser.test.sendMessage("current-tab-closed", false));
+        try {
+          let [tab] = await browser.tabs.query({active: true});
+          await browser.tabs.remove(tab.id);
+          browser.test.sendMessage("current-tab-closed", true);
+        } catch (e) {
+          browser.test.sendMessage("current-tab-closed", false);
+        }
       }
     });
 
     browser.test.sendMessage("ready");
   }
 
   function contentScript() {
     browser.runtime.sendMessage("webextension -> legacy_extension message", (reply) => {
--- a/browser/components/extensions/test/browser/browser_ext_optionsPage_privileges.js
+++ b/browser/components/extensions/test/browser/browser_ext_optionsPage_privileges.js
@@ -12,26 +12,27 @@ add_task(function* test_tab_options_priv
           browser.test.log(`Error: ${error} :: ${error.stack}`);
           browser.test.notifyFail("options-ui-privileges");
         });
       }
     });
     browser.runtime.openOptionsPage();
   }
 
-  function optionsScript() {
-    browser.tabs.query({url: "http://example.com/"}).then(tabs => {
-      browser.test.assertEq("http://example.com/", tabs[0].url, "Got the expect tab");
-      return browser.tabs.getCurrent();
-    }).then(tab => {
+  async function optionsScript() {
+    try {
+      let [tab] = await browser.tabs.query({url: "http://example.com/"});
+      browser.test.assertEq("http://example.com/", tab.url, "Got the expect tab");
+
+      tab = await browser.tabs.getCurrent();
       browser.runtime.sendMessage({msgName: "removeTabId", tabId: tab.id});
-    }).catch(error => {
+    } catch (error) {
       browser.test.log(`Error: ${error} :: ${error.stack}`);
       browser.test.notifyFail("options-ui-privileges");
-    });
+    }
   }
 
   const ID = "options_privileges@tests.mozilla.org";
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "temporary",
 
     manifest: {
       applications: {gecko: {id: ID}},
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
@@ -74,108 +74,105 @@ add_task(function* testTabSwitchContext(
           browser.tabs.onUpdated.addListener(function listener(tabId, changed) {
             if (tabId == details.id && changed.url == details.url) {
               browser.tabs.onUpdated.removeListener(listener);
               resolve();
             }
           });
         });
       };
+
       return [
         expect => {
           browser.test.log("Initial state. No icon visible.");
           expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Show the icon on the first tab, expect default properties.");
-          browser.pageAction.show(tabs[0]).then(() => {
-            expect(details[0]);
-          });
+          await browser.pageAction.show(tabs[0]);
+          expect(details[0]);
         },
         expect => {
           browser.test.log("Change the icon. Expect default properties excluding the icon.");
           browser.pageAction.setIcon({tabId: tabs[0], path: "1.png"});
           expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Create a new tab. No icon visible.");
-          browser.tabs.create({active: true, url: "about:blank?0"}, tab => {
-            tabs.push(tab.id);
-            expect(null);
-          });
+          let tab = await browser.tabs.create({active: true, url: "about:blank?0"});
+          tabs.push(tab.id);
+          expect(null);
         },
         expect => {
           browser.test.log("Await tab load. No icon visible.");
           expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change properties. Expect new properties.");
           let tabId = tabs[1];
-          browser.pageAction.show(tabId).then(() => {
-            browser.pageAction.setIcon({tabId, path: "2.png"});
-            browser.pageAction.setPopup({tabId, popup: "2.html"});
-            browser.pageAction.setTitle({tabId, title: "Title 2"});
+          await browser.pageAction.show(tabId);
 
-            expect(details[2]);
-          });
+          browser.pageAction.setIcon({tabId, path: "2.png"});
+          browser.pageAction.setPopup({tabId, popup: "2.html"});
+          browser.pageAction.setTitle({tabId, title: "Title 2"});
+
+          expect(details[2]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change the hash. Expect same properties.");
 
-          promiseTabLoad({id: tabs[1], url: "about:blank?0#ref"}).then(() => {
-            expect(details[2]);
-          });
+          let promise = promiseTabLoad({id: tabs[1], url: "about:blank?0#ref"});
+          browser.tabs.update(tabs[1], {url: "about:blank?0#ref"});
+          await promise;
 
-          browser.tabs.update(tabs[1], {url: "about:blank?0#ref"});
+          expect(details[2]);
         },
         expect => {
           browser.test.log("Clear the title. Expect default title.");
           browser.pageAction.setTitle({tabId: tabs[1], title: ""});
 
           expect(details[3]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Navigate to a new page. Expect icon hidden.");
 
           // TODO: This listener should not be necessary, but the |tabs.update|
           // callback currently fires too early in e10s windows.
-          promiseTabLoad({id: tabs[1], url: "about:blank?1"}).then(() => {
-            expect(null);
-          });
+          let promise = promiseTabLoad({id: tabs[1], url: "about:blank?1"});
 
           browser.tabs.update(tabs[1], {url: "about:blank?1"});
-        },
-        expect => {
-          browser.test.log("Show the icon. Expect default properties again.");
-          browser.pageAction.show(tabs[1]).then(() => {
-            expect(details[0]);
-          });
+
+          await promise;
+          expect(null);
         },
-        expect => {
+        async expect => {
+          browser.test.log("Show the icon. Expect default properties again.");
+
+          await browser.pageAction.show(tabs[1]);
+          expect(details[0]);
+        },
+        async expect => {
           browser.test.log("Switch back to the first tab. Expect previously set properties.");
-          browser.tabs.update(tabs[0], {active: true}, () => {
-            expect(details[1]);
-          });
+          await browser.tabs.update(tabs[0], {active: true});
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Hide the icon on tab 2. Switch back, expect hidden.");
-          browser.pageAction.hide(tabs[1]).then(() => {
-            browser.tabs.update(tabs[1], {active: true}, () => {
-              expect(null);
-            });
-          });
+          await browser.pageAction.hide(tabs[1]);
+
+          await browser.tabs.update(tabs[1], {active: true});
+          expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Switch back to tab 1. Expect previous results again.");
-          browser.tabs.remove(tabs[1], () => {
-            expect(details[1]);
-          });
+          await browser.tabs.remove(tabs[1]);
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Hide the icon. Expect hidden.");
-          browser.pageAction.hide(tabs[0]).then(() => {
-            expect(null);
-          });
+
+          await browser.pageAction.hide(tabs[0]);
+          expect(null);
         },
       ];
     },
   });
 });
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js
@@ -34,17 +34,17 @@ add_task(function* testPageActionPopup()
 
       "data/popup-b.html": scriptPage("popup-b.js"),
       "data/popup-b.js": function() {
         browser.runtime.sendMessage("from-popup-b");
       },
 
       "data/background.html": scriptPage("background.js"),
 
-      "data/background.js": function() {
+      "data/background.js": async function() {
         let tabId;
 
         let sendClick;
         let tests = [
           () => {
             sendClick({expectEvent: false, expectPopup: "a"});
           },
           () => {
@@ -110,17 +110,17 @@ add_task(function* testPageActionPopup()
           } else {
             browser.test.fail("unexpected click event");
           }
 
           expect.event = false;
           browser.test.sendMessage("next-test");
         });
 
-        browser.test.onMessage.addListener((msg) => {
+        browser.test.onMessage.addListener(msg => {
           if (msg == "close-popup") {
             browser.runtime.sendMessage("close-popup");
             return;
           }
 
           if (msg != "next-test") {
             browser.test.fail("Expecting 'next-test' message");
           }
@@ -128,23 +128,21 @@ add_task(function* testPageActionPopup()
           if (tests.length) {
             let test = tests.shift();
             test();
           } else {
             browser.test.notifyPass("pageaction-tests-done");
           }
         });
 
-        browser.tabs.query({active: true, currentWindow: true}, tabs => {
-          tabId = tabs[0].id;
+        let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+        tabId = tab.id;
 
-          browser.pageAction.show(tabId).then(() => {
-            browser.test.sendMessage("next-test");
-          });
-        });
+        await browser.pageAction.show(tabId);
+        browser.test.sendMessage("next-test");
       },
     },
   });
 
   extension.onMessage("send-click", () => {
     clickPageAction(extension);
   });
 
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_title.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_title.js
@@ -79,106 +79,100 @@ add_task(function* testTabSwitchContext(
           });
         });
       };
       return [
         expect => {
           browser.test.log("Initial state. No icon visible.");
           expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Show the icon on the first tab, expect default properties.");
-          browser.pageAction.show(tabs[0]).then(() => {
-            expect(details[0]);
-          });
+          await browser.pageAction.show(tabs[0]);
+          expect(details[0]);
         },
         expect => {
           browser.test.log("Change the icon. Expect default properties excluding the icon.");
           browser.pageAction.setIcon({tabId: tabs[0], path: "1.png"});
           expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Create a new tab. No icon visible.");
-          browser.tabs.create({active: true, url: "about:blank?0"}, tab => {
-            tabs.push(tab.id);
-            expect(null);
-          });
+          let tab = await browser.tabs.create({active: true, url: "about:blank?0"});
+          tabs.push(tab.id);
+          expect(null);
         },
         expect => {
           browser.test.log("Await tab load. No icon visible.");
           expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change properties. Expect new properties.");
           let tabId = tabs[1];
-          browser.pageAction.show(tabId).then(() => {
-            browser.pageAction.setIcon({tabId, path: "2.png"});
-            browser.pageAction.setPopup({tabId, popup: "2.html"});
-            browser.pageAction.setTitle({tabId, title: "Title 2"});
 
-            expect(details[2]);
-          });
+          await browser.pageAction.show(tabId);
+          browser.pageAction.setIcon({tabId, path: "2.png"});
+          browser.pageAction.setPopup({tabId, popup: "2.html"});
+          browser.pageAction.setTitle({tabId, title: "Title 2"});
+
+          expect(details[2]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Change the hash. Expect same properties.");
 
-          promiseTabLoad({id: tabs[1], url: "about:blank?0#ref"}).then(() => {
-            expect(details[2]);
-          });
+          let promise = promiseTabLoad({id: tabs[1], url: "about:blank?0#ref"});
 
           browser.tabs.update(tabs[1], {url: "about:blank?0#ref"});
+
+          await promise;
+          expect(details[2]);
         },
         expect => {
           browser.test.log("Clear the title. Expect default title.");
           browser.pageAction.setTitle({tabId: tabs[1], title: ""});
 
           expect(details[3]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Navigate to a new page. Expect icon hidden.");
 
           // TODO: This listener should not be necessary, but the |tabs.update|
           // callback currently fires too early in e10s windows.
-          promiseTabLoad({id: tabs[1], url: "about:blank?1"}).then(() => {
-            expect(null);
-          });
+          let promise = promiseTabLoad({id: tabs[1], url: "about:blank?1"});
 
           browser.tabs.update(tabs[1], {url: "about:blank?1"});
-        },
-        expect => {
-          browser.test.log("Show the icon. Expect default properties again.");
-          browser.pageAction.show(tabs[1]).then(() => {
-            expect(details[0]);
-          });
+
+          await promise;
+          expect(null);
         },
-        expect => {
+        async expect => {
+          browser.test.log("Show the icon. Expect default properties again.");
+          await browser.pageAction.show(tabs[1]);
+          expect(details[0]);
+        },
+        async expect => {
           browser.test.log("Switch back to the first tab. Expect previously set properties.");
-          browser.tabs.update(tabs[0], {active: true}, () => {
-            expect(details[1]);
-          });
+          await browser.tabs.update(tabs[0], {active: true});
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Hide the icon on tab 2. Switch back, expect hidden.");
-          browser.pageAction.hide(tabs[1]).then(() => {
-            browser.tabs.update(tabs[1], {active: true}, () => {
-              expect(null);
-            });
-          });
+          await browser.pageAction.hide(tabs[1]);
+          await browser.tabs.update(tabs[1], {active: true});
+          expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Switch back to tab 1. Expect previous results again.");
-          browser.tabs.remove(tabs[1], () => {
-            expect(details[1]);
-          });
+          await browser.tabs.remove(tabs[1]);
+          expect(details[1]);
         },
-        expect => {
+        async expect => {
           browser.test.log("Hide the icon. Expect hidden.");
-          browser.pageAction.hide(tabs[0]).then(() => {
-            expect(null);
-          });
+          await browser.pageAction.hide(tabs[0]);
+          expect(null);
         },
       ];
     },
   });
 });
 
 add_task(function* testDefaultTitle() {
   yield runTests({
@@ -206,21 +200,20 @@ add_task(function* testDefaultTitle() {
          "icon": browser.runtime.getURL("icon.png")},
       ];
 
       return [
         expect => {
           browser.test.log("Initial state. No icon visible.");
           expect(null);
         },
-        expect => {
+        async expect => {
           browser.test.log("Show the icon on the first tab, expect extension title as default title.");
-          browser.pageAction.show(tabs[0]).then(() => {
-            expect(details[0]);
-          });
+          await browser.pageAction.show(tabs[0]);
+          expect(details[0]);
         },
         expect => {
           browser.test.log("Change the title. Expect new title.");
           browser.pageAction.setTitle({tabId: tabs[0], title: "Foo Title"});
           expect(details[1]);
         },
         expect => {
           browser.test.log("Clear the title. Expect extension title.");
--- a/browser/components/extensions/test/browser/browser_ext_popup_shutdown.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_shutdown.js
@@ -1,19 +1,18 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 let getExtension = () => {
   return ExtensionTestUtils.loadExtension({
-    background() {
-      browser.tabs.query({active: true, currentWindow: true}, tabs => {
-        browser.pageAction.show(tabs[0].id)
-          .then(() => { browser.test.sendMessage("pageAction ready"); });
-      });
+    background: async function() {
+      let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+      await browser.pageAction.show(tab.id);
+      browser.test.sendMessage("pageAction ready");
     },
 
     manifest: {
       "browser_action": {
         "default_popup": "popup.html",
         "browser_style": false,
       },
 
--- a/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js
+++ b/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js
@@ -56,17 +56,17 @@ add_tasks(function* test_inline_options(
   let extension = yield loadExtension(Object.assign({}, extraOptions, {
     manifest: {
       applications: {gecko: {id: "inline_options@tests.mozilla.org"}},
       "options_ui": {
         "page": "options.html",
       },
     },
 
-    background: function() {
+    background: async function() {
       let _optionsPromise;
       let awaitOptions = () => {
         browser.test.assertFalse(_optionsPromise, "Should not be awaiting options already");
 
         return new Promise(resolve => {
           _optionsPromise = {resolve};
         });
       };
@@ -77,76 +77,73 @@ add_tasks(function* test_inline_options(
             _optionsPromise.resolve(sender.tab);
             _optionsPromise = null;
           } else {
             browser.test.fail("Saw unexpected options page load");
           }
         }
       });
 
-      let firstTab, optionsTab;
-      browser.tabs.query({currentWindow: true, active: true}).then(tabs => {
-        firstTab = tabs[0].id;
+      try {
+        let [firstTab] = await browser.tabs.query({currentWindow: true, active: true});
 
         browser.test.log("Open options page. Expect fresh load.");
-        return Promise.all([
+
+        let [, optionsTab] = await Promise.all([
           browser.runtime.openOptionsPage(),
           awaitOptions(),
         ]);
-      }).then(([, tab]) => {
-        browser.test.assertEq("about:addons", tab.url, "Tab contains AddonManager");
-        browser.test.assertTrue(tab.active, "Tab is active");
-        browser.test.assertTrue(tab.id != firstTab, "Tab is a new tab");
 
-        optionsTab = tab.id;
+        browser.test.assertEq("about:addons", optionsTab.url, "Tab contains AddonManager");
+        browser.test.assertTrue(optionsTab.active, "Tab is active");
+        browser.test.assertTrue(optionsTab.id != firstTab.id, "Tab is a new tab");
+
         browser.test.assertEq(0, browser.extension.getViews({type: "popup"}).length, "viewType is not popup");
         browser.test.assertEq(1, browser.extension.getViews({type: "tab"}).length, "viewType is tab");
-        browser.test.assertEq(1, browser.extension.getViews({windowId: tab.windowId}).length, "windowId matches");
+        browser.test.assertEq(1, browser.extension.getViews({windowId: optionsTab.windowId}).length, "windowId matches");
+
         let views = browser.extension.getViews();
         browser.test.assertEq(2, views.length, "Expected the options page and the background page");
         browser.test.assertTrue(views.includes(window), "One of the views is the background page");
         browser.test.assertTrue(views.some(w => w.iAmOption), "One of the views is the options page");
 
         browser.test.log("Switch tabs.");
-        return browser.tabs.update(firstTab, {active: true});
-      }).then(() => {
+        await browser.tabs.update(firstTab.id, {active: true});
+
         browser.test.log("Open options page again. Expect tab re-selected, no new load.");
 
-        return browser.runtime.openOptionsPage();
-      }).then(() => {
-        return browser.tabs.query({currentWindow: true, active: true});
-      }).then(([tab]) => {
-        browser.test.assertEq(optionsTab, tab.id, "Tab is the same as the previous options tab");
+        await browser.runtime.openOptionsPage();
+        let [tab] = await browser.tabs.query({currentWindow: true, active: true});
+
+        browser.test.assertEq(optionsTab.id, tab.id, "Tab is the same as the previous options tab");
         browser.test.assertEq("about:addons", tab.url, "Tab contains AddonManager");
 
         browser.test.log("Ping options page.");
-        return browser.runtime.sendMessage("ping");
-      }).then((pong) => {
+        let pong = await browser.runtime.sendMessage("ping");
         browser.test.assertEq("pong", pong, "Got pong.");
 
         browser.test.log("Remove options tab.");
-        return browser.tabs.remove(optionsTab);
-      }).then(() => {
+        await browser.tabs.remove(optionsTab.id);
+
         browser.test.log("Open options page again. Expect fresh load.");
-        return Promise.all([
+        [, tab] = await Promise.all([
           browser.runtime.openOptionsPage(),
           awaitOptions(),
         ]);
-      }).then(([, tab]) => {
         browser.test.assertEq("about:addons", tab.url, "Tab contains AddonManager");
         browser.test.assertTrue(tab.active, "Tab is active");
-        browser.test.assertTrue(tab.id != optionsTab, "Tab is a new tab");
+        browser.test.assertTrue(tab.id != optionsTab.id, "Tab is a new tab");
 
-        return browser.tabs.remove(tab.id);
-      }).then(() => {
+        await browser.tabs.remove(tab.id);
+
         browser.test.notifyPass("options-ui");
-      }).catch(error => {
-        browser.test.log(`Error: ${error} :: ${error.stack}`);
+      } catch (error) {
+        browser.test.fail(`Error: ${error} :: ${error.stack}`);
         browser.test.notifyFail("options-ui");
-      });
+      }
     },
   }));
 
   yield extension.awaitFinish("options-ui");
   yield extension.unload();
 
   yield BrowserTestUtils.removeTab(tab);
 });
@@ -160,17 +157,17 @@ add_tasks(function* test_tab_options(ext
     manifest: {
       applications: {gecko: {id: "tab_options@tests.mozilla.org"}},
       "options_ui": {
         "page": "options.html",
         "open_in_tab": true,
       },
     },
 
-    background: function() {
+    background: async function() {
       let _optionsPromise;
       let awaitOptions = () => {
         browser.test.assertFalse(_optionsPromise, "Should not be awaiting options already");
 
         return new Promise(resolve => {
           _optionsPromise = {resolve};
         });
       };
@@ -183,77 +180,73 @@ add_tasks(function* test_tab_options(ext
           } else {
             browser.test.fail("Saw unexpected options page load");
           }
         }
       });
 
       let optionsURL = browser.extension.getURL("options.html");
 
-      let firstTab, optionsTab;
-      browser.tabs.query({currentWindow: true, active: true}).then(tabs => {
-        firstTab = tabs[0].id;
+      try {
+        let [firstTab] = await browser.tabs.query({currentWindow: true, active: true});
 
         browser.test.log("Open options page. Expect fresh load.");
-        return Promise.all([
+        let [, optionsTab] = await Promise.all([
           browser.runtime.openOptionsPage(),
           awaitOptions(),
         ]);
-      }).then(([, tab]) => {
-        browser.test.assertEq(optionsURL, tab.url, "Tab contains options.html");
-        browser.test.assertTrue(tab.active, "Tab is active");
-        browser.test.assertTrue(tab.id != firstTab, "Tab is a new tab");
+        browser.test.assertEq(optionsURL, optionsTab.url, "Tab contains options.html");
+        browser.test.assertTrue(optionsTab.active, "Tab is active");
+        browser.test.assertTrue(optionsTab.id != firstTab.id, "Tab is a new tab");
 
-        optionsTab = tab.id;
         browser.test.assertEq(0, browser.extension.getViews({type: "popup"}).length, "viewType is not popup");
         browser.test.assertEq(1, browser.extension.getViews({type: "tab"}).length, "viewType is tab");
-        browser.test.assertEq(1, browser.extension.getViews({windowId: tab.windowId}).length, "windowId matches");
+        browser.test.assertEq(1, browser.extension.getViews({windowId: optionsTab.windowId}).length, "windowId matches");
+
         let views = browser.extension.getViews();
         browser.test.assertEq(2, views.length, "Expected the options page and the background page");
         browser.test.assertTrue(views.includes(window), "One of the views is the background page");
         browser.test.assertTrue(views.some(w => w.iAmOption), "One of the views is the options page");
 
         browser.test.log("Switch tabs.");
-        return browser.tabs.update(firstTab, {active: true});
-      }).then(() => {
+        await browser.tabs.update(firstTab.id, {active: true});
+
         browser.test.log("Open options page again. Expect tab re-selected, no new load.");
 
-        return browser.runtime.openOptionsPage();
-      }).then(() => {
-        return browser.tabs.query({currentWindow: true, active: true});
-      }).then(([tab]) => {
-        browser.test.assertEq(optionsTab, tab.id, "Tab is the same as the previous options tab");
+        await browser.runtime.openOptionsPage();
+        let [tab] = await browser.tabs.query({currentWindow: true, active: true});
+
+        browser.test.assertEq(optionsTab.id, tab.id, "Tab is the same as the previous options tab");
         browser.test.assertEq(optionsURL, tab.url, "Tab contains options.html");
 
         // Unfortunately, we can't currently do this, since onMessage doesn't
         // currently support responses when there are multiple listeners.
         //
         // browser.test.log("Ping options page.");
         // return new Promise(resolve => browser.runtime.sendMessage("ping", resolve));
 
         browser.test.log("Remove options tab.");
-        return browser.tabs.remove(optionsTab);
-      }).then(() => {
+        await browser.tabs.remove(optionsTab.id);
+
         browser.test.log("Open options page again. Expect fresh load.");
-        return Promise.all([
+        [, tab] = await Promise.all([
           browser.runtime.openOptionsPage(),
           awaitOptions(),
         ]);
-      }).then(([, tab]) => {
         browser.test.assertEq(optionsURL, tab.url, "Tab contains options.html");
         browser.test.assertTrue(tab.active, "Tab is active");
-        browser.test.assertTrue(tab.id != optionsTab, "Tab is a new tab");
+        browser.test.assertTrue(tab.id != optionsTab.id, "Tab is a new tab");
 
-        return browser.tabs.remove(tab.id);
-      }).then(() => {
+        await browser.tabs.remove(tab.id);
+
         browser.test.notifyPass("options-ui-tab");
-      }).catch(error => {
-        browser.test.log(`Error: ${error} :: ${error.stack}`);
+      } catch (error) {
+        browser.test.fail(`Error: ${error} :: ${error.stack}`);
         browser.test.notifyFail("options-ui-tab");
-      });
+      }
     },
   }));
 
   yield extension.awaitFinish("options-ui-tab");
   yield extension.unload();
 
   yield BrowserTestUtils.removeTab(tab);
 });
@@ -278,17 +271,17 @@ add_tasks(function* test_options_no_mani
           let expected = "No `options_ui` declared";
           browser.test.assertTrue(
             error.message.includes(expected),
             `Got expected error (got: '${error.message}', expected: '${expected}'`);
         }
       ).then(() => {
         browser.test.notifyPass("options-no-manifest");
       }).catch(error => {
-        browser.test.log(`Error: ${error} :: ${error.stack}`);
+        browser.test.fail(`Error: ${error} :: ${error.stack}`);
         browser.test.notifyFail("options-no-manifest");
       });
     },
   }));
 
   yield extension.awaitFinish("options-no-manifest");
   yield extension.unload();
 });
--- a/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage_uninstall.js
+++ b/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage_uninstall.js
@@ -43,17 +43,17 @@ add_task(function* test_inline_options_u
   let extension = yield loadExtension({
     manifest: {
       applications: {gecko: {id: "inline_options_uninstall@tests.mozilla.org"}},
       "options_ui": {
         "page": "options.html",
       },
     },
 
-    background: function() {
+    background: async function() {
       let _optionsPromise;
       let awaitOptions = () => {
         browser.test.assertFalse(_optionsPromise, "Should not be awaiting options already");
 
         return new Promise(resolve => {
           _optionsPromise = {resolve};
         });
       };
@@ -64,34 +64,33 @@ add_task(function* test_inline_options_u
             _optionsPromise.resolve(sender.tab);
             _optionsPromise = null;
           } else {
             browser.test.fail("Saw unexpected options page load");
           }
         }
       });
 
-      let firstTab;
-      browser.tabs.query({currentWindow: true, active: true}).then(tabs => {
-        firstTab = tabs[0].id;
+      try {
+        let [firstTab] = await browser.tabs.query({currentWindow: true, active: true});
 
         browser.test.log("Open options page. Expect fresh load.");
-        return Promise.all([
+        let [, tab] = await Promise.all([
           browser.runtime.openOptionsPage(),
           awaitOptions(),
         ]);
-      }).then(([, tab]) => {
+
         browser.test.assertEq("about:addons", tab.url, "Tab contains AddonManager");
         browser.test.assertTrue(tab.active, "Tab is active");
-        browser.test.assertTrue(tab.id != firstTab, "Tab is a new tab");
+        browser.test.assertTrue(tab.id != firstTab.id, "Tab is a new tab");
 
         browser.test.sendMessage("options-ui-open");
-      }).catch(error => {
+      } catch (error) {
         browser.test.fail(`Error: ${error} :: ${error.stack}`);
-      });
+      }
     },
   });
 
   yield extension.awaitMessage("options-ui-open");
   yield extension.unload();
 
   is(gBrowser.selectedBrowser.currentURI.spec, "about:addons",
      "Add-on manager tab should still be open");
--- a/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
+++ b/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
@@ -25,17 +25,17 @@ function* makeAndInstallXPI(id, backgrou
   let loadTab = yield loadPromise;
   yield BrowserTestUtils.removeTab(loadTab);
 
   return addon;
 }
 
 
 add_task(function* test_setuninstallurl_badargs() {
-  function backgroundScript() {
+  async function backgroundScript() {
     let promises = [
       browser.runtime.setUninstallURL("this is not a url")
         .then(() => {
           browser.test.notifyFail("setUninstallURL should have failed with bad url");
         })
         .catch(error => {
           browser.test.assertTrue(/Invalid URL/.test(error.message), "error message indicates malformed url");
         }),
@@ -44,52 +44,52 @@ add_task(function* test_setuninstallurl_
         .then(() => {
           browser.test.notifyFail("setUninstallURL should have failed with non-http[s] url");
         })
         .catch(error => {
           browser.test.assertTrue(/must have the scheme http or https/.test(error.message), "error message indicates bad scheme");
         }),
     ];
 
-    Promise.all(promises)
-      .then(() => browser.test.notifyPass("setUninstallURL bad params"));
+    await Promise.all(promises);
+    browser.test.notifyPass("setUninstallURL bad params");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: "(" + backgroundScript.toString() + ")()",
   });
   yield extension.startup();
   yield extension.awaitFinish();
   yield extension.unload();
 });
 
 // Test the documented behavior of setUninstallURL() that passing an
 // empty string is equivalent to not setting an uninstall URL
 // (i.e., no new tab is opened upon uninstall)
 add_task(function* test_setuninstall_empty_url() {
-  function backgroundScript() {
-    browser.runtime.setUninstallURL("")
-      .then(() => browser.tabs.create({url: "http://example.com/addon_loaded"}));
+  async function backgroundScript() {
+    await browser.runtime.setUninstallURL("");
+    browser.tabs.create({url: "http://example.com/addon_loaded"});
   }
 
   let addon = yield makeAndInstallXPI("test_uinstallurl2@tests.mozilla.org",
                                       backgroundScript,
                                       "http://example.com/addon_loaded");
 
   addon.uninstall(true);
   info("uninstalled");
 
   // no need to explicitly check for the absence of a new tab,
   // BrowserTestUtils will eventually complain if one is opened.
 });
 
 add_task(function* test_setuninstallurl() {
-  function backgroundScript() {
-    browser.runtime.setUninstallURL("http://example.com/addon_uninstalled")
-      .then(() => browser.tabs.create({url: "http://example.com/addon_loaded"}));
+  async function backgroundScript() {
+    await browser.runtime.setUninstallURL("http://example.com/addon_uninstalled");
+    browser.tabs.create({url: "http://example.com/addon_loaded"});
   }
 
   let addon = yield makeAndInstallXPI("test_uinstallurl@tests.mozilla.org",
                                       backgroundScript,
                                       "http://example.com/addon_loaded");
 
   // look for a new tab with the uninstall url.
   let uninstallPromise = BrowserTestUtils.waitForNewTab(gBrowser, "http://example.com/addon_uninstalled");
--- a/browser/components/extensions/test/browser/browser_ext_tabs_audio.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_audio.js
@@ -3,27 +3,17 @@
 "use strict";
 
 add_task(function* () {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank?1");
   let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank?2");
 
   gBrowser.selectedTab = tab1;
 
-  function background() {
-    // Wrap API methods in promise-based variants.
-    let promiseTabs = {};
-    Object.keys(browser.tabs).forEach(method => {
-      promiseTabs[method] = (...args) => {
-        return new Promise(resolve => {
-          browser.tabs[method](...args, resolve);
-        });
-      };
-    });
-
+  async function background() {
     function promiseUpdated(tabId, attr) {
       return new Promise(resolve => {
         let onUpdated = (tabId_, changeInfo, tab) => {
           if (tabId == tabId_ && attr in changeInfo) {
             browser.tabs.onUpdated.removeListener(onUpdated);
 
             resolve({changeInfo, tab});
           }
@@ -42,134 +32,129 @@ add_task(function* () {
     function changeTab(tabId, attr, on) {
       return new Promise((resolve, reject) => {
         deferred[tabId] = {resolve, reject};
         browser.test.sendMessage("change-tab", tabId, attr, on);
       });
     }
 
 
-    let windowId;
-    let tabIds;
-    promiseTabs.query({lastFocusedWindow: true}).then(tabs => {
+    try {
+      let tabs = await browser.tabs.query({lastFocusedWindow: true});
       browser.test.assertEq(tabs.length, 3, "We have three tabs");
 
       for (let tab of tabs) {
         // Note: We want to check that these are actual boolean values, not
         // just that they evaluate as false.
         browser.test.assertEq(false, tab.mutedInfo.muted, "Tab is not muted");
         browser.test.assertEq(undefined, tab.mutedInfo.reason, "Tab has no muted info reason");
         browser.test.assertEq(false, tab.audible, "Tab is not audible");
       }
 
-      windowId = tabs[0].windowId;
-      tabIds = [tabs[1].id, tabs[2].id];
+      let windowId = tabs[0].windowId;
+      let tabIds = [tabs[1].id, tabs[2].id];
 
       browser.test.log("Test initial queries for muted and audible return no tabs");
-      return Promise.all([
-        promiseTabs.query({windowId, audible: false}),
-        promiseTabs.query({windowId, audible: true}),
-        promiseTabs.query({windowId, muted: true}),
-        promiseTabs.query({windowId, muted: false}),
-      ]);
-    }).then(([silent, audible, muted, nonMuted]) => {
+      let silent = await browser.tabs.query({windowId, audible: false});
+      let audible = await browser.tabs.query({windowId, audible: true});
+      let muted = await browser.tabs.query({windowId, muted: true});
+      let nonMuted = await browser.tabs.query({windowId, muted: false});
+
       browser.test.assertEq(3, silent.length, "Three silent tabs");
       browser.test.assertEq(0, audible.length, "No audible tabs");
 
       browser.test.assertEq(0, muted.length, "No muted tabs");
       browser.test.assertEq(3, nonMuted.length, "Three non-muted tabs");
 
       browser.test.log("Toggle muted and audible externally on one tab each, and check results");
-      return Promise.all([
+      [muted, audible] = await Promise.all([
         promiseUpdated(tabIds[0], "mutedInfo"),
         promiseUpdated(tabIds[1], "audible"),
         changeTab(tabIds[0], "muted", true),
         changeTab(tabIds[1], "audible", true),
       ]);
-    }).then(([muted, audible]) => {
+
       for (let obj of [muted.changeInfo, muted.tab]) {
         browser.test.assertEq(true, obj.mutedInfo.muted, "Tab is muted");
         browser.test.assertEq("user", obj.mutedInfo.reason, "Tab was muted by the user");
       }
 
       browser.test.assertEq(true, audible.changeInfo.audible, "Tab audible state changed");
       browser.test.assertEq(true, audible.tab.audible, "Tab is audible");
 
       browser.test.log("Re-check queries. Expect one audible and one muted tab");
-      return Promise.all([
-        promiseTabs.query({windowId, audible: false}),
-        promiseTabs.query({windowId, audible: true}),
-        promiseTabs.query({windowId, muted: true}),
-        promiseTabs.query({windowId, muted: false}),
-      ]);
-    }).then(([silent, audible, muted, nonMuted]) => {
+      silent = await browser.tabs.query({windowId, audible: false});
+      audible = await browser.tabs.query({windowId, audible: true});
+      muted = await browser.tabs.query({windowId, muted: true});
+      nonMuted = await browser.tabs.query({windowId, muted: false});
+
       browser.test.assertEq(2, silent.length, "Two silent tabs");
       browser.test.assertEq(1, audible.length, "One audible tab");
 
       browser.test.assertEq(1, muted.length, "One muted tab");
       browser.test.assertEq(2, nonMuted.length, "Two non-muted tabs");
 
       browser.test.assertEq(true, muted[0].mutedInfo.muted, "Tab is muted");
       browser.test.assertEq("user", muted[0].mutedInfo.reason, "Tab was muted by the user");
 
       browser.test.assertEq(true, audible[0].audible, "Tab is audible");
 
       browser.test.log("Toggle muted internally on two tabs, and check results");
-      return Promise.all([
+      [nonMuted, muted] = await Promise.all([
         promiseUpdated(tabIds[0], "mutedInfo"),
         promiseUpdated(tabIds[1], "mutedInfo"),
-        promiseTabs.update(tabIds[0], {muted: false}),
-        promiseTabs.update(tabIds[1], {muted: true}),
+        browser.tabs.update(tabIds[0], {muted: false}),
+        browser.tabs.update(tabIds[1], {muted: true}),
       ]);
-    }).then(([unmuted, muted]) => {
-      for (let obj of [unmuted.changeInfo, unmuted.tab]) {
+
+      for (let obj of [nonMuted.changeInfo, nonMuted.tab]) {
         browser.test.assertEq(false, obj.mutedInfo.muted, "Tab is not muted");
       }
       for (let obj of [muted.changeInfo, muted.tab]) {
         browser.test.assertEq(true, obj.mutedInfo.muted, "Tab is muted");
       }
 
-      for (let obj of [unmuted.changeInfo, unmuted.tab, muted.changeInfo, muted.tab]) {
+      for (let obj of [nonMuted.changeInfo, nonMuted.tab, muted.changeInfo, muted.tab]) {
         browser.test.assertEq("extension", obj.mutedInfo.reason, "Mute state changed by extension");
 
         // FIXME: browser.runtime.id is currently broken.
         browser.test.assertEq(browser.i18n.getMessage("@@extension_id"),
                               obj.mutedInfo.extensionId,
                               "Mute state changed by extension");
       }
 
       browser.test.log("Test that mutedInfo is preserved by sessionstore");
-      return changeTab(tabIds[1], "duplicate").then(promiseTabs.get);
-    }).then(tab => {
+      let tab = await changeTab(tabIds[1], "duplicate").then(browser.tabs.get);
+
       browser.test.assertEq(true, tab.mutedInfo.muted, "Tab is muted");
 
       browser.test.assertEq("extension", tab.mutedInfo.reason, "Mute state changed by extension");
 
       // FIXME: browser.runtime.id is currently broken.
       browser.test.assertEq(browser.i18n.getMessage("@@extension_id"),
                             tab.mutedInfo.extensionId,
                             "Mute state changed by extension");
 
       browser.test.log("Unmute externally, and check results");
-      return Promise.all([
+      [nonMuted] = await Promise.all([
         promiseUpdated(tabIds[1], "mutedInfo"),
         changeTab(tabIds[1], "muted", false),
-        promiseTabs.remove(tab.id),
+        browser.tabs.remove(tab.id),
       ]);
-    }).then(([unmuted]) => {
-      for (let obj of [unmuted.changeInfo, unmuted.tab]) {
+
+      for (let obj of [nonMuted.changeInfo, nonMuted.tab]) {
         browser.test.assertEq(false, obj.mutedInfo.muted, "Tab is not muted");
         browser.test.assertEq("user", obj.mutedInfo.reason, "Mute state changed by user");
       }
 
       browser.test.notifyPass("tab-audio");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`${e} :: ${e.stack}`);
       browser.test.notifyFail("tab-audio");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_captureVisibleTab.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_captureVisibleTab.js
@@ -21,103 +21,95 @@ function* runTest(options) {
     </html>
   `;
 
   let url = `data:text/html,${encodeURIComponent(html)}`;
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url, true);
 
   tab.linkedBrowser.fullZoom = options.fullZoom;
 
-  function background(options) {
-    // Wrap API methods in promise-based variants.
-    let promiseTabs = {};
-    Object.keys(browser.tabs).forEach(method => {
-      promiseTabs[method] = (...args) => {
-        return new Promise(resolve => {
-          browser.tabs[method](...args, resolve);
-        });
-      };
-    });
-
+  async function background(options) {
     browser.test.log(`Test color ${options.color} at fullZoom=${options.fullZoom}`);
 
-    promiseTabs.query({currentWindow: true, active: true}).then(([tab]) => {
-      return Promise.all([
-        promiseTabs.captureVisibleTab(tab.windowId, {format: "jpeg", quality: 95}),
-        promiseTabs.captureVisibleTab(tab.windowId, {format: "png", quality: 95}),
-        promiseTabs.captureVisibleTab(tab.windowId, {quality: 95}),
-        promiseTabs.captureVisibleTab(tab.windowId),
-      ]).then(([jpeg, png, ...pngs]) => {
-        browser.test.assertTrue(pngs.every(url => url == png), "All PNGs are identical");
+    try {
+      let [tab] = await browser.tabs.query({currentWindow: true, active: true});
 
-        browser.test.assertTrue(jpeg.startsWith("data:image/jpeg;base64,"), "jpeg is JPEG");
-        browser.test.assertTrue(png.startsWith("data:image/png;base64,"), "png is PNG");
+      let [jpeg, png, ...pngs] = await Promise.all([
+        browser.tabs.captureVisibleTab(tab.windowId, {format: "jpeg", quality: 95}),
+        browser.tabs.captureVisibleTab(tab.windowId, {format: "png", quality: 95}),
+        browser.tabs.captureVisibleTab(tab.windowId, {quality: 95}),
+        browser.tabs.captureVisibleTab(tab.windowId),
+      ]);
+
+      browser.test.assertTrue(pngs.every(url => url == png), "All PNGs are identical");
+
+      browser.test.assertTrue(jpeg.startsWith("data:image/jpeg;base64,"), "jpeg is JPEG");
+      browser.test.assertTrue(png.startsWith("data:image/png;base64,"), "png is PNG");
 
-        let promises = [jpeg, png].map(url => new Promise(resolve => {
-          let img = new Image();
-          img.src = url;
-          img.onload = () => resolve(img);
-        }));
-        return Promise.all(promises);
-      }).then(([jpeg, png]) => {
-        let tabDims = `${tab.width}\u00d7${tab.height}`;
+      let promises = [jpeg, png].map(url => new Promise(resolve => {
+        let img = new Image();
+        img.src = url;
+        img.onload = () => resolve(img);
+      }));
 
-        let images = {jpeg, png};
-        for (let format of Object.keys(images)) {
-          let img = images[format];
+      [jpeg, png] = await Promise.all(promises);
+      let tabDims = `${tab.width}\u00d7${tab.height}`;
 
-          let dims = `${img.width}\u00d7${img.height}`;
-          browser.test.assertEq(tabDims, dims, `${format} dimensions are correct`);
+      let images = {jpeg, png};
+      for (let format of Object.keys(images)) {
+        let img = images[format];
 
-          let canvas = document.createElement("canvas");
-          canvas.width = img.width;
-          canvas.height = img.height;
-          canvas.mozOpaque = true;
+        let dims = `${img.width}\u00d7${img.height}`;
+        browser.test.assertEq(tabDims, dims, `${format} dimensions are correct`);
 
-          let ctx = canvas.getContext("2d");
-          ctx.drawImage(img, 0, 0);
+        let canvas = document.createElement("canvas");
+        canvas.width = img.width;
+        canvas.height = img.height;
+        canvas.mozOpaque = true;
 
-          // Check the colors of the first and last pixels of the image, to make
-          // sure we capture the entire frame, and scale it correctly.
-          let coords = [
-            {x: 0, y: 0,
-             color: options.color},
-            {x: img.width - 1,
-             y: img.height - 1,
-             color: options.color},
-            {x: img.width / 2 | 0,
-             y: img.height / 2 | 0,
-             color: options.neutral},
-          ];
+        let ctx = canvas.getContext("2d");
+        ctx.drawImage(img, 0, 0);
 
-          for (let {x, y, color} of coords) {
-            let imageData = ctx.getImageData(x, y, 1, 1).data;
+        // Check the colors of the first and last pixels of the image, to make
+        // sure we capture the entire frame, and scale it correctly.
+        let coords = [
+          {x: 0, y: 0,
+           color: options.color},
+          {x: img.width - 1,
+           y: img.height - 1,
+           color: options.color},
+          {x: img.width / 2 | 0,
+           y: img.height / 2 | 0,
+           color: options.neutral},
+        ];
 
-            if (format == "png") {
-              browser.test.assertEq(`rgba(${color},255)`, `rgba(${[...imageData]})`, `${format} image color is correct at (${x}, ${y})`);
-            } else {
-              // Allow for some deviation in JPEG version due to lossy compression.
-              const SLOP = 3;
+        for (let {x, y, color} of coords) {
+          let imageData = ctx.getImageData(x, y, 1, 1).data;
 
-              browser.test.log(`Testing ${format} image color at (${x}, ${y}), have rgba(${[...imageData]}), expecting approx. rgba(${color},255)`);
+          if (format == "png") {
+            browser.test.assertEq(`rgba(${color},255)`, `rgba(${[...imageData]})`, `${format} image color is correct at (${x}, ${y})`);
+          } else {
+            // Allow for some deviation in JPEG version due to lossy compression.
+            const SLOP = 3;
 
-              browser.test.assertTrue(Math.abs(color[0] - imageData[0]) <= SLOP, `${format} image color.red is correct at (${x}, ${y})`);
-              browser.test.assertTrue(Math.abs(color[1] - imageData[1]) <= SLOP, `${format} image color.green is correct at (${x}, ${y})`);
-              browser.test.assertTrue(Math.abs(color[2] - imageData[2]) <= SLOP, `${format} image color.blue is correct at (${x}, ${y})`);
-              browser.test.assertEq(255, imageData[3], `${format} image color.alpha is correct at (${x}, ${y})`);
-            }
+            browser.test.log(`Testing ${format} image color at (${x}, ${y}), have rgba(${[...imageData]}), expecting approx. rgba(${color},255)`);
+
+            browser.test.assertTrue(Math.abs(color[0] - imageData[0]) <= SLOP, `${format} image color.red is correct at (${x}, ${y})`);
+            browser.test.assertTrue(Math.abs(color[1] - imageData[1]) <= SLOP, `${format} image color.green is correct at (${x}, ${y})`);
+            browser.test.assertTrue(Math.abs(color[2] - imageData[2]) <= SLOP, `${format} image color.blue is correct at (${x}, ${y})`);
+            browser.test.assertEq(255, imageData[3], `${format} image color.alpha is correct at (${x}, ${y})`);
           }
         }
+      }
 
-        browser.test.notifyPass("captureVisibleTab");
-      });
-    }).catch(e => {
+      browser.test.notifyPass("captureVisibleTab");
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFail("captureVisibleTab");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["<all_urls>"],
     },
 
     background: `(${background})(${JSON.stringify(options)})`,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
@@ -37,107 +37,89 @@ add_task(function* () {
 
     background: function() {
       function testTab(data, tab) {
         browser.test.assertTrue(data.success, "we want a success");
         browser.test.assertTrue(!!tab, "we have a tab");
         browser.test.assertEq(data.expectedCookieStoreId, tab.cookieStoreId, "tab should have the correct cookieStoreId");
       }
 
-      function runTest(data) {
-        // Tab Creation
-        browser.tabs.create({windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
-                             cookieStoreId: data.cookieStoreId})
+      async function runTest(data) {
+        try {
+          // Tab Creation
+          let tab = await browser.tabs.create({
+            windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
+            cookieStoreId: data.cookieStoreId,
+          }).then((tab) => {
+            // Tests for tab creation
+            testTab(data, tab);
+            return tab;
+          }, (error) => {
+            browser.test.assertTrue(!!data.failure, "we want a failure");
+            if (data.failure == "illegal") {
+              browser.test.assertTrue(/Illegal cookieStoreId/.test(error.message),
+                                      "runtime.lastError should report the expected error message");
+            } else if (data.failure == "defaultToPrivate") {
+              browser.test.assertTrue("Illegal to set private cookieStorageId in a non private window",
+                                      error.message,
+                                      "runtime.lastError should report the expected error message");
+            } else if (data.failure == "privateToDefault") {
+              browser.test.assertTrue("Illegal to set non private cookieStorageId in a private window",
+                                      error.message,
+                                      "runtime.lastError should report the expected error message");
+            } else if (data.failure == "exist") {
+              browser.test.assertTrue(/No cookie store exists/.test(error.message),
+                                      "runtime.lastError should report the expected error message");
+            } else {
+              browser.test.fail("The test is broken");
+            }
 
-        // Tests for tab creation
-        .then((tab) => {
-          testTab(data, tab);
-          return tab;
-        }, (error) => {
-          browser.test.assertTrue(!!data.failure, "we want a failure");
-          if (data.failure == "illegal") {
-            browser.test.assertTrue(/Illegal cookieStoreId/.test(error.message),
-                                    "runtime.lastError should report the expected error message");
-          } else if (data.failure == "defaultToPrivate") {
-            browser.test.assertTrue("Illegal to set private cookieStorageId in a non private window",
-                                    error.message,
-                                    "runtime.lastError should report the expected error message");
-          } else if (data.failure == "privateToDefault") {
-            browser.test.assertTrue("Illegal to set non private cookieStorageId in a private window",
-                                    error.message,
-                                    "runtime.lastError should report the expected error message");
-          } else if (data.failure == "exist") {
-            browser.test.assertTrue(/No cookie store exists/.test(error.message),
-                                    "runtime.lastError should report the expected error message");
-          } else {
-            browser.test.fail("The test is broken");
+            return null;
+          });
+
+          if (tab) {
+            {
+              // Tests for tab querying
+              let [tab] = await browser.tabs.query({
+                windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
+                cookieStoreId: data.cookieStoreId,
+              });
+
+              browser.test.assertTrue(tab != undefined, "Tab found!");
+              testTab(data, tab);
+            }
+
+            let stores = await browser.cookies.getAllCookieStores();
+
+            let store = stores.find(store => store.id === tab.cookieStoreId);
+            browser.test.assertTrue(!!store, "We have a store for this tab.");
+
+            await browser.tabs.remove(tab.id);
           }
 
-          return null;
-        })
-
-        // Tests for tab querying
-        .then((tab) => {
-          if (tab) {
-            return browser.tabs.query({windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
-                                       cookieStoreId: data.cookieStoreId})
-                   .then((tabs) => {
-                     browser.test.assertTrue(tabs.length >= 1, "Tab found!");
-                     testTab(data, tabs[0]);
-                     return tab;
-                   });
-          }
-        })
-
-        .then((tab) => {
-          if (tab) {
-            return browser.cookies.getAllCookieStores()
-                   .then(stores => {
-                     let store = stores.find(store => store.id === tab.cookieStoreId);
-                     browser.test.assertTrue(!!store, "We have a store for this tab.");
-                     return tab;
-                   });
-          }
-        })
-
-        .then((tab) => {
-          if (tab) {
-            return browser.tabs.remove(tab.id);
-          }
-        })
-
-        .then(() => {
           browser.test.sendMessage("test-done");
-        }, () => {
-          browser.test.fail("An exception has ben thrown");
-        });
+        } catch (e) {
+          browser.test.fail("An exception has been thrown");
+        }
       }
 
-      function initialize() {
-        browser.windows.create({incognito: true})
-        .then((win) => {
-          this.privateWindowId = win.id;
-          return browser.windows.create({incognito: false});
-        })
-        .then((win) => {
-          this.defaultWindowId = win.id;
-        })
-        .then(() => {
-          browser.test.sendMessage("ready");
-        });
+      async function initialize() {
+        let win = await browser.windows.create({incognito: true});
+        this.privateWindowId = win.id;
+
+        win = await browser.windows.create({incognito: false});
+        this.defaultWindowId = win.id;
+
+        browser.test.sendMessage("ready");
       }
 
-      function shutdown() {
-        browser.windows.remove(this.privateWindowId)
-        .then(() => {
-          browser.windows.remove(this.defaultWindowId);
-        })
-        .then(() => {
-          browser.test.sendMessage("gone");
-        });
+      async function shutdown() {
+        await browser.windows.remove(this.privateWindowId);
+        await browser.windows.remove(this.defaultWindowId);
+        browser.test.sendMessage("gone");
       }
 
       // Waiting for messages
       browser.test.onMessage.addListener((msg, data) => {
         if (msg == "be-ready") {
           initialize();
         } else if (msg == "test") {
           runTest(data);
--- a/browser/components/extensions/test/browser/browser_ext_tabs_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_create.js
@@ -85,17 +85,17 @@ add_task(function* () {
               result: {index: 1, active: false},
             },
             {
               create: {windowId: activeWindow},
               result: {windowId: activeWindow},
             },
           ];
 
-          function nextTest() {
+          async function nextTest() {
             if (!tests.length) {
               browser.test.notifyPass("tabs.create");
               return;
             }
 
             let test = tests.shift();
             let expected = Object.assign({}, DEFAULTS, test.result);
 
@@ -114,43 +114,39 @@ add_task(function* () {
             let createdPromise = new Promise(resolve => {
               let onCreated = tab => {
                 browser.test.assertTrue("id" in tab, `Expected tabs.onCreated callback to receive tab object`);
                 resolve();
               };
               browser.tabs.onCreated.addListener(onCreated);
             });
 
-            let tabId;
-            Promise.all([
+            let [tab] = await Promise.all([
               browser.tabs.create(test.create),
               createdPromise,
-            ]).then(([tab]) => {
-              tabId = tab.id;
+            ]);
+            let tabId = tab.id;
 
-              for (let key of Object.keys(expected)) {
-                if (key === "url") {
-                  // FIXME: This doesn't get updated until later in the load cycle.
-                  continue;
-                }
-
-                browser.test.assertEq(expected[key], tab[key], `Expected value for tab.${key}`);
+            for (let key of Object.keys(expected)) {
+              if (key === "url") {
+                // FIXME: This doesn't get updated until later in the load cycle.
+                continue;
               }
 
-              return updatedPromise;
-            }).then(updated => {
-              browser.test.assertEq(tabId, updated.tabId, `Expected value for tab.id`);
-              browser.test.assertEq(expected.url, updated.url, `Expected value for tab.url`);
+              browser.test.assertEq(expected[key], tab[key], `Expected value for tab.${key}`);
+            }
 
-              return browser.tabs.remove(tabId);
-            }).then(() => {
-              return browser.tabs.update(activeTab, {active: true});
-            }).then(() => {
-              nextTest();
-            });
+            let updated = await updatedPromise;
+            browser.test.assertEq(tabId, updated.tabId, `Expected value for tab.id`);
+            browser.test.assertEq(expected.url, updated.url, `Expected value for tab.url`);
+
+            await browser.tabs.remove(tabId);
+            await browser.tabs.update(activeTab, {active: true});
+
+            nextTest();
           }
 
           nextTest();
         }
 
         browser.tabs.query({active: true, currentWindow: true}, tabs => {
           activeTab = tabs[0].id;
           activeWindow = tabs[0].windowId;
--- a/browser/components/extensions/test/browser/browser_ext_tabs_detectLanguage.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_detectLanguage.js
@@ -3,48 +3,44 @@
 "use strict";
 
 add_task(function* testDetectLanguage() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
-    background() {
+    background: async function() {
       const BASE_PATH = "browser/browser/components/extensions/test/browser";
 
       function loadTab(url) {
         return browser.tabs.create({url});
       }
 
-      loadTab(`http://example.co.jp/${BASE_PATH}/file_language_ja.html`).then(tab => {
-        return browser.tabs.detectLanguage(tab.id).then(lang => {
-          browser.test.assertEq("ja", lang, "Japanese document should be detected as Japanese");
-          return browser.tabs.remove(tab.id);
-        });
-      }).then(() => {
-        return loadTab(`http://example.co.jp/${BASE_PATH}/file_language_fr_en.html`);
-      }).then(tab => {
-        return browser.tabs.detectLanguage(tab.id).then(lang => {
-          browser.test.assertEq("fr", lang, "French/English document should be detected as primarily French");
-          return browser.tabs.remove(tab.id);
-        });
-      }).then(() => {
-        return loadTab(`http://example.co.jp/${BASE_PATH}/file_language_tlh.html`);
-      }).then(tab => {
-        return browser.tabs.detectLanguage(tab.id).then(lang => {
-          browser.test.assertEq("und", lang, "Klingon document should not be detected, should return 'und'");
-          return browser.tabs.remove(tab.id);
-        });
-      }).then(() => {
+      try {
+        let tab = await loadTab(`http://example.co.jp/${BASE_PATH}/file_language_ja.html`);
+        let lang = await browser.tabs.detectLanguage(tab.id);
+        browser.test.assertEq("ja", lang, "Japanese document should be detected as Japanese");
+        await browser.tabs.remove(tab.id);
+
+        tab = await loadTab(`http://example.co.jp/${BASE_PATH}/file_language_fr_en.html`);
+        lang = await browser.tabs.detectLanguage(tab.id);
+        browser.test.assertEq("fr", lang, "French/English document should be detected as primarily French");
+        await browser.tabs.remove(tab.id);
+
+        tab = await loadTab(`http://example.co.jp/${BASE_PATH}/file_language_tlh.html`);
+        lang = await browser.tabs.detectLanguage(tab.id);
+        browser.test.assertEq("und", lang, "Klingon document should not be detected, should return 'und'");
+        await browser.tabs.remove(tab.id);
+
         browser.test.notifyPass("detectLanguage");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`Error: ${e} :: ${e.stack}`);
         browser.test.notifyFail("detectLanguage");
-      });
+      }
     },
   });
 
   yield extension.startup();
 
   yield extension.awaitFinish("detectLanguage");
 
   yield extension.unload();
--- a/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
@@ -36,17 +36,17 @@ add_task(function* testDuplicateTab() {
   yield extension.unload();
 
   while (gBrowser.tabs[0].linkedBrowser.currentURI.spec === "http://example.net/") {
     yield BrowserTestUtils.removeTab(gBrowser.tabs[0]);
   }
 });
 
 add_task(function* testDuplicateTabLazily() {
-  function background() {
+  async function background() {
     let tabLoadComplete = new Promise(resolve => {
       browser.test.onMessage.addListener((message, tabId, result) => {
         if (message == "duplicate-tab-done") {
           resolve(tabId);
         }
       });
     });
 
@@ -56,42 +56,38 @@ add_task(function* testDuplicateTabLazil
           if (tabId == tabId_ && changed.status == "complete") {
             browser.tabs.onUpdated.removeListener(listener);
             resolve();
           }
         });
       });
     }
 
-    let startTabId;
-    let url = "http://example.com/browser/browser/components/extensions/test/browser/file_dummy.html";
-    browser.tabs.create({url}, tab => {
-      startTabId = tab.id;
+    try {
+      let url = "http://example.com/browser/browser/components/extensions/test/browser/file_dummy.html";
+      let tab = await browser.tabs.create({url});
+      let startTabId = tab.id;
 
-      awaitLoad(startTabId).then(() => {
-        browser.test.sendMessage("duplicate-tab", startTabId);
+      await awaitLoad(startTabId);
+      browser.test.sendMessage("duplicate-tab", startTabId);
 
-        tabLoadComplete.then(unloadedTabId => {
-          browser.tabs.get(startTabId, loadedtab => {
-            browser.test.assertEq("Dummy test page", loadedtab.title, "Title should be returned for loaded pages");
-            browser.test.assertEq("complete", loadedtab.status, "Tab status should be complete for loaded pages");
-          });
+      let unloadedTabId = await tabLoadComplete;
+      let loadedtab = await browser.tabs.get(startTabId);
+      browser.test.assertEq("Dummy test page", loadedtab.title, "Title should be returned for loaded pages");
+      browser.test.assertEq("complete", loadedtab.status, "Tab status should be complete for loaded pages");
 
-          browser.tabs.get(unloadedTabId, unloadedtab => {
-            browser.test.assertEq("Dummy test page", unloadedtab.title, "Title should be returned after page has been unloaded");
-          });
+      let unloadedtab = await browser.tabs.get(unloadedTabId);
+      browser.test.assertEq("Dummy test page", unloadedtab.title, "Title should be returned after page has been unloaded");
 
-          browser.tabs.remove([tab.id, unloadedTabId]);
-          browser.test.notifyPass("tabs.hasCorrectTabTitle");
-        });
-      }).catch(e => {
-        browser.test.fail(`${e} :: ${e.stack}`);
-        browser.test.notifyFail("tabs.hasCorrectTabTitle");
-      });
-    });
+      await browser.tabs.remove([tab.id, unloadedTabId]);
+      browser.test.notifyPass("tabs.hasCorrectTabTitle");
+    } catch (e) {
+      browser.test.fail(`${e} :: ${e.stack}`);
+      browser.test.notifyFail("tabs.hasCorrectTabTitle");
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_events.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_events.js
@@ -1,14 +1,14 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testTabEvents() {
-  function background() {
+  async function background() {
     let events = [];
     browser.tabs.onCreated.addListener(tab => {
       events.push({type: "onCreated", tab});
     });
 
     browser.tabs.onAttached.addListener((tabId, info) => {
       events.push(Object.assign({type: "onAttached", tabId}, info));
     });
@@ -20,136 +20,131 @@ add_task(function* testTabEvents() {
     browser.tabs.onRemoved.addListener((tabId, info) => {
       events.push(Object.assign({type: "onRemoved", tabId}, info));
     });
 
     browser.tabs.onMoved.addListener((tabId, info) => {
       events.push(Object.assign({type: "onMoved", tabId}, info));
     });
 
-    function expectEvents(names) {
+    async function expectEvents(names) {
       browser.test.log(`Expecting events: ${names.join(", ")}`);
 
-      return new Promise(resolve => {
-        setTimeout(resolve, 0);
-      }).then(() => {
-        browser.test.assertEq(names.length, events.length, "Got expected number of events");
-        for (let [i, name] of names.entries()) {
-          browser.test.assertEq(name, i in events && events[i].type,
-                                `Got expected ${name} event`);
-        }
-        return events.splice(0);
-      });
+      await new Promise(resolve => setTimeout(resolve, 0));
+
+      browser.test.assertEq(names.length, events.length, "Got expected number of events");
+      for (let [i, name] of names.entries()) {
+        browser.test.assertEq(name, i in events && events[i].type,
+                              `Got expected ${name} event`);
+      }
+      return events.splice(0);
     }
 
-    browser.test.log("Create second browser window");
-    let windowId;
-    Promise.all([
-      browser.windows.getCurrent(),
-      browser.windows.create({url: "about:blank"}),
-    ]).then(windows => {
-      windowId = windows[0].id;
+    try {
+      browser.test.log("Create second browser window");
+
+      let windows = await Promise.all([
+        browser.windows.getCurrent(),
+        browser.windows.create({url: "about:blank"}),
+      ]);
+
+      let windowId = windows[0].id;
       let otherWindowId = windows[1].id;
-      let initialTab;
 
-      return expectEvents(["onCreated"]).then(([created]) => {
-        initialTab = created.tab;
+      let [created] = await expectEvents(["onCreated"]);
+      let initialTab = created.tab;
+
 
-        browser.test.log("Create tab in window 1");
-        return browser.tabs.create({windowId, index: 0, url: "about:blank"});
-      }).then(tab => {
-        let oldIndex = tab.index;
-        browser.test.assertEq(0, oldIndex, "Tab has the expected index");
+      browser.test.log("Create tab in window 1");
+      let tab = await browser.tabs.create({windowId, index: 0, url: "about:blank"});
+      let oldIndex = tab.index;
+      browser.test.assertEq(0, oldIndex, "Tab has the expected index");
+
+      [created] = await expectEvents(["onCreated"]);
+      browser.test.assertEq(tab.id, created.tab.id, "Got expected tab ID");
+      browser.test.assertEq(oldIndex, created.tab.index, "Got expected tab index");
+
 
-        return expectEvents(["onCreated"]).then(([created]) => {
-          browser.test.assertEq(tab.id, created.tab.id, "Got expected tab ID");
-          browser.test.assertEq(oldIndex, created.tab.index, "Got expected tab index");
+      browser.test.log("Move tab to window 2");
+      await browser.tabs.move([tab.id], {windowId: otherWindowId, index: 0});
 
-          browser.test.log("Move tab to window 2");
-          return browser.tabs.move([tab.id], {windowId: otherWindowId, index: 0});
-        }).then(() => {
-          return expectEvents(["onDetached", "onAttached"]);
-        }).then(([detached, attached]) => {
-          browser.test.assertEq(oldIndex, detached.oldPosition, "Expected old index");
-          browser.test.assertEq(windowId, detached.oldWindowId, "Expected old window ID");
+      let [detached, attached] = await expectEvents(["onDetached", "onAttached"]);
+      browser.test.assertEq(oldIndex, detached.oldPosition, "Expected old index");
+      browser.test.assertEq(windowId, detached.oldWindowId, "Expected old window ID");
+
+      browser.test.assertEq(0, attached.newPosition, "Expected new index");
+      browser.test.assertEq(otherWindowId, attached.newWindowId, "Expected new window ID");
+
 
-          browser.test.assertEq(0, attached.newPosition, "Expected new index");
-          browser.test.assertEq(otherWindowId, attached.newWindowId, "Expected new window ID");
+      browser.test.log("Move tab within the same window");
+      let [moved] = await browser.tabs.move([tab.id], {index: 1});
+      browser.test.assertEq(1, moved.index, "Expected new index");
+
+      [moved] = await expectEvents(["onMoved"]);
+      browser.test.assertEq(tab.id, moved.tabId, "Expected tab ID");
+      browser.test.assertEq(0, moved.fromIndex, "Expected old index");
+      browser.test.assertEq(1, moved.toIndex, "Expected new index");
+      browser.test.assertEq(otherWindowId, moved.windowId, "Expected window ID");
 
-          browser.test.log("Move tab within the same window");
-          return browser.tabs.move([tab.id], {index: 1});
-        }).then(([moved]) => {
-          browser.test.assertEq(1, moved.index, "Expected new index");
+
+      browser.test.log("Remove tab");
+      await browser.tabs.remove(tab.id);
+      let [removed] = await expectEvents(["onRemoved"]);
 
-          return expectEvents(["onMoved"]);
-        }).then(([moved]) => {
-          browser.test.assertEq(tab.id, moved.tabId, "Expected tab ID");
-          browser.test.assertEq(0, moved.fromIndex, "Expected old index");
-          browser.test.assertEq(1, moved.toIndex, "Expected new index");
-          browser.test.assertEq(otherWindowId, moved.windowId, "Expected window ID");
+      browser.test.assertEq(tab.id, removed.tabId, "Expected removed tab ID");
+      browser.test.assertEq(otherWindowId, removed.windowId, "Expected removed tab window ID");
+      // Note: We want to test for the actual boolean value false here.
+      browser.test.assertEq(false, removed.isWindowClosing, "Expected isWindowClosing value");
+
 
-          browser.test.log("Remove tab");
-          return browser.tabs.remove(tab.id);
-        }).then(() => {
-          return expectEvents(["onRemoved"]);
-        }).then(([removed]) => {
-          browser.test.assertEq(tab.id, removed.tabId, "Expected removed tab ID");
-          browser.test.assertEq(otherWindowId, removed.windowId, "Expected removed tab window ID");
-          // Note: We want to test for the actual boolean value false here.
-          browser.test.assertEq(false, removed.isWindowClosing, "Expected isWindowClosing value");
+      browser.test.log("Close second window");
+      await browser.windows.remove(otherWindowId);
+      [removed] = await expectEvents(["onRemoved"]);
+      browser.test.assertEq(initialTab.id, removed.tabId, "Expected removed tab ID");
+      browser.test.assertEq(otherWindowId, removed.windowId, "Expected removed tab window ID");
+      browser.test.assertEq(true, removed.isWindowClosing, "Expected isWindowClosing value");
+
 
-          browser.test.log("Close second window");
-          return browser.windows.remove(otherWindowId);
-        }).then(() => {
-          return expectEvents(["onRemoved"]);
-        }).then(([removed]) => {
-          browser.test.assertEq(initialTab.id, removed.tabId, "Expected removed tab ID");
-          browser.test.assertEq(otherWindowId, removed.windowId, "Expected removed tab window ID");
-          browser.test.assertEq(true, removed.isWindowClosing, "Expected isWindowClosing value");
+      browser.test.log("Create additional tab in window 1");
+      tab = await browser.tabs.create({windowId, url: "about:blank"});
+      await expectEvents(["onCreated"]);
+
+
+      browser.test.log("Create a new window, adopting the new tab");
+      // We have to explicitly wait for the event here, since its timing is
+      // not predictable.
+      let promiseAttached = new Promise(resolve => {
+        browser.tabs.onAttached.addListener(function listener(tabId) {
+          browser.tabs.onAttached.removeListener(listener);
+          resolve();
         });
       });
-    }).then(() => {
-      browser.test.log("Create additional tab in window 1");
-      return browser.tabs.create({windowId, url: "about:blank"});
-    }).then(tab => {
-      return expectEvents(["onCreated"]).then(() => {
-        browser.test.log("Create a new window, adopting the new tab");
 
-        // We have to explicitly wait for the event here, since its timing is
-        // not predictable.
-        let promiseAttached = new Promise(resolve => {
-          browser.tabs.onAttached.addListener(function listener(tabId) {
-            browser.tabs.onAttached.removeListener(listener);
-            resolve();
-          });
-        });
+      let [window] = await Promise.all([
+        browser.windows.create({tabId: tab.id}),
+        promiseAttached,
+      ]);
+
+      [detached, attached] = await expectEvents(["onDetached", "onAttached"]);
+
+      browser.test.assertEq(tab.id, detached.tabId, "Expected onDetached tab ID");
 
-        return Promise.all([
-          browser.windows.create({tabId: tab.id}),
-          promiseAttached,
-        ]);
-      }).then(([window]) => {
-        return expectEvents(["onDetached", "onAttached"]).then(([detached, attached]) => {
-          browser.test.assertEq(tab.id, detached.tabId, "Expected onDetached tab ID");
+      browser.test.assertEq(tab.id, attached.tabId, "Expected onAttached tab ID");
+      browser.test.assertEq(0, attached.newPosition, "Expected onAttached new index");
+      browser.test.assertEq(window.id, attached.newWindowId,
+                            "Expected onAttached new window id");
 
-          browser.test.assertEq(tab.id, attached.tabId, "Expected onAttached tab ID");
-          browser.test.assertEq(0, attached.newPosition, "Expected onAttached new index");
-          browser.test.assertEq(window.id, attached.newWindowId,
-                                "Expected onAttached new window id");
+      browser.test.log("Close the new window");
+      await browser.windows.remove(window.id);
 
-          browser.test.log("Close the new window");
-          return browser.windows.remove(window.id);
-        });
-      });
-    }).then(() => {
       browser.test.notifyPass("tabs-events");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`${e} :: ${e.stack}`);
       browser.test.notifyFail("tabs-events");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
@@ -171,26 +166,24 @@ add_task(function* testTabEventsSize() {
     });
 
     browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
       if (changeInfo.status == "complete") {
         sendSizeMessages(tab, "on-updated");
       }
     });
 
-    browser.test.onMessage.addListener((msg, arg) => {
+    browser.test.onMessage.addListener(async (msg, arg) => {
       if (msg === "create-tab") {
-        browser.tabs.create({url: "http://example.com/"}).then(tab => {
-          sendSizeMessages(tab, "create");
-          browser.test.sendMessage("created-tab-id", tab.id);
-        });
+        let tab = await browser.tabs.create({url: "http://example.com/"});
+        sendSizeMessages(tab, "create");
+        browser.test.sendMessage("created-tab-id", tab.id);
       } else if (msg === "update-tab") {
-        browser.tabs.update(arg, {url: "http://example.org/"}).then(tab => {
-          sendSizeMessages(tab, "update");
-        });
+        let tab = await browser.tabs.update(arg, {url: "http://example.org/"});
+        sendSizeMessages(tab, "update");
       } else if (msg === "remove-tab") {
         browser.tabs.remove(arg);
         browser.test.sendMessage("tab-removed");
       }
     });
 
     browser.test.sendMessage("ready");
   }
@@ -233,19 +226,17 @@ add_task(function* testTabEventsSize() {
     yield extension.awaitMessage("tab-removed");
   }
 
   yield extension.unload();
   SpecialPowers.clearUserPref(RESOLUTION_PREF);
 });
 
 add_task(function* testTabRemovalEvent() {
-  function background() {
-    let removalTabId;
-
+  async function background() {
     function awaitLoad(tabId) {
       return new Promise(resolve => {
         browser.tabs.onUpdated.addListener(function listener(tabId_, changed, tab) {
           if (tabId == tabId_ && changed.status == "complete") {
             browser.tabs.onUpdated.removeListener(listener);
             resolve();
           }
         });
@@ -257,27 +248,26 @@ add_task(function* testTabRemovalEvent()
       chrome.tabs.query({}, tabs => {
         for (let tab of tabs) {
           browser.test.assertTrue(tab.id != tabId, "Tab query should not include removed tabId");
         }
         browser.test.notifyPass("tabs-events");
       });
     });
 
-    let url = "http://example.com/browser/browser/components/extensions/test/browser/context.html";
-    browser.tabs.create({url: url})
-    .then(tab => {
-      removalTabId = tab.id;
-      return awaitLoad(tab.id);
-    }).then(() => {
-      return browser.tabs.remove(removalTabId);
-    }).catch(e => {
+    try {
+      let url = "http://example.com/browser/browser/components/extensions/test/browser/context.html";
+      let tab = await browser.tabs.create({url: url});
+      await awaitLoad(tab.id);
+
+      await browser.tabs.remove(tab.id);
+    } catch (e) {
       browser.test.fail(`${e} :: ${e.stack}`);
       browser.test.notifyFail("tabs-events");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js
@@ -31,22 +31,23 @@ add_task(function* testExecuteScript() {
 
   let messageManagersSize = countMM(MessageChannel.messageManagers);
   let responseManagersSize = countMM(MessageChannel.responseManagers);
 
   const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
   const URL = BASE + "file_iframe_document.html";
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, URL, true);
 
-  function background() {
-    browser.tabs.query({active: true, currentWindow: true}).then(tabs => {
-      return browser.webNavigation.getAllFrames({tabId: tabs[0].id});
-    }).then(frames => {
+  async function background() {
+    try {
+      let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+      let frames = await browser.webNavigation.getAllFrames({tabId: tab.id});
+
       browser.test.log(`FRAMES: ${frames[1].frameId} ${JSON.stringify(frames)}\n`);
-      return Promise.all([
+      await Promise.all([
         browser.tabs.executeScript({
           code: "42",
         }).then(result => {
           browser.test.assertEq(1, result.length, "Expected one callback result");
           browser.test.assertEq(42, result[0], "Expected callback result");
         }),
 
         browser.tabs.executeScript({
@@ -122,30 +123,30 @@ add_task(function* testExecuteScript() {
           let details = {
             frame_id: Number.MAX_SAFE_INTEGER,
             matchesHost: ["http://mochi.test/", "http://example.com/"],
           };
           browser.test.assertEq(`No window matching ${JSON.stringify(details)}`,
                                 error.message, "Got expected error");
         }),
 
-        browser.tabs.create({url: "http://example.net/", active: false}).then(tab => {
-          return browser.tabs.executeScript(tab.id, {
+        browser.tabs.create({url: "http://example.net/", active: false}).then(async tab => {
+          await browser.tabs.executeScript(tab.id, {
             code: "42",
           }).then(result => {
             browser.test.fail("Expected error when trying to execute on invalid domain");
           }, error => {
             let details = {
               matchesHost: ["http://mochi.test/", "http://example.com/"],
             };
             browser.test.assertEq(`No window matching ${JSON.stringify(details)}`,
                                   error.message, "Got expected error");
-          }).then(() => {
-            return browser.tabs.remove(tab.id);
           });
+
+          await browser.tabs.remove(tab.id);
         }),
 
         browser.tabs.executeScript({
           code: "Promise.resolve(42)",
         }).then(result => {
           browser.test.assertEq(42, result[0], "Got expected promise resolution value as result");
         }),
 
@@ -173,37 +174,37 @@ add_task(function* testExecuteScript() {
         browser.tabs.executeScript({
           code: "location.href;",
           frameId: frames[1].frameId,
         }).then(result => {
           browser.test.assertEq(1, result.length, "Expected one result");
           browser.test.assertEq("http://mochi.test:8888/", result[0], "Result for frameId[1] is correct");
         }),
 
-        browser.tabs.create({url: "http://example.com/"}).then(tab => {
-          return browser.tabs.executeScript(tab.id, {code: "location.href"}).then(result => {
-            browser.test.assertEq("http://example.com/", result[0], "Script executed correctly in new tab");
+        browser.tabs.create({url: "http://example.com/"}).then(async tab => {
+          let result = await browser.tabs.executeScript(tab.id, {code: "location.href"});
 
-            return browser.tabs.remove(tab.id);
-          });
+          browser.test.assertEq("http://example.com/", result[0], "Script executed correctly in new tab");
+
+          await browser.tabs.remove(tab.id);
         }),
 
         new Promise(resolve => {
           browser.runtime.onMessage.addListener(message => {
             browser.test.assertEq("script ran", message, "Expected runtime message");
             resolve();
           });
         }),
       ]);
-    }).then(() => {
+
       browser.test.notifyPass("executeScript");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFail("executeScript");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["http://mochi.test/", "http://example.com/", "webNavigation"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
@@ -1,16 +1,16 @@
 "use strict";
 
 // This is a pretty terrible hack, but it's the best we can do until we
 // support |executeScript| callbacks and |lastError|.
 function* testHasNoPermission(params) {
   let contentSetup = params.contentSetup || (() => Promise.resolve());
 
-  function background(contentSetup) {
+  async function background(contentSetup) {
     browser.runtime.onMessage.addListener((msg, sender) => {
       browser.test.assertEq(msg, "second script ran", "second script ran");
       browser.test.notifyPass("executeScript");
     });
 
     browser.test.onMessage.addListener(msg => {
       browser.test.assertEq(msg, "execute-script");
 
@@ -25,19 +25,19 @@ function* testHasNoPermission(params) {
         // it, but it's just about the best we can do until we
         // support callbacks for executeScript.
         browser.tabs.executeScript(tabs[1].id, {
           file: "second-script.js",
         });
       });
     });
 
-    contentSetup().then(() => {
-      browser.test.sendMessage("ready");
-    });
+    await contentSetup();
+
+    browser.test.sendMessage("ready");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: params.manifest,
 
     background: `(${background})(${contentSetup})`,
 
     files: {
@@ -127,83 +127,76 @@ add_task(function* testBadPermissions() 
   });
 
   info("Test active tab, page action, no click");
   yield testHasNoPermission({
     manifest: {
       "permissions": ["http://example.com/", "activeTab"],
       "page_action": {},
     },
-    contentSetup() {
-      return new Promise(resolve => {
-        browser.tabs.query({active: true, currentWindow: true}, tabs => {
-          browser.pageAction.show(tabs[0].id).then(() => {
-            resolve();
-          });
-        });
-      });
+    async contentSetup() {
+      let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+      await browser.pageAction.show(tab.id);
     },
   });
 
   yield BrowserTestUtils.removeTab(tab2);
   yield BrowserTestUtils.removeTab(tab1);
 });
 
 add_task(function* testBadURL() {
-  function background() {
-    browser.tabs.query({currentWindow: true}, tabs => {
-      let promises = [
-        new Promise(resolve => {
-          browser.tabs.executeScript({
-            file: "http://example.com/script.js",
-          }, result => {
-            browser.test.assertEq(undefined, result, "Result value");
-
-            browser.test.assertTrue(browser.extension.lastError instanceof Error,
-                                    "runtime.lastError is Error");
-
-            browser.test.assertTrue(browser.runtime.lastError instanceof Error,
-                                    "runtime.lastError is Error");
-
-            browser.test.assertEq(
-              "Files to be injected must be within the extension",
-              browser.extension.lastError && browser.extension.lastError.message,
-              "extension.lastError value");
-
-            browser.test.assertEq(
-              "Files to be injected must be within the extension",
-              browser.runtime.lastError && browser.runtime.lastError.message,
-              "runtime.lastError value");
-
-            resolve();
-          });
-        }),
-
+  async function background() {
+    let promises = [
+      new Promise(resolve => {
         browser.tabs.executeScript({
           file: "http://example.com/script.js",
-        }).catch(error => {
-          browser.test.assertTrue(error instanceof Error, "Error is Error");
+        }, result => {
+          browser.test.assertEq(undefined, result, "Result value");
+
+          browser.test.assertTrue(browser.extension.lastError instanceof Error,
+                                  "runtime.lastError is Error");
 
-          browser.test.assertEq(null, browser.extension.lastError,
-                                "extension.lastError value");
+          browser.test.assertTrue(browser.runtime.lastError instanceof Error,
+                                  "runtime.lastError is Error");
 
-          browser.test.assertEq(null, browser.runtime.lastError,
-                                "runtime.lastError value");
+          browser.test.assertEq(
+            "Files to be injected must be within the extension",
+            browser.extension.lastError && browser.extension.lastError.message,
+            "extension.lastError value");
 
           browser.test.assertEq(
             "Files to be injected must be within the extension",
-            error && error.message,
-            "error value");
-        }),
-      ];
+            browser.runtime.lastError && browser.runtime.lastError.message,
+            "runtime.lastError value");
+
+          resolve();
+        });
+      }),
+
+      browser.tabs.executeScript({
+        file: "http://example.com/script.js",
+      }).catch(error => {
+        browser.test.assertTrue(error instanceof Error, "Error is Error");
 
-      Promise.all(promises).then(() => {
-        browser.test.notifyPass("executeScript-lastError");
-      });
-    });
+        browser.test.assertEq(null, browser.extension.lastError,
+                              "extension.lastError value");
+
+        browser.test.assertEq(null, browser.runtime.lastError,
+                              "runtime.lastError value");
+
+        browser.test.assertEq(
+          "Files to be injected must be within the extension",
+          error && error.message,
+          "error value");
+      }),
+    ];
+
+    await Promise.all(promises);
+
+    browser.test.notifyPass("executeScript-lastError");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["<all_urls>"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
@@ -2,33 +2,33 @@
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 requestLongerTimeout(2);
 
 function* testHasPermission(params) {
   let contentSetup = params.contentSetup || (() => Promise.resolve());
 
-  function background(contentSetup) {
+  async function background(contentSetup) {
     browser.runtime.onMessage.addListener((msg, sender) => {
       browser.test.assertEq(msg, "script ran", "script ran");
       browser.test.notifyPass("executeScript");
     });
 
     browser.test.onMessage.addListener(msg => {
       browser.test.assertEq(msg, "execute-script");
 
       browser.tabs.executeScript({
         file: "script.js",
       });
     });
 
-    contentSetup().then(() => {
-      browser.test.sendMessage("ready");
-    });
+    await contentSetup();
+
+    browser.test.sendMessage("ready");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: params.manifest,
 
     background: `(${background})(${contentSetup})`,
 
     files: {
@@ -117,57 +117,46 @@ add_task(function* testGoodPermissions()
   });
 
   info("Test activeTab permission with a page action click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab"],
       "page_action": {},
     },
-    contentSetup() {
-      return new Promise(resolve => {
-        browser.tabs.query({active: true, currentWindow: true}, tabs => {
-          browser.pageAction.show(tabs[0].id).then(() => {
-            resolve();
-          });
-        });
-      });
+    contentSetup: async () => {
+      let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+      await browser.pageAction.show(tab.id);
     },
     setup: clickPageAction,
     tearDown: closePageAction,
   });
 
   info("Test activeTab permission with a browser action w/popup click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab"],
       "browser_action": {"default_popup": "_blank.html"},
     },
-    setup: extension => {
-      return clickBrowserAction(extension).then(() => {
-        return awaitExtensionPanel(extension, window, "_blank.html");
-      });
+    setup: async extension => {
+      await clickBrowserAction(extension);
+      return awaitExtensionPanel(extension, window, "_blank.html");
     },
     tearDown: closeBrowserAction,
   });
 
   info("Test activeTab permission with a page action w/popup click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab"],
       "page_action": {"default_popup": "_blank.html"},
     },
-    contentSetup() {
-      return new Promise(resolve => {
-        browser.tabs.query({active: true, currentWindow: true}, tabs => {
-          browser.pageAction.show(tabs[0].id).then(() => {
-            resolve();
-          });
-        });
-      });
+    contentSetup: async () => {
+      let [tab] = await browser.tabs.query({active: true, currentWindow: true});
+      await browser.pageAction.show(tab.id);
     },
     setup: clickPageAction,
     tearDown: closePageAction,
   });
 
   info("Test activeTab permission with a context menu click");
   yield testHasPermission({
     manifest: {
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_runAt.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_runAt.js
@@ -12,91 +12,86 @@
  *
  * And since we can't actually rely on that timing, it retries any attempts that
  * fail to load as early as expected, but don't load at any illegal time.
  */
 
 add_task(function* testExecuteScript() {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", true);
 
-  function background() {
+  async function background() {
     let tab;
 
     const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
     const URL = BASE + "file_iframe_document.sjs";
 
     const MAX_TRIES = 10;
-    let tries = 0;
+
+    try {
+      [tab] = await browser.tabs.query({active: true, currentWindow: true});
 
-    function again() {
-      if (tries++ == MAX_TRIES) {
-        return Promise.reject(new Error("Max tries exceeded"));
-      }
-
-      let url = `${URL}?r=${Math.random()}`;
+      let success = false;
+      for (let tries = 0; !success && tries < MAX_TRIES; tries++) {
+        let url = `${URL}?r=${Math.random()}`;
 
-      let loadingPromise = new Promise(resolve => {
-        browser.tabs.onUpdated.addListener(function listener(tabId, changed, tab_) {
-          if (tabId == tab.id && changed.status == "loading" && tab_.url == url) {
-            browser.tabs.onUpdated.removeListener(listener);
-            resolve();
-          }
+        let loadingPromise = new Promise(resolve => {
+          browser.tabs.onUpdated.addListener(function listener(tabId, changed, tab_) {
+            if (tabId == tab.id && changed.status == "loading" && tab_.url == url) {
+              browser.tabs.onUpdated.removeListener(listener);
+              resolve();
+            }
+          });
         });
-      });
 
-      // TODO: Test allFrames and frameId.
+        // TODO: Test allFrames and frameId.
 
-      return browser.tabs.update({url}).then(() => {
-        return loadingPromise;
-      }).then(() => {
-        return Promise.all([
+        await browser.tabs.update({url});
+        await loadingPromise;
+
+        let states = await Promise.all([
           // Send the executeScript requests in the reverse order that we expect
           // them to execute in, to avoid them passing only because of timing
           // races.
           browser.tabs.executeScript({
             code: "document.readyState",
             runAt: "document_idle",
           }),
           browser.tabs.executeScript({
             code: "document.readyState",
             runAt: "document_end",
           }),
           browser.tabs.executeScript({
             code: "document.readyState",
             runAt: "document_start",
           }),
         ].reverse());
-      }).then(states => {
+
         browser.test.log(`Got states: ${states}`);
 
         // Make sure that none of our scripts executed earlier than expected,
         // regardless of retries.
         browser.test.assertTrue(states[1] == "interactive" || states[1] == "complete",
                                 `document_end state is valid: ${states[1]}`);
         browser.test.assertTrue(states[2] == "complete",
                                 `document_idle state is valid: ${states[2]}`);
 
         // If we have the earliest valid states for each script, we're done.
         // Otherwise, try again.
-        if (states[0] != "loading" || states[1] != "interactive" || states[2] != "complete") {
-          return again();
-        }
-      });
-    }
+        success = (states[0] == "loading" &&
+                   states[1] == "interactive" &&
+                   states[2] == "complete");
+      }
 
-    browser.tabs.query({active: true, currentWindow: true}).then(tabs => {
-      tab = tabs[0];
+      browser.test.assertTrue(success, "Got the earliest expected states at least once");
 
-      return again();
-    }).then(() => {
       browser.test.notifyPass("executeScript-runAt");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFail("executeScript-runAt");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["http://mochi.test/", "tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js
@@ -5,18 +5,18 @@
 add_task(function* testExecuteScript() {
   let {MessageChannel} = Cu.import("resource://gre/modules/MessageChannel.jsm", {});
 
   let messageManagersSize = MessageChannel.messageManagers.size;
   let responseManagersSize = MessageChannel.responseManagers.size;
 
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/", true);
 
-  function background() {
-    let promises = [
+  async function background() {
+    let tasks = [
       {
         background: "transparent",
         foreground: "rgb(0, 113, 4)",
         promise: () => {
           return browser.tabs.insertCSS({
             file: "file2.css",
           });
         },
@@ -32,41 +32,35 @@ add_task(function* testExecuteScript() {
       },
     ];
 
     function checkCSS() {
       let computedStyle = window.getComputedStyle(document.body);
       return [computedStyle.backgroundColor, computedStyle.color];
     }
 
-    function next() {
-      if (!promises.length) {
-        return;
-      }
+    try {
+      for (let {promise, background, foreground} of tasks) {
+        let result = await promise();
 
-      let {promise, background, foreground} = promises.shift();
-      return promise().then(result => {
         browser.test.assertEq(undefined, result, "Expected callback result");
 
-        return browser.tabs.executeScript({
+        [result] = await browser.tabs.executeScript({
           code: `(${checkCSS})()`,
         });
-      }).then(([result]) => {
+
         browser.test.assertEq(background, result[0], "Expected background color");
         browser.test.assertEq(foreground, result[1], "Expected foreground color");
-        return next();
-      });
-    }
+      }
 
-    next().then(() => {
       browser.test.notifyPass("insertCSS");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFailure("insertCSS");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["http://mochi.test/"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_move.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_move.js
@@ -60,39 +60,32 @@ add_task(function* () {
   yield extension.awaitFinish("tabs.move.multiple");
   yield extension.unload();
 
   extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
-    background: function() {
-      browser.tabs.query(
-        {lastFocusedWindow: true},
+    async background() {
+      let [, tab] = await browser.tabs.query({lastFocusedWindow: true});
+
+      // Assuming that tab.id of 12345 does not exist.
+      await browser.tabs.move([tab.id, 12345], {index: 0}).then(
         tabs => {
-          let tab = tabs[1];
-          // Assuming that tab.id of 12345 does not exist.
-          browser.tabs.move([tab.id, 12345], {index: 0})
-          .then(
-            tabs => { browser.test.fail("Promise should not resolve"); },
-            e => {
-              browser.test.assertTrue(/Invalid tab/.test(e),
-                                      "Invalid tab should be in error");
-            })
-          .then(
-            browser.tabs.query({lastFocusedWindow: true})
-            .then(
-              (tabs) => {
-                browser.test.assertEq(tabs[1].url, tab.url, "should be second tab");
-                browser.test.notifyPass("tabs.move.invalid");
-              }
-            )
-          );
+          browser.test.fail("Promise should not resolve");
+        },
+        e => {
+          browser.test.assertTrue(/Invalid tab/.test(e),
+                                  "Invalid tab should be in error");
         });
+
+      let tabs = await browser.tabs.query({lastFocusedWindow: true});
+      browser.test.assertEq(tabs[1].url, tab.url, "should be second tab");
+      browser.test.notifyPass("tabs.move.invalid");
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.move.invalid");
   yield extension.unload();
 
   extension = ExtensionTestUtils.loadExtension({
--- a/browser/components/extensions/test/browser/browser_ext_tabs_move_window.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_move_window.js
@@ -7,42 +7,37 @@ add_task(function* () {
   let window1 = yield BrowserTestUtils.openNewBrowserWindow();
   yield BrowserTestUtils.openNewForegroundTab(window1.gBrowser, "http://example.com/");
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
-    background: function() {
-      browser.tabs.query({
-        url: "<all_urls>",
-      }, function(tabs) {
-        let destination = tabs[0];
-        let source = tabs[1]; // skip over about:blank in window1
-        browser.tabs.move(source.id, {windowId: destination.windowId, index: 0});
+    async background() {
+      let tabs = await browser.tabs.query({url: "<all_urls>"});
+      let destination = tabs[0];
+      let source = tabs[1]; // skip over about:blank in window1
 
-        browser.tabs.query(
-          {url: "<all_urls>"},
-          tabs => {
-            browser.test.assertEq(tabs[0].url, "http://example.com/");
-            browser.test.assertEq(tabs[0].windowId, destination.windowId);
-            browser.test.notifyPass("tabs.move.window");
-          });
+      // Assuming that this windowId does not exist.
+      await browser.tabs.move(source.id, {windowId: 123144576, index: 0}).then(
+        tabs => {
+          browser.test.fail("Promise should not resolve");
+        },
+        e => {
+          browser.test.assertTrue(/Invalid window/.test(e),
+                                  "Invalid window should be in error");
+        });
 
-        // Assuming that this windowId does not exist.
-        browser.tabs.move(source.id, {windowId: 123144576, index: 0})
-        .then(
-          tabs => { browser.test.fail("Promise should not resolve"); },
-          e => {
-            browser.test.assertTrue(/Invalid window/.test(e),
-                                    "Invalid window should be in error");
-          }
-        );
-      });
+      browser.tabs.move(source.id, {windowId: destination.windowId, index: 0});
+
+      tabs = await browser.tabs.query({url: "<all_urls>"});
+      browser.test.assertEq(tabs[0].url, "http://example.com/");
+      browser.test.assertEq(tabs[0].windowId, destination.windowId);
+      browser.test.notifyPass("tabs.move.window");
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.move.window");
   yield extension.unload();
 
   for (let tab of window.gBrowser.tabs) {
@@ -61,33 +56,33 @@ add_task(function* test_currentWindowAft
             browser.test.sendMessage("id", win.id);
           });
         }
       });
       browser.test.sendMessage("ready");
     },
   };
 
-  function background() {
+  async function background() {
     let tabId;
+
     const url = browser.extension.getURL("current.html");
-    browser.tabs.create({url}).then(tab => {
-      tabId = tab.id;
-    });
-    browser.test.onMessage.addListener(msg => {
+
+    browser.test.onMessage.addListener(async msg => {
       if (msg === "move") {
-        browser.windows.create({tabId}).then(() => {
-          browser.test.sendMessage("moved");
-        });
+        await browser.windows.create({tabId});
+        browser.test.sendMessage("moved");
       } else if (msg === "close") {
-        browser.tabs.remove(tabId).then(() => {
-          browser.test.sendMessage("done");
-        });
+        await browser.tabs.remove(tabId);
+        browser.test.sendMessage("done");
       }
     });
+
+    let tab = await browser.tabs.create({url});
+    tabId = tab.id;
   }
 
   const extension = ExtensionTestUtils.loadExtension({files, background});
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
 
   extension.sendMessage("current");
--- a/browser/components/extensions/test/browser/browser_ext_tabs_onHighlighted.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_onHighlighted.js
@@ -1,14 +1,14 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testTabEvents() {
-  function background() {
+  async function background() {
     /** The list of active tab ID's */
     let tabIds = [];
 
     /**
      * Stores the events that fire for each tab.
      *
      * events {
      *   tabId1: [event1, event2, ...],
@@ -34,89 +34,87 @@ add_task(function* testTabEvents() {
     });
 
     /**
      * Asserts that the expected events are fired for the tab with id = tabId.
      * The events associated to the specified tab are removed after this check is made.
      *
      * @param {number} tabId
      * @param {Array<string>} expectedEvents
-     * @returns {Promise}
      */
-    function expectEvents(tabId, expectedEvents) {
+    async function expectEvents(tabId, expectedEvents) {
       browser.test.log(`Expecting events: ${expectedEvents.join(", ")}`);
 
-      return new Promise(resolve => {
-        setTimeout(resolve, 0);
-      }).then(() => {
-        browser.test.assertEq(expectedEvents.length, events[tabId].length,
-         `Got expected number of events for ${tabId}`);
-        for (let [i, name] of expectedEvents.entries()) {
-          browser.test.assertEq(name, i in events[tabId] && events[tabId][i],
-                                `Got expected ${name} event`);
-        }
-        delete events[tabId];
-      });
+      await new Promise(resolve => setTimeout(resolve, 0));
+
+      browser.test.assertEq(expectedEvents.length, events[tabId].length,
+                            `Got expected number of events for ${tabId}`);
+
+      for (let [i, name] of expectedEvents.entries()) {
+        browser.test.assertEq(name, i in events[tabId] && events[tabId][i],
+                              `Got expected ${name} event`);
+      }
+      delete events[tabId];
     }
 
     /**
      * Opens a new tab and asserts that the correct events are fired.
      *
      * @param {number} windowId
-     * @returns {Promise}
      */
-    function openTab(windowId) {
-      return browser.tabs.create({windowId}).then(tab => {
-        tabIds.push(tab.id);
-        browser.test.log(`Opened tab ${tab.id}`);
-        return expectEvents(tab.id, [
-          "onActivated",
-          "onHighlighted",
-        ]);
-      });
+    async function openTab(windowId) {
+      let tab = await browser.tabs.create({windowId});
+
+      tabIds.push(tab.id);
+      browser.test.log(`Opened tab ${tab.id}`);
+
+      await expectEvents(tab.id, [
+        "onActivated",
+        "onHighlighted",
+      ]);
     }
 
     /**
      * Highlights an existing tab and asserts that the correct events are fired.
      *
      * @param {number} tabId
-     * @returns {Promise}
      */
-    function highlightTab(tabId) {
+    async function highlightTab(tabId) {
       browser.test.log(`Highlighting tab ${tabId}`);
-      return browser.tabs.update(tabId, {active: true}).then(tab => {
-        browser.test.assertEq(tab.id, tabId, `Tab ${tab.id} highlighted`);
-        return expectEvents(tab.id, [
-          "onActivated",
-          "onHighlighted",
-        ]);
-      });
+      let tab = await browser.tabs.update(tabId, {active: true});
+
+      browser.test.assertEq(tab.id, tabId, `Tab ${tab.id} highlighted`);
+
+      await expectEvents(tab.id, [
+        "onActivated",
+        "onHighlighted",
+      ]);
     }
 
     /**
      * The main entry point to the tests.
      */
-    browser.tabs.query({active: true, currentWindow: true}, tabs => {
-      let activeWindow = tabs[0].windowId;
-      Promise.all([
-        openTab(activeWindow),
-        openTab(activeWindow),
-        openTab(activeWindow),
-      ]).then(() => {
-        return Promise.all([
-          highlightTab(tabIds[0]),
-          highlightTab(tabIds[1]),
-          highlightTab(tabIds[2]),
-        ]);
-      }).then(() => {
-        return Promise.all(tabIds.map(id => browser.tabs.remove(id)));
-      }).then(() => {
-        browser.test.notifyPass("tabs.highlight");
-      });
-    });
+    let tabs = await browser.tabs.query({active: true, currentWindow: true});
+
+    let activeWindow = tabs[0].windowId;
+    await Promise.all([
+      openTab(activeWindow),
+      openTab(activeWindow),
+      openTab(activeWindow),
+    ]);
+
+    await Promise.all([
+      highlightTab(tabIds[0]),
+      highlightTab(tabIds[1]),
+      highlightTab(tabIds[2]),
+    ]);
+
+    await Promise.all(tabIds.map(id => browser.tabs.remove(id)));
+
+    browser.test.notifyPass("tabs.highlight");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_query.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_query.js
@@ -134,21 +134,21 @@ add_task(function* () {
 
   // test width and height
   extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background: function() {
-      browser.test.onMessage.addListener((msg) => {
-        browser.tabs.query({active: true}).then(tabs => {
-          browser.test.assertEq(tabs.length, 1, "should have one tab");
-          browser.test.sendMessage("dims", {width: tabs[0].width, height: tabs[0].height});
-        });
+      browser.test.onMessage.addListener(async msg => {
+        let tabs = await browser.tabs.query({active: true});
+
+        browser.test.assertEq(tabs.length, 1, "should have one tab");
+        browser.test.sendMessage("dims", {width: tabs[0].width, height: tabs[0].height});
       });
       browser.test.sendMessage("ready");
     },
   });
 
   const RESOLUTION_PREF = "layout.css.devPixelsPerPx";
   registerCleanupFunction(() => {
     SpecialPowers.clearUserPref(RESOLUTION_PREF);
@@ -177,40 +177,41 @@ add_task(function* () {
 });
 
 add_task(function* testQueryPermissions() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": [],
     },
 
-    background: function(x) {
-      browser.tabs.query({currentWindow: true, active: true}).then((tabs) => {
+    async background() {
+      try {
+        let tabs = await browser.tabs.query({currentWindow: true, active: true});
         browser.test.assertEq(tabs.length, 1, "Expect query to return tabs");
         browser.test.notifyPass("queryPermissions");
-      }).catch((e) => {
+      } catch (e) {
         browser.test.notifyFail("queryPermissions");
-      });
+      }
     },
   });
 
   yield extension.startup();
 
   yield extension.awaitFinish("queryPermissions");
 
   yield extension.unload();
 });
 
 add_task(function* testQueryWithURLPermissions() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": [],
     },
 
-    background: function(x) {
+    background: function() {
       browser.tabs.query({"url": "http://www.bbc.com/"}).then(() => {
         browser.test.notifyFail("queryWithURLPermissions");
       }).catch((e) => {
         browser.test.assertEq('The "tabs" permission is required to use the query API with the "url" parameter',
                               e.message, "Expected permissions error message");
         browser.test.notifyPass("queryWithURLPermissions");
       });
     },
--- a/browser/components/extensions/test/browser/browser_ext_tabs_reload.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_reload.js
@@ -14,41 +14,41 @@ add_task(function* () {
       },
       "tab.html":
         `<head>
           <meta charset="utf-8">
           <script src="tab.js"></script>
         </head>`,
     },
 
-    background: function() {
+    async background() {
       let tabLoadedCount = 0;
 
-      browser.tabs.create({url: "tab.html", active: true}).then(tab => {
-        browser.runtime.onMessage.addListener(msg => {
-          if (msg == "tab-loaded") {
-            tabLoadedCount++;
+      let tab = await browser.tabs.create({url: "tab.html", active: true});
 
-            if (tabLoadedCount == 1) {
-              // Reload the tab once passing no arguments.
-              return browser.tabs.reload();
-            }
+      browser.runtime.onMessage.addListener(msg => {
+        if (msg == "tab-loaded") {
+          tabLoadedCount++;
+
+          if (tabLoadedCount == 1) {
+            // Reload the tab once passing no arguments.
+            return browser.tabs.reload();
+          }
 
-            if (tabLoadedCount == 2) {
-              // Reload the tab again with explicit arguments.
-              return browser.tabs.reload(tab.id, {
-                bypassCache: false,
-              });
-            }
+          if (tabLoadedCount == 2) {
+            // Reload the tab again with explicit arguments.
+            return browser.tabs.reload(tab.id, {
+              bypassCache: false,
+            });
+          }
 
-            if (tabLoadedCount == 3) {
-              browser.test.notifyPass("tabs.reload");
-            }
+          if (tabLoadedCount == 3) {
+            browser.test.notifyPass("tabs.reload");
           }
-        });
+        }
       });
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.reload");
   yield extension.unload();
 });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js
@@ -3,57 +3,56 @@
 "use strict";
 
 add_task(function* () {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs", "<all_urls>"],
     },
 
-    background: function() {
+    async background() {
       const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
       const URL = BASE + "file_bypass_cache.sjs";
 
       function awaitLoad(tabId) {
         return new Promise(resolve => {
           browser.tabs.onUpdated.addListener(function listener(tabId_, changed, tab) {
             if (tabId == tabId_ && changed.status == "complete" && tab.url == URL) {
               browser.tabs.onUpdated.removeListener(listener);
               resolve();
             }
           });
         });
       }
 
-      let tabId;
-      browser.tabs.create({url: URL}).then((tab) => {
-        tabId = tab.id;
-        return awaitLoad(tabId);
-      }).then(() => {
-        return browser.tabs.reload(tabId, {bypassCache: false});
-      }).then(() => {
-        return awaitLoad(tabId);
-      }).then(() => {
-        return browser.tabs.executeScript(tabId, {code: "document.body.textContent"});
-      }).then(([textContent]) => {
+      try {
+        let tab = await browser.tabs.create({url: URL});
+        await awaitLoad(tab.id);
+
+        await browser.tabs.reload(tab.id, {bypassCache: false});
+        await awaitLoad(tab.id);
+
+        let [textContent] = await browser.tabs.executeScript(tab.id, {code: "document.body.textContent"});
         browser.test.assertEq("", textContent, "`textContent` should be empty when bypassCache=false");
-        return browser.tabs.reload(tabId, {bypassCache: true});
-      }).then(() => {
-        return awaitLoad(tabId);
-      }).then(() => {
-        return browser.tabs.executeScript(tabId, {code: "document.body.textContent"});
-      }).then(([textContent]) => {
+
+        await browser.tabs.reload(tab.id, {bypassCache: true});
+        await awaitLoad(tab.id);
+
+        [textContent] = await browser.tabs.executeScript(tab.id, {code: "document.body.textContent"});
+
         let [pragma, cacheControl] = textContent.split(":");
         browser.test.assertEq("no-cache", pragma, "`pragma` should be set to `no-cache` when bypassCache is true");
         browser.test.assertEq("no-cache", cacheControl, "`cacheControl` should be set to `no-cache` when bypassCache is true");
-        browser.tabs.remove(tabId);
+
+        await browser.tabs.remove(tab.id);
+
         browser.test.notifyPass("tabs.reload_bypass_cache");
-      }).catch(error => {
+      } catch (error) {
         browser.test.fail(`${error} :: ${error.stack}`);
         browser.test.notifyFail("tabs.reload_bypass_cache");
-      });
+      }
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.reload_bypass_cache");
   yield extension.unload();
 });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
@@ -1,17 +1,17 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testExecuteScript() {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/", true);
 
-  function background() {
-    let promises = [
+  async function background() {
+    let tasks = [
       // Insert CSS file.
       {
         background: "transparent",
         foreground: "rgb(0, 113, 4)",
         promise: () => {
           return browser.tabs.insertCSS({
             file: "file2.css",
           });
@@ -49,41 +49,33 @@ add_task(function* testExecuteScript() {
       },
     ];
 
     function checkCSS() {
       let computedStyle = window.getComputedStyle(document.body);
       return [computedStyle.backgroundColor, computedStyle.color];
     }
 
-    function next() {
-      if (!promises.length) {
-        return;
-      }
-
-      let {promise, background, foreground} = promises.shift();
-      return promise().then(result => {
+    try {
+      for (let {promise, background, foreground} of tasks) {
+        let result = await promise();
         browser.test.assertEq(undefined, result, "Expected callback result");
 
-        return browser.tabs.executeScript({
+        [result] = await browser.tabs.executeScript({
           code: `(${checkCSS})()`,
         });
-      }).then(([result]) => {
         browser.test.assertEq(background, result[0], "Expected background color");
         browser.test.assertEq(foreground, result[1], "Expected foreground color");
-        return next();
-      });
-    }
+      }
 
-    next().then(() => {
       browser.test.notifyPass("removeCSS");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFailure("removeCSS");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["http://mochi.test/"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js
@@ -9,17 +9,17 @@ add_task(function* tabsSendMessageReply(
 
       "content_scripts": [{
         "matches": ["http://example.com/"],
         "js": ["content-script.js"],
         "run_at": "document_start",
       }],
     },
 
-    background: function() {
+    background: async function() {
       let firstTab;
       let promiseResponse = new Promise(resolve => {
         browser.runtime.onMessage.addListener((msg, sender, respond) => {
           if (msg == "content-script-ready") {
             let tabId = sender.tab.id;
 
             Promise.all([
               promiseResponse,
@@ -61,50 +61,50 @@ add_task(function* tabsSendMessageReply(
 
             return Promise.resolve("expected-response");
           } else if (msg[0] == "got-response") {
             resolve(msg[1]);
           }
         });
       });
 
-      browser.tabs.query({currentWindow: true, active: true}).then(tabs => {
-        firstTab = tabs[0].id;
-        browser.tabs.create({url: "http://example.com/"});
-      });
+      let tabs = await browser.tabs.query({currentWindow: true, active: true});
+      firstTab = tabs[0].id;
+      browser.tabs.create({url: "http://example.com/"});
     },
 
     files: {
-      "content-script.js": function() {
+      "content-script.js": async function() {
         browser.runtime.onMessage.addListener((msg, sender, respond) => {
           if (msg == "respond-now") {
             respond(msg);
           } else if (msg == "respond-soon") {
             setTimeout(() => { respond(msg); }, 0);
             return true;
           } else if (msg == "respond-promise") {
             return Promise.resolve(msg);
           } else if (msg == "respond-never") {
             return;
           } else if (msg == "respond-error") {
             return Promise.reject(new Error(msg));
           } else if (msg == "throw-error") {
             throw new Error(msg);
           }
         });
+
         browser.runtime.onMessage.addListener((msg, sender, respond) => {
           if (msg == "respond-now") {
             respond("hello");
           } else if (msg == "respond-now-2") {
             respond(msg);
           }
         });
-        browser.runtime.sendMessage("content-script-ready").then(response => {
-          browser.runtime.sendMessage(["got-response", response]);
-        });
+
+        let response = await browser.runtime.sendMessage("content-script-ready");
+        browser.runtime.sendMessage(["got-response", response]);
       },
     },
   });
 
   yield extension.startup();
 
   yield extension.awaitFinish("sendMessage");
 
@@ -119,62 +119,60 @@ add_task(function* tabsSendHidden() {
 
       "content_scripts": [{
         "matches": ["http://example.com/content*"],
         "js": ["content-script.js"],
         "run_at": "document_start",
       }],
     },
 
-    background: function() {
+    background: async function() {
       let resolveContent;
       browser.runtime.onMessage.addListener((msg, sender) => {
         if (msg[0] == "content-ready") {
           resolveContent(msg[1]);
         }
       });
 
       let awaitContent = url => {
         return new Promise(resolve => {
           resolveContent = resolve;
         }).then(result => {
           browser.test.assertEq(url, result, "Expected content script URL");
         });
       };
 
-      const URL1 = "http://example.com/content1.html";
-      const URL2 = "http://example.com/content2.html";
-      browser.tabs.create({url: URL1}).then(tab => {
-        return awaitContent(URL1).then(() => {
-          return browser.tabs.sendMessage(tab.id, URL1);
-        }).then(url => {
-          browser.test.assertEq(URL1, url, "Should get response from expected content window");
+      try {
+        const URL1 = "http://example.com/content1.html";
+        const URL2 = "http://example.com/content2.html";
+
+        let tab = await browser.tabs.create({url: URL1});
+        await awaitContent(URL1);
+
+        let url = await browser.tabs.sendMessage(tab.id, URL1);
+        browser.test.assertEq(URL1, url, "Should get response from expected content window");
+
+        await browser.tabs.update(tab.id, {url: URL2});
+        await awaitContent(URL2);
 
-          return browser.tabs.update(tab.id, {url: URL2});
-        }).then(() => {
-          return awaitContent(URL2);
-        }).then(() => {
-          return browser.tabs.sendMessage(tab.id, URL2);
-        }).then(url => {
-          browser.test.assertEq(URL2, url, "Should get response from expected content window");
+        url = await browser.tabs.sendMessage(tab.id, URL2);
+        browser.test.assertEq(URL2, url, "Should get response from expected content window");
 
-          // Repeat once just to be sure the first message was processed by all
-          // listeners before we exit the test.
-          return browser.tabs.sendMessage(tab.id, URL2);
-        }).then(url => {
-          browser.test.assertEq(URL2, url, "Should get response from expected content window");
+        // Repeat once just to be sure the first message was processed by all
+        // listeners before we exit the test.
+        url = await browser.tabs.sendMessage(tab.id, URL2);
+        browser.test.assertEq(URL2, url, "Should get response from expected content window");
 
-          return browser.tabs.remove(tab.id);
-        });
-      }).then(() => {
+        await browser.tabs.remove(tab.id);
+
         browser.test.notifyPass("contentscript-bfcache-window");
-      }).catch(error => {
+      } catch (error) {
         browser.test.fail(`Error: ${error} :: ${error.stack}`);
         browser.test.notifyFail("contentscript-bfcache-window");
-      });
+      }
     },
 
     files: {
       "content-script.js": function() {
         // Store this in a local variable to make sure we don't touch any
         // properties of the possibly-hidden content window.
         let href = window.location.href;
 
@@ -198,32 +196,30 @@ add_task(function* tabsSendHidden() {
 
 
 add_task(function* tabsSendMessageNoExceptionOnNonExistentTab() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
-    background: function() {
+    async background() {
       let url = "http://example.com/mochitest/browser/browser/components/extensions/test/browser/file_dummy.html";
-      browser.tabs.create({url}, tab => {
-        let exception;
-        try {
-          browser.tabs.sendMessage(tab.id, "message");
-          browser.tabs.sendMessage(tab.id + 100, "message");
-        } catch (e) {
-          exception = e;
-        }
+      let tab = await browser.tabs.create({url});
 
-        browser.test.assertEq(undefined, exception, "no exception should be raised on tabs.sendMessage to nonexistent tabs");
-        browser.tabs.remove(tab.id, function() {
-          browser.test.notifyPass("tabs.sendMessage");
-        });
-      });
+      try {
+        browser.tabs.sendMessage(tab.id, "message");
+        browser.tabs.sendMessage(tab.id + 100, "message");
+      } catch (e) {
+        browser.test.fail("no exception should be raised on tabs.sendMessage to nonexistent tabs");
+      }
+
+      await browser.tabs.remove(tab.id);
+
+      browser.test.notifyPass("tabs.sendMessage");
     },
   });
 
   yield Promise.all([
     extension.startup(),
     extension.awaitFinish("tabs.sendMessage"),
   ]);
 
--- a/browser/components/extensions/test/browser/browser_ext_tabs_update_url.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_update_url.js
@@ -19,41 +19,31 @@ function* testTabsUpdateURL(existentTabU
             <h1>tab page</h1>
           </body>
         </html>
       `.trim(),
     },
     background: function() {
       browser.test.sendMessage("ready", browser.runtime.getURL("tab.html"));
 
-      browser.test.onMessage.addListener((msg, tabsUpdateURL, isErrorExpected) => {
-        let onTabsUpdated = (tab) => {
-          if (isErrorExpected) {
-            browser.test.fail(`tabs.update with URL ${tabsUpdateURL} should be rejected`);
-          } else {
-            browser.test.assertTrue(tab, "on success the tab should be defined");
-          }
-        };
+      browser.test.onMessage.addListener(async (msg, tabsUpdateURL, isErrorExpected) => {
+        let tabs = await browser.tabs.query({lastFocusedWindow: true});
+
+        try {
+          let tab = await browser.tabs.update(tabs[1].id, {url: tabsUpdateURL});
 
-        let onTabsUpdateError = (error) => {
-          if (!isErrorExpected) {
-            browser.test.fails(`tabs.update with URL ${tabsUpdateURL} should not be rejected`);
-          } else {
-            browser.test.assertTrue(/^Illegal URL/.test(error.message),
-                                    "tabs.update should be rejected with the expected error message");
-          }
-        };
+          browser.test.assertFalse(isErrorExpected, `tabs.update with URL ${tabsUpdateURL} should be rejected`);
+          browser.test.assertTrue(tab, "on success the tab should be defined");
+        } catch (error) {
+          browser.test.assertTrue(isErrorExpected, `tabs.update with URL ${tabsUpdateURL} should not be rejected`);
+          browser.test.assertTrue(/^Illegal URL/.test(error.message),
+                                  "tabs.update should be rejected with the expected error message");
+        }
 
-        let onTabsUpdateDone = () => browser.test.sendMessage("done");
-
-        browser.tabs.query({lastFocusedWindow: true}, (tabs) => {
-          browser.tabs.update(tabs[1].id, {url: tabsUpdateURL})
-                      .then(onTabsUpdated, onTabsUpdateError)
-                      .then(onTabsUpdateDone);
-        });
+        browser.test.sendMessage("done");
       });
     },
   });
 
   yield extension.startup();
 
   let mozExtTabURL = yield extension.awaitMessage("ready");
 
--- a/browser/components/extensions/test/browser/browser_ext_tabs_zoom.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_zoom.js
@@ -5,17 +5,17 @@
 const SITE_SPECIFIC_PREF = "browser.zoom.siteSpecific";
 
 add_task(function* () {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.net/");
 
   gBrowser.selectedTab = tab1;
 
-  function background() {
+  async function background() {
     function promiseUpdated(tabId, attr) {
       return new Promise(resolve => {
         let onUpdated = (tabId_, changeInfo, tab) => {
           if (tabId == tabId_ && attr in changeInfo) {
             browser.tabs.onUpdated.removeListener(onUpdated);
 
             resolve({changeInfo, tab});
           }
@@ -45,156 +45,149 @@ add_task(function* () {
     let eventPromises = [];
     browser.tabs.onZoomChange.addListener(info => {
       zoomEvents.push(info);
       if (eventPromises.length) {
         eventPromises.shift().resolve();
       }
     });
 
-    let awaitZoom = (tabId, newValue) => {
+    let awaitZoom = async (tabId, newValue) => {
       let listener;
 
-      return new Promise(resolve => {
+      await new Promise(async resolve => {
         listener = info => {
           if (info.tabId == tabId && info.newZoomFactor == newValue) {
             resolve();
           }
         };
         browser.tabs.onZoomChange.addListener(listener);
 
-        browser.tabs.getZoom(tabId).then(zoomFactor => {
-          if (zoomFactor == newValue) {
-            resolve();
-          }
-        });
-      }).then(() => {
-        browser.tabs.onZoomChange.removeListener(listener);
+        let zoomFactor = await browser.tabs.getZoom(tabId);
+        if (zoomFactor == newValue) {
+          resolve();
+        }
       });
+
+      browser.tabs.onZoomChange.removeListener(listener);
     };
 
-    let checkZoom = (tabId, newValue, oldValue = null) => {
+    let checkZoom = async (tabId, newValue, oldValue = null) => {
       let awaitEvent;
       if (oldValue != null && !zoomEvents.length) {
         awaitEvent = new Promise(resolve => {
           eventPromises.push({resolve});
         });
       }
 
-      return Promise.all([
+      let [apiZoom, realZoom] = await Promise.all([
         browser.tabs.getZoom(tabId),
         msg("get-zoom", tabId),
         awaitEvent,
-      ]).then(([apiZoom, realZoom]) => {
-        browser.test.assertEq(newValue, apiZoom, `Got expected zoom value from API`);
-        browser.test.assertEq(newValue, realZoom, `Got expected zoom value from parent`);
+      ]);
+
+      browser.test.assertEq(newValue, apiZoom, `Got expected zoom value from API`);
+      browser.test.assertEq(newValue, realZoom, `Got expected zoom value from parent`);
 
-        if (oldValue != null) {
-          let event = zoomEvents.shift();
-          browser.test.assertEq(tabId, event.tabId, `Got expected zoom event tab ID`);
-          browser.test.assertEq(newValue, event.newZoomFactor, `Got expected zoom event zoom factor`);
-          browser.test.assertEq(oldValue, event.oldZoomFactor, `Got expected zoom event old zoom factor`);
+      if (oldValue != null) {
+        let event = zoomEvents.shift();
+        browser.test.assertEq(tabId, event.tabId, `Got expected zoom event tab ID`);
+        browser.test.assertEq(newValue, event.newZoomFactor, `Got expected zoom event zoom factor`);
+        browser.test.assertEq(oldValue, event.oldZoomFactor, `Got expected zoom event old zoom factor`);
 
-          browser.test.assertEq(3, Object.keys(event.zoomSettings).length, `Zoom settings should have 3 keys`);
-          browser.test.assertEq("automatic", event.zoomSettings.mode, `Mode should be "automatic"`);
-          browser.test.assertEq("per-origin", event.zoomSettings.scope, `Scope should be "per-origin"`);
-          browser.test.assertEq(1, event.zoomSettings.defaultZoomFactor, `Default zoom should be 1`);
-        }
-      });
+        browser.test.assertEq(3, Object.keys(event.zoomSettings).length, `Zoom settings should have 3 keys`);
+        browser.test.assertEq("automatic", event.zoomSettings.mode, `Mode should be "automatic"`);
+        browser.test.assertEq("per-origin", event.zoomSettings.scope, `Scope should be "per-origin"`);
+        browser.test.assertEq(1, event.zoomSettings.defaultZoomFactor, `Default zoom should be 1`);
+      }
     };
 
-    let tabIds;
-
-    browser.tabs.query({lastFocusedWindow: true}).then(tabs => {
+    try {
+      let tabs = await browser.tabs.query({lastFocusedWindow: true});
       browser.test.assertEq(tabs.length, 3, "We have three tabs");
 
-      tabIds = [tabs[1].id, tabs[2].id];
+      let tabIds = [tabs[1].id, tabs[2].id];
+      await checkZoom(tabIds[0], 1);
 
-      return checkZoom(tabIds[0], 1);
-    }).then(() => {
-      return browser.tabs.setZoom(tabIds[0], 2);
-    }).then(() => {
-      return checkZoom(tabIds[0], 2, 1);
-    }).then(() => {
-      return browser.tabs.getZoomSettings(tabIds[0]);
-    }).then(zoomSettings => {
+      await browser.tabs.setZoom(tabIds[0], 2);
+      await checkZoom(tabIds[0], 2, 1);
+
+      let zoomSettings = await browser.tabs.getZoomSettings(tabIds[0]);
       browser.test.assertEq(3, Object.keys(zoomSettings).length, `Zoom settings should have 3 keys`);
       browser.test.assertEq("automatic", zoomSettings.mode, `Mode should be "automatic"`);
       browser.test.assertEq("per-origin", zoomSettings.scope, `Scope should be "per-origin"`);
       browser.test.assertEq(1, zoomSettings.defaultZoomFactor, `Default zoom should be 1`);
 
+
       browser.test.log(`Switch to tab 2`);
-      return browser.tabs.update(tabIds[1], {active: true});
-    }).then(() => {
-      return checkZoom(tabIds[1], 1);
-    }).then(() => {
+      await browser.tabs.update(tabIds[1], {active: true});
+      await checkZoom(tabIds[1], 1);
+
+
       browser.test.log(`Navigate tab 2 to origin of tab 1`);
       browser.tabs.update(tabIds[1], {url: "http://example.com"});
+      await promiseUpdated(tabIds[1], "url");
+      await checkZoom(tabIds[1], 2, 1);
 
-      return promiseUpdated(tabIds[1], "url");
-    }).then(() => {
-      return checkZoom(tabIds[1], 2, 1);
-    }).then(() => {
+
       browser.test.log(`Update zoom in tab 2, expect changes in both tabs`);
-      return browser.tabs.setZoom(tabIds[1], 1.5);
-    }).then(() => {
-      return checkZoom(tabIds[1], 1.5, 2);
-    }).then(() => {
+      await browser.tabs.setZoom(tabIds[1], 1.5);
+      await checkZoom(tabIds[1], 1.5, 2);
+
+
       browser.test.log(`Switch to tab 1, expect asynchronous zoom change just after the switch`);
-      return Promise.all([
+      await Promise.all([
         awaitZoom(tabIds[0], 1.5),
         browser.tabs.update(tabIds[0], {active: true}),
       ]);
-    }).then(() => {
-      return checkZoom(tabIds[0], 1.5, 2);
-    }).then(() => {
+      await checkZoom(tabIds[0], 1.5, 2);
+
+
       browser.test.log("Set zoom to 0, expect it set to 1");
-      return browser.tabs.setZoom(tabIds[0], 0);
-    }).then(() => {
-      return checkZoom(tabIds[0], 1, 1.5);
-    }).then(() => {
+      await browser.tabs.setZoom(tabIds[0], 0);
+      await checkZoom(tabIds[0], 1, 1.5);
+
+
       browser.test.log("Change zoom externally, expect changes reflected");
-      return msg("enlarge");
-    }).then(() => {
-      return checkZoom(tabIds[0], 1.1, 1);
-    }).then(() => {
-      return Promise.all([
+      await msg("enlarge");
+      await checkZoom(tabIds[0], 1.1, 1);
+
+      await Promise.all([
         browser.tabs.setZoom(tabIds[0], 0),
         browser.tabs.setZoom(tabIds[1], 0),
       ]);
-    }).then(() => {
-      return Promise.all([
+      await Promise.all([
         checkZoom(tabIds[0], 1, 1.1),
         checkZoom(tabIds[1], 1, 1.5),
       ]);
-    }).then(() => {
+
+
       browser.test.log("Check that invalid zoom values throw an error");
-      return browser.tabs.setZoom(tabIds[0], 42).then(
+      await browser.tabs.setZoom(tabIds[0], 42).then(
         () => {
           browser.test.fail("Expected an error");
         },
         error => {
           browser.test.assertTrue(error.message.includes("Zoom value 42 out of range"),
                                   "Got expected error");
         });
-    }).then(() => {
+
+
       browser.test.log("Disable site-specific zoom, expect correct scope");
-      return msg("site-specific", false);
-    }).then(() => {
-      return browser.tabs.getZoomSettings(tabIds[0]);
-    }).then(zoomSettings => {
+      await msg("site-specific", false);
+      zoomSettings = await browser.tabs.getZoomSettings(tabIds[0]);
+
       browser.test.assertEq("per-tab", zoomSettings.scope, `Scope should be "per-tab"`);
-    }).then(() => {
-      return msg("site-specific", null);
-    }).then(() => {
+      await msg("site-specific", null);
+
       browser.test.notifyPass("tab-zoom");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFail("tab-zoom");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_webNavigation_frameId0.js
+++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_frameId0.js
@@ -15,25 +15,23 @@ add_task(function* webNavigation_getFram
   // main process:
   // Cu.import("resource://gre/modules/ExtensionManagement.jsm", {});
   //
   // Or simply run the test again.
   const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
   const DUMMY_URL = BASE + "file_dummy.html";
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_URL, true);
 
-  function background(DUMMY_URL) {
-    browser.tabs.query({active: true, currentWindow: true}).then(tabs => {
-      return browser.webNavigation.getAllFrames({tabId: tabs[0].id});
-    }).then(frames => {
-      browser.test.assertEq(1, frames.length, "The dummy page has one frame");
-      browser.test.assertEq(0, frames[0].frameId, "Main frame's ID must be 0");
-      browser.test.assertEq(DUMMY_URL, frames[0].url, "Main frame URL must match");
-      browser.test.notifyPass("frameId checked");
-    });
+  async function background(DUMMY_URL) {
+    let tabs = await browser.tabs.query({active: true, currentWindow: true});
+    let frames = await browser.webNavigation.getAllFrames({tabId: tabs[0].id});
+    browser.test.assertEq(1, frames.length, "The dummy page has one frame");
+    browser.test.assertEq(0, frames[0].frameId, "Main frame's ID must be 0");
+    browser.test.assertEq(DUMMY_URL, frames[0].url, "Main frame URL must match");
+    browser.test.notifyPass("frameId checked");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["webNavigation"],
     },
 
     background: `(${background})(${JSON.stringify(DUMMY_URL)});`,
--- a/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js
+++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js
@@ -1,38 +1,39 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testWebNavigationGetNonExistentTab() {
   let extension = ExtensionTestUtils.loadExtension({
-    background: "(" + function() {
+    background: async function() {
       let results = [
         // There is no "tabId = 0" because the id assigned by TabManager (defined in ext-utils.js)
         // starts from 1.
         browser.webNavigation.getAllFrames({tabId: 0}).then(() => {
           browser.test.fail("getAllFrames Promise should be rejected on error");
         }, (error) => {
           browser.test.assertEq("Invalid tab ID: 0", error.message,
                                 "getAllFrames rejected Promise should pass the expected error");
         }),
+
         // There is no "tabId = 0" because the id assigned by TabManager (defined in ext-utils.js)
         // starts from 1, processId is currently marked as optional and it is ignored.
         browser.webNavigation.getFrame({tabId: 0, frameId: 15, processId: 20}).then(() => {
           browser.test.fail("getFrame Promise should be rejected on error");
         }, (error) => {
           browser.test.assertEq("Invalid tab ID: 0", error.message,
                                 "getFrame rejected Promise should pass the expected error");
         }),
       ];
 
-      Promise.all(results).then(() => {
-        browser.test.sendMessage("getNonExistentTab.done");
-      });
-    } + ")();",
+      await Promise.all(results);
+
+      browser.test.sendMessage("getNonExistentTab.done");
+    },
     manifest: {
       permissions: ["webNavigation"],
     },
   });
   info("load complete");
 
   yield extension.startup();
   info("startup complete");
@@ -40,68 +41,65 @@ add_task(function* testWebNavigationGetN
   yield extension.awaitMessage("getNonExistentTab.done");
 
   yield extension.unload();
   info("extension unloaded");
 });
 
 add_task(function* testWebNavigationFrames() {
   let extension = ExtensionTestUtils.loadExtension({
-    background: "(" + function() {
+    background: async function() {
       let tabId;
       let collectedDetails = [];
 
-      browser.webNavigation.onCompleted.addListener((details) => {
+      browser.webNavigation.onCompleted.addListener(async details => {
         collectedDetails.push(details);
 
         if (details.frameId !== 0) {
           // wait for the top level iframe to be complete
           return;
         }
 
-        browser.webNavigation.getAllFrames({tabId}).then((getAllFramesDetails) => {
-          let getFramePromises = getAllFramesDetails.map((frameDetail) => {
-            let {frameId} = frameDetail;
-            // processId is currently marked as optional and it is ignored.
-            return browser.webNavigation.getFrame({tabId, frameId, processId: 0});
-          });
+        let getAllFramesDetails = await browser.webNavigation.getAllFrames({tabId});
+
+        let getFramePromises = getAllFramesDetails.map(({frameId}) => {
+          // processId is currently marked as optional and it is ignored.
+          return browser.webNavigation.getFrame({tabId, frameId, processId: 0});
+        });
+
+        let getFrameResults = await Promise.all(getFramePromises);
+        browser.test.sendMessage("webNavigationFrames.done", {
+          collectedDetails, getAllFramesDetails, getFrameResults,
+        });
 
-          Promise.all(getFramePromises).then((getFrameResults) => {
-            browser.test.sendMessage("webNavigationFrames.done", {
-              collectedDetails, getAllFramesDetails, getFrameResults,
-            });
-          }, () => {
-            browser.test.assertTrue(false, "None of the getFrame promises should have been rejected");
+        // Pick a random frameId.
+        let nonExistentFrameId = Math.floor(Math.random() * 10000);
+
+        // Increment the picked random nonExistentFrameId until it doesn't exists.
+        while (getAllFramesDetails.filter((details) => details.frameId == nonExistentFrameId).length > 0) {
+          nonExistentFrameId += 1;
+        }
+
+        // Check that getFrame Promise is rejected with the expected error message on nonexistent frameId.
+        await browser.webNavigation.getFrame({tabId, frameId: nonExistentFrameId, processId: 20}).then(
+          () => {
+            browser.test.fail("getFrame promise should be rejected for an unexistent frameId");
+          },
+          error => {
+            browser.test.assertEq(`No frame found with frameId: ${nonExistentFrameId}`, error.message,
+                                  "getFrame promise should be rejected with the expected error message on unexistent frameId");
           });
 
-          // Pick a random frameId.
-          let nonExistentFrameId = Math.floor(Math.random() * 10000);
-
-          // Increment the picked random nonExistentFrameId until it doesn't exists.
-          while (getAllFramesDetails.filter((details) => details.frameId == nonExistentFrameId).length > 0) {
-            nonExistentFrameId += 1;
-          }
-
-          // Check that getFrame Promise is rejected with the expected error message on nonexistent frameId.
-          browser.webNavigation.getFrame({tabId, frameId: nonExistentFrameId, processId: 20}).then(() => {
-            browser.test.fail("getFrame promise should be rejected for an unexistent frameId");
-          }, (error) => {
-            browser.test.assertEq(`No frame found with frameId: ${nonExistentFrameId}`, error.message,
-                                  "getFrame promise should be rejected with the expected error message on unexistent frameId");
-          }).then(() => {
-            browser.tabs.remove(tabId);
-            browser.test.sendMessage("webNavigationFrames.done");
-          });
-        });
+        await browser.tabs.remove(tabId);
+        browser.test.sendMessage("webNavigationFrames.done");
       });
 
-      browser.tabs.create({url: "tab.html"}, (tab) => {
-        tabId = tab.id;
-      });
-    } + ")();",
+      let tab = await browser.tabs.create({url: "tab.html"});
+      tabId = tab.id;
+    },
     manifest: {
       permissions: ["webNavigation", "tabs"],
     },
     files: {
       "tab.html": `
         <!DOCTYPE html>
         <html>
           <head>
--- a/browser/components/extensions/test/browser/browser_ext_windows_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create.js
@@ -1,15 +1,15 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testWindowCreate() {
   let extension = ExtensionTestUtils.loadExtension({
-    background() {
+    async background() {
       let _checkWindowPromise;
       browser.test.onMessage.addListener(msg => {
         if (msg == "checked-window") {
           _checkWindowPromise.resolve();
           _checkWindowPromise = null;
         }
       });
 
@@ -17,69 +17,71 @@ add_task(function* testWindowCreate() {
 
       function checkWindow(expected) {
         return new Promise(resolve => {
           _checkWindowPromise = {resolve};
           browser.test.sendMessage("check-window", expected);
         });
       }
 
-      function createWindow(params, expected, keep = false) {
-        return browser.windows.create(params).then(window => {
-          for (let key of Object.keys(params)) {
-            if (key == "state" && os == "mac" && params.state == "normal") {
-              // OS-X doesn't have a hard distinction between "normal" and
-              // "maximized" states.
-              browser.test.assertTrue(window.state == "normal" || window.state == "maximized",
-                                      `Expected window.state (currently ${window.state}) to be "normal" but will accept "maximized"`);
-            } else {
-              browser.test.assertEq(params[key], window[key], `Got expected value for window.${key}`);
-            }
+      async function createWindow(params, expected, keep = false) {
+        let window = await browser.windows.create(params);
+
+        for (let key of Object.keys(params)) {
+          if (key == "state" && os == "mac" && params.state == "normal") {
+            // OS-X doesn't have a hard distinction between "normal" and
+            // "maximized" states.
+            browser.test.assertTrue(window.state == "normal" || window.state == "maximized",
+                                    `Expected window.state (currently ${window.state}) to be "normal" but will accept "maximized"`);
+          } else {
+            browser.test.assertEq(params[key], window[key], `Got expected value for window.${key}`);
           }
+        }
 
-          browser.test.assertEq(1, window.tabs.length, "tabs property got populated");
-          return checkWindow(expected).then(() => {
-            if (keep) {
-              return window;
-            }
-            if (params.state == "fullscreen" && os == "win") {
-              // FIXME: Closing a fullscreen window causes a window leak in
-              // Windows tests.
-              return browser.windows.update(window.id, {state: "normal"}).then(() => {
-                return browser.windows.remove(window.id);
-              });
-            }
-            return browser.windows.remove(window.id);
-          });
-        });
+        browser.test.assertEq(1, window.tabs.length, "tabs property got populated");
+
+        await checkWindow(expected);
+        if (keep) {
+          return window;
+        }
+
+        if (params.state == "fullscreen" && os == "win") {
+          // FIXME: Closing a fullscreen window causes a window leak in
+          // Windows tests.
+          await browser.windows.update(window.id, {state: "normal"});
+        }
+        await browser.windows.remove(window.id);
       }
 
-      browser.runtime.getPlatformInfo().then(info => { os = info.os; })
-      .then(() => createWindow({state: "maximized"}, {state: "STATE_MAXIMIZED"}))
-      .then(() => createWindow({state: "minimized"}, {state: "STATE_MINIMIZED"}))
-      .then(() => createWindow({state: "normal"}, {state: "STATE_NORMAL", hiddenChrome: []}))
-      .then(() => createWindow({state: "fullscreen"}, {state: "STATE_FULLSCREEN"}))
-      .then(() => {
-        return createWindow({type: "popup"},
-                            {hiddenChrome: ["menubar", "toolbar", "location", "directories", "status", "extrachrome"],
-                             chromeFlags: ["CHROME_OPENAS_DIALOG"]},
-                            true);
-      }).then(window => {
-        return browser.tabs.query({windowType: "popup", active: true}).then(tabs => {
-          browser.test.assertEq(1, tabs.length, "Expected only one popup");
-          browser.test.assertEq(window.id, tabs[0].windowId, "Expected new window to be returned in query");
+      try {
+        ({os} = await browser.runtime.getPlatformInfo());
+
+        await createWindow({state: "maximized"}, {state: "STATE_MAXIMIZED"});
+        await createWindow({state: "minimized"}, {state: "STATE_MINIMIZED"});
+        await createWindow({state: "normal"}, {state: "STATE_NORMAL", hiddenChrome: []});
+        await createWindow({state: "fullscreen"}, {state: "STATE_FULLSCREEN"});
 
-          return browser.windows.remove(window.id);
-        });
-      }).then(() => {
+        let window = await createWindow(
+          {type: "popup"},
+          {hiddenChrome: ["menubar", "toolbar", "location", "directories", "status", "extrachrome"],
+           chromeFlags: ["CHROME_OPENAS_DIALOG"]},
+          true);
+
+        let tabs = await browser.tabs.query({windowType: "popup", active: true});
+
+        browser.test.assertEq(1, tabs.length, "Expected only one popup");
+        browser.test.assertEq(window.id, tabs[0].windowId, "Expected new window to be returned in query");
+
+        await browser.windows.remove(window.id);
+
         browser.test.notifyPass("window-create");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-create");
-      });
+      }
     },
   });
 
   let latestWindow;
   let windowListener = (window, topic) => {
     if (topic == "domwindowopened") {
       latestWindow = window;
     }
--- a/browser/components/extensions/test/browser/browser_ext_windows_create_params.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create_params.js
@@ -1,17 +1,17 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 
 // Tests that incompatible parameters can't be used together.
 add_task(function* testWindowCreateParams() {
   let extension = ExtensionTestUtils.loadExtension({
-    background() {
+    async background() {
       function* getCalls() {
         for (let state of ["minimized", "maximized", "fullscreen"]) {
           for (let param of ["left", "top", "width", "height"]) {
             let expected = `"state": "${state}" may not be combined with "left", "top", "width", or "height"`;
 
             yield browser.windows.create({state, [param]: 100}).then(
               val => {
                 browser.test.fail(`Expected error but got "${val}" instead`);
@@ -20,21 +20,23 @@ add_task(function* testWindowCreateParam
                 browser.test.assertTrue(
                   error.message.includes(expected),
                   `Got expected error (got: '${error.message}', expected: '${expected}'`);
               });
           }
         }
       }
 
-      Promise.all(getCalls()).then(() => {
+      try {
+        await Promise.all(getCalls());
+
         browser.test.notifyPass("window-create-params");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-create-params");
-      });
+      }
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("window-create-params");
   yield extension.unload();
 });
--- a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
@@ -1,14 +1,14 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testWindowCreate() {
-  function background() {
+  async function background() {
     let promiseTabAttached = () => {
       return new Promise(resolve => {
         browser.tabs.onAttached.addListener(function listener() {
           browser.tabs.onAttached.removeListener(listener);
           resolve();
         });
       });
     };
@@ -19,130 +19,126 @@ add_task(function* testWindowCreate() {
           if (changeInfo.url === expected) {
             browser.tabs.onUpdated.removeListener(listener);
             resolve();
           }
         });
       });
     };
 
-    let windowId, tabId;
-    browser.windows.getCurrent().then(window => {
-      windowId = window.id;
+    try {
+      let window = await browser.windows.getCurrent();
+      let windowId = window.id;
 
       browser.test.log("Create additional tab in window 1");
-      return browser.tabs.create({windowId, url: "about:blank"});
-    }).then(tab => {
-      tabId = tab.id;
+      let tab = await browser.tabs.create({windowId, url: "about:blank"});
+      let tabId = tab.id;
+
       browser.test.log("Create a new window, adopting the new tab");
 
       // Note that we want to check against actual boolean values for
       // all of the `incognito` property tests.
       browser.test.assertEq(false, tab.incognito, "Tab is not private");
 
-      return Promise.all([
-        promiseTabAttached(),
-        browser.windows.create({tabId: tabId}),
-      ]);
-    }).then(([, window]) => {
-      browser.test.assertEq(false, window.incognito, "New window is not private");
-      browser.test.assertEq(tabId, window.tabs[0].id, "tabs property populated correctly");
+      {
+        let [, window] = await Promise.all([
+          promiseTabAttached(),
+          browser.windows.create({tabId: tabId}),
+        ]);
+        browser.test.assertEq(false, window.incognito, "New window is not private");
+        browser.test.assertEq(tabId, window.tabs[0].id, "tabs property populated correctly");
 
-      browser.test.log("Close the new window");
-      return browser.windows.remove(window.id);
-    }).then(() => {
-      browser.test.log("Create a new private window");
+        browser.test.log("Close the new window");
+        await browser.windows.remove(window.id);
+      }
 
-      return browser.windows.create({incognito: true});
-    }).then(privateWindow => {
-      browser.test.assertEq(true, privateWindow.incognito, "Private window is private");
+      {
+        browser.test.log("Create a new private window");
+        let privateWindow = await browser.windows.create({incognito: true});
+        browser.test.assertEq(true, privateWindow.incognito, "Private window is private");
 
-      browser.test.log("Create additional tab in private window");
-      return browser.tabs.create({windowId: privateWindow.id}).then(privateTab => {
+        browser.test.log("Create additional tab in private window");
+        let privateTab = await browser.tabs.create({windowId: privateWindow.id});
         browser.test.assertEq(true, privateTab.incognito, "Private tab is private");
 
         browser.test.log("Create a new window, adopting the new private tab");
-
-        return Promise.all([
+        let [, newWindow] = await Promise.all([
           promiseTabAttached(),
           browser.windows.create({tabId: privateTab.id}),
         ]);
-      }).then(([, newWindow]) => {
         browser.test.assertEq(true, newWindow.incognito, "New private window is private");
 
         browser.test.log("Close the new private window");
-        return browser.windows.remove(newWindow.id);
-      }).then(() => {
+        await browser.windows.remove(newWindow.id);
+
         browser.test.log("Close the private window");
-        return browser.windows.remove(privateWindow.id);
-      });
-    }).then(() => {
-      return browser.tabs.query({windowId, active: true});
-    }).then(([tab]) => {
+        await browser.windows.remove(privateWindow.id);
+      }
+
+
       browser.test.log("Try to create a window with both a tab and a URL");
-
-      return browser.windows.create({tabId: tab.id, url: "http://example.com/"}).then(
+      [tab] = await browser.tabs.query({windowId, active: true});
+      await browser.windows.create({tabId: tab.id, url: "http://example.com/"}).then(
         window => {
           browser.test.fail("Create call should have failed");
         },
         error => {
           browser.test.assertTrue(/`tabId` may not be used in conjunction with `url`/.test(error.message),
                                   "Create call failed as expected");
-        }).then(() => {
-          browser.test.log("Try to create a window with both a tab and an invalid incognito setting");
+        });
+
 
-          return browser.windows.create({tabId: tab.id, incognito: true});
-        }).then(
-          window => {
-            browser.test.fail("Create call should have failed");
-          },
-          error => {
-            browser.test.assertTrue(/`incognito` property must match the incognito state of tab/.test(error.message),
-                                    "Create call failed as expected");
-          });
-    }).then(() => {
+      browser.test.log("Try to create a window with both a tab and an invalid incognito setting");
+      await browser.windows.create({tabId: tab.id, incognito: true}).then(
+        window => {
+          browser.test.fail("Create call should have failed");
+        },
+        error => {
+          browser.test.assertTrue(/`incognito` property must match the incognito state of tab/.test(error.message),
+                                  "Create call failed as expected");
+        });
+
+
       browser.test.log("Try to create a window with an invalid tabId");
-
-      return browser.windows.create({tabId: 0}).then(
+      await browser.windows.create({tabId: 0}).then(
         window => {
           browser.test.fail("Create call should have failed");
         },
         error => {
           browser.test.assertTrue(/Invalid tab ID: 0/.test(error.message),
                                   "Create call failed as expected");
-        }
-      );
-    }).then(() => {
+        });
+
+
       browser.test.log("Try to create a window with two URLs");
-
-      return Promise.all([
+      [, , window] = await Promise.all([
         // tabs.onUpdated can be invoked between the call of windows.create and
         // the invocation of its callback/promise, so set up the listeners
         // before creating the window.
         promiseTabUpdated("http://example.com/"),
         promiseTabUpdated("http://example.org/"),
         browser.windows.create({url: ["http://example.com/", "http://example.org/"]}),
       ]);
-    }).then(([, , window]) => {
       browser.test.assertEq(2, window.tabs.length, "2 tabs were opened in new window");
       browser.test.assertEq("about:blank", window.tabs[0].url, "about:blank, page not loaded yet");
       browser.test.assertEq("about:blank", window.tabs[1].url, "about:blank, page not loaded yet");
 
-      return browser.windows.get(window.id, {populate: true});
-    }).then(window => {
+      window = await browser.windows.get(window.id, {populate: true});
+
       browser.test.assertEq(2, window.tabs.length, "2 tabs were opened in new window");
       browser.test.assertEq("http://example.com/", window.tabs[0].url, "Correct URL was loaded in tab 1");
       browser.test.assertEq("http://example.org/", window.tabs[1].url, "Correct URL was loaded in tab 2");
-      return browser.windows.remove(window.id);
-    }).then(() => {
+
+      await browser.windows.remove(window.id);
+
       browser.test.notifyPass("window-create");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`${e} :: ${e.stack}`);
       browser.test.notifyFail("window-create");
-    });
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
     },
 
     background,
--- a/browser/components/extensions/test/browser/browser_ext_windows_create_url.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create_url.js
@@ -3,17 +3,17 @@
 "use strict";
 
 add_task(function* testWindowCreate() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["tabs"],
     },
 
-    background() {
+    background: async function() {
       const EXTENSION_URL = browser.runtime.getURL("test.html");
       const REMOTE_URL = browser.runtime.getURL("test.html");
 
       let windows = new class extends Map { // eslint-disable-line new-parens
         get(id) {
           if (!this.has(id)) {
             let window = {
               tabs: new Map(),
@@ -35,47 +35,47 @@ add_task(function* testWindowCreate() {
           window.tabs.set(tab.index, tab);
 
           if (window.tabs.size === window.expectedTabs) {
             window.resolvePromise(window);
           }
         }
       });
 
-      function create(options) {
-        return browser.windows.create(options).then(window => {
-          let win = windows.get(window.id);
+      async function create(options) {
+        let window = await browser.windows.create(options);
+        let win = windows.get(window.id);
 
-          win.expectedTabs = Array.isArray(options.url) ? options.url.length : 1;
+        win.expectedTabs = Array.isArray(options.url) ? options.url.length : 1;
 
-          return win.promise;
-        });
+        return win.promise;
       }
 
-      Promise.all([
-        create({url: REMOTE_URL}),
-        create({url: "test.html"}),
-        create({url: EXTENSION_URL}),
-        create({url: [REMOTE_URL, "test.html", EXTENSION_URL]}),
-      ]).then(windows => {
+      try {
+        let windows = await Promise.all([
+          create({url: REMOTE_URL}),
+          create({url: "test.html"}),
+          create({url: EXTENSION_URL}),
+          create({url: [REMOTE_URL, "test.html", EXTENSION_URL]}),
+        ]);
         browser.test.assertEq(REMOTE_URL, windows[0].tabs.get(0).url, "Single, absolute, remote URL");
 
         browser.test.assertEq(REMOTE_URL, windows[1].tabs.get(0).url, "Single, relative URL");
 
         browser.test.assertEq(REMOTE_URL, windows[2].tabs.get(0).url, "Single, absolute, extension URL");
 
         browser.test.assertEq(REMOTE_URL, windows[3].tabs.get(0).url, "url[0]: Absolute, remote URL");
         browser.test.assertEq(EXTENSION_URL, windows[3].tabs.get(1).url, "url[1]: Relative URL");
         browser.test.assertEq(EXTENSION_URL, windows[3].tabs.get(2).url, "url[2]: Absolute, extension URL");
-      }).then(() => {
+
         browser.test.notifyPass("window-create-url");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-create-url");
-      });
+      }
     },
 
     files: {
       "test.html": `<DOCTYPE html><html><head><meta charset="utf-8"></head></html>`,
     },
   });
 
   yield extension.startup();
--- a/browser/components/extensions/test/browser/browser_ext_windows_events.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_events.js
@@ -1,50 +1,50 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 SimpleTest.requestCompleteLog();
 
 add_task(function* testWindowsEvents() {
   function background() {
-    browser.windows.onCreated.addListener(function listener(window) {
+    browser.windows.onCreated.addListener(window => {
       browser.test.log(`onCreated: windowId=${window.id}`);
 
       browser.test.assertTrue(Number.isInteger(window.id),
                               "Window object's id is an integer");
       browser.test.assertEq("normal", window.type,
                             "Window object returned with the correct type");
       browser.test.sendMessage("window-created", window.id);
     });
 
     let lastWindowId, os;
-    browser.windows.onFocusChanged.addListener(function listener(windowId) {
+    browser.windows.onFocusChanged.addListener(async windowId => {
       browser.test.log(`onFocusChange: windowId=${windowId} lastWindowId=${lastWindowId}`);
 
       if (windowId === browser.windows.WINDOW_ID_NONE && os === "linux") {
         browser.test.log("Ignoring a superfluous WINDOW_ID_NONE (blur) event on Linux");
         return;
       }
 
       browser.test.assertTrue(lastWindowId !== windowId,
                               "onFocusChanged fired once for the given window");
       lastWindowId = windowId;
 
       browser.test.assertTrue(Number.isInteger(windowId),
                               "windowId is an integer");
 
-      browser.windows.getLastFocused().then(window => {
-        browser.test.assertEq(windowId, window.id,
-                              "Last focused window has the correct id");
-        browser.test.sendMessage(`window-focus-changed`, window.id);
-      });
+      let window = await browser.windows.getLastFocused();
+
+      browser.test.assertEq(windowId, window.id,
+                            "Last focused window has the correct id");
+      browser.test.sendMessage(`window-focus-changed`, window.id);
     });
 
-    browser.windows.onRemoved.addListener(function listener(windowId) {
+    browser.windows.onRemoved.addListener(windowId => {
       browser.test.log(`onRemoved: windowId=${windowId}`);
 
       browser.test.assertTrue(Number.isInteger(windowId),
                               "windowId is an integer");
       browser.test.sendMessage(`window-removed`, windowId);
       browser.test.notifyPass("windows.events");
     });
 
--- a/browser/components/extensions/test/browser/browser_ext_windows_size.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_size.js
@@ -1,15 +1,15 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testWindowCreate() {
   let extension = ExtensionTestUtils.loadExtension({
-    background() {
+    async background() {
       let _checkWindowPromise;
       browser.test.onMessage.addListener((msg, arg) => {
         if (msg == "checked-window") {
           _checkWindowPromise.resolve(arg);
           _checkWindowPromise = null;
         }
       });
 
@@ -23,83 +23,73 @@ add_task(function* testWindowCreate() {
       const KEYS = ["left", "top", "width", "height"];
       function checkGeom(expected, actual) {
         for (let key of KEYS) {
           browser.test.assertEq(expected[key], actual[key], `Expected '${key}' value`);
         }
       }
 
       let windowId;
-      function checkWindow(expected, retries = 5) {
-        return getWindowSize().then(geom => {
-          if (retries && KEYS.some(key => expected[key] != geom[key])) {
-            browser.test.log(`Got mismatched size (${JSON.stringify(expected)} != ${JSON.stringify(geom)}). ` +
-                             `Retrying after a short delay.`);
+      async function checkWindow(expected, retries = 5) {
+        let geom = await getWindowSize();
+
+        if (retries && KEYS.some(key => expected[key] != geom[key])) {
+          browser.test.log(`Got mismatched size (${JSON.stringify(expected)} != ${JSON.stringify(geom)}). ` +
+                           `Retrying after a short delay.`);
+
+          await new Promise(resolve => setTimeout(resolve, 200));
 
-            return new Promise(resolve => {
-              setTimeout(resolve, 200);
-            }).then(() => {
-              return checkWindow(expected, retries - 1);
-            });
-          }
+          return checkWindow(expected, retries - 1);
+        }
+
+        browser.test.log(`Check actual window size`);
+        checkGeom(expected, geom);
 
-          browser.test.log(`Check actual window size`);
-          checkGeom(expected, geom);
+        browser.test.log("Check API-reported window size");
 
-          browser.test.log("Check API-reported window size");
-          return browser.windows.get(windowId).then(geom => {
-            checkGeom(expected, geom);
-          });
-        });
+        geom = await browser.windows.get(windowId);
+
+        checkGeom(expected, geom);
       }
 
-      let geom = {left: 100, top: 100, width: 500, height: 300};
+      try {
+        let geom = {left: 100, top: 100, width: 500, height: 300};
 
-      return browser.windows.create(geom).then(window => {
+        let window = await browser.windows.create(geom);
         windowId = window.id;
 
-        return checkWindow(geom);
-      }).then(() => {
+        await checkWindow(geom);
+
         let update = {left: 150, width: 600};
         Object.assign(geom, update);
-
-        return browser.windows.update(windowId, update);
-      }).then(() => {
-        return checkWindow(geom);
-      }).then(() => {
-        let update = {top: 150, height: 400};
-        Object.assign(geom, update);
+        await browser.windows.update(windowId, update);
+        await checkWindow(geom);
 
-        return browser.windows.update(windowId, update);
-      }).then(() => {
-        return checkWindow(geom);
-      }).then(() => {
-        geom = {left: 200, top: 200, width: 800, height: 600};
+        update = {top: 150, height: 400};
+        Object.assign(geom, update);
+        await browser.windows.update(windowId, update);
+        await checkWindow(geom);
 
-        return browser.windows.update(windowId, geom);
-      }).then(() => {
-        return checkWindow(geom);
-      }).then(() => {
-        return browser.runtime.getPlatformInfo();
-      }).then((platformInfo) => {
+        geom = {left: 200, top: 200, width: 800, height: 600};
+        await browser.windows.update(windowId, geom);
+        await checkWindow(geom);
+
+        let platformInfo = await browser.runtime.getPlatformInfo();
         if (platformInfo.os != "linux") {
           geom = {left: -50, top: -50, width: 800, height: 600};
-
-          return browser.windows.update(windowId, geom).then(() => {
-            return checkWindow(geom);
-          });
+          await browser.windows.update(windowId, geom);
+          await checkWindow(geom);
         }
-      }).then(() => {
-        return browser.windows.remove(windowId);
-      }).then(() => {
+
+        await browser.windows.remove(windowId);
         browser.test.notifyPass("window-size");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-size");
-      });
+      }
     },
   });
 
   let latestWindow;
   let windowListener = (window, topic) => {
     if (topic == "domwindowopened") {
       latestWindow = window;
     }
--- a/browser/components/extensions/test/browser/browser_ext_windows_update.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_update.js
@@ -46,17 +46,17 @@ add_task(function* () {
   yield extension.unload();
 
   yield BrowserTestUtils.closeWindow(window2);
 });
 
 
 add_task(function* testWindowUpdate() {
   let extension = ExtensionTestUtils.loadExtension({
-    background() {
+    async background() {
       let _checkWindowPromise;
       browser.test.onMessage.addListener(msg => {
         if (msg == "checked-window") {
           _checkWindowPromise.resolve();
           _checkWindowPromise = null;
         }
       });
 
@@ -64,49 +64,53 @@ add_task(function* testWindowUpdate() {
       function checkWindow(expected) {
         return new Promise(resolve => {
           _checkWindowPromise = {resolve};
           browser.test.sendMessage("check-window", expected);
         });
       }
 
       let currentWindowId;
-      function updateWindow(windowId, params, expected) {
-        return browser.windows.update(windowId, params).then(window => {
-          browser.test.assertEq(currentWindowId, window.id, "Expected WINDOW_ID_CURRENT to refer to the same window");
-          for (let key of Object.keys(params)) {
-            if (key == "state" && os == "mac" && params.state == "normal") {
-              // OS-X doesn't have a hard distinction between "normal" and
-              // "maximized" states.
-              browser.test.assertTrue(window.state == "normal" || window.state == "maximized",
-                                      `Expected window.state (currently ${window.state}) to be "normal" but will accept "maximized"`);
-            } else {
-              browser.test.assertEq(params[key], window[key], `Got expected value for window.${key}`);
-            }
+      async function updateWindow(windowId, params, expected) {
+        let window = await browser.windows.update(windowId, params);
+
+        browser.test.assertEq(currentWindowId, window.id, "Expected WINDOW_ID_CURRENT to refer to the same window");
+        for (let key of Object.keys(params)) {
+          if (key == "state" && os == "mac" && params.state == "normal") {
+            // OS-X doesn't have a hard distinction between "normal" and
+            // "maximized" states.
+            browser.test.assertTrue(window.state == "normal" || window.state == "maximized",
+                                    `Expected window.state (currently ${window.state}) to be "normal" but will accept "maximized"`);
+          } else {
+            browser.test.assertEq(params[key], window[key], `Got expected value for window.${key}`);
           }
+        }
 
-          return checkWindow(expected);
-        });
+        return checkWindow(expected);
       }
 
-      let windowId = browser.windows.WINDOW_ID_CURRENT;
+      try {
+        let windowId = browser.windows.WINDOW_ID_CURRENT;
+
+        ({os} = await browser.runtime.getPlatformInfo());
+
+        let window = await browser.windows.getCurrent();
+        currentWindowId = window.id;
 
-      browser.runtime.getPlatformInfo().then(info => { os = info.os; })
-      .then(() => browser.windows.getCurrent().then(window => { currentWindowId = window.id; }))
-      .then(() => updateWindow(windowId, {state: "maximized"}, {state: "STATE_MAXIMIZED"}))
-      .then(() => updateWindow(windowId, {state: "minimized"}, {state: "STATE_MINIMIZED"}))
-      .then(() => updateWindow(windowId, {state: "normal"}, {state: "STATE_NORMAL"}))
-      .then(() => updateWindow(windowId, {state: "fullscreen"}, {state: "STATE_FULLSCREEN"}))
-      .then(() => updateWindow(windowId, {state: "normal"}, {state: "STATE_NORMAL"}))
-      .then(() => {
+        await updateWindow(windowId, {state: "maximized"}, {state: "STATE_MAXIMIZED"});
+        await updateWindow(windowId, {state: "minimized"}, {state: "STATE_MINIMIZED"});
+        await updateWindow(windowId, {state: "normal"}, {state: "STATE_NORMAL"});
+        await updateWindow(windowId, {state: "fullscreen"}, {state: "STATE_FULLSCREEN"});
+        await updateWindow(windowId, {state: "normal"}, {state: "STATE_NORMAL"});
+
         browser.test.notifyPass("window-update");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-update");
-      });
+      }
     },
   });
 
   extension.onMessage("check-window", expected => {
     if (expected.state != null) {
       let {windowState} = window;
       if (window.fullScreen) {
         windowState = window.STATE_FULLSCREEN;
@@ -152,17 +156,17 @@ add_task(function* () {
 
   yield BrowserTestUtils.closeWindow(window2);
 });
 
 
 // Tests that incompatible parameters can't be used together.
 add_task(function* testWindowUpdateParams() {
   let extension = ExtensionTestUtils.loadExtension({
-    background() {
+    async background() {
       function* getCalls() {
         for (let state of ["minimized", "maximized", "fullscreen"]) {
           for (let param of ["left", "top", "width", "height"]) {
             let expected = `"state": "${state}" may not be combined with "left", "top", "width", or "height"`;
 
             let windowId = browser.windows.WINDOW_ID_CURRENT;
             yield browser.windows.update(windowId, {state, [param]: 100}).then(
               val => {
@@ -172,21 +176,22 @@ add_task(function* testWindowUpdateParam
                 browser.test.assertTrue(
                   error.message.includes(expected),
                   `Got expected error (got: '${error.message}', expected: '${expected}'`);
               });
           }
         }
       }
 
-      Promise.all(getCalls()).then(() => {
+      try {
+        await Promise.all(getCalls());
         browser.test.notifyPass("window-update-params");
-      }).catch(e => {
+      } catch (e) {
         browser.test.fail(`${e} :: ${e.stack}`);
         browser.test.notifyFail("window-update-params");
-      });
+      }
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("window-update-params");
   yield extension.unload();
 });
--- a/toolkit/components/extensions/.eslintrc.js
+++ b/toolkit/components/extensions/.eslintrc.js
@@ -1,13 +1,17 @@
 "use strict";
 
 module.exports = { // eslint-disable-line no-undef
   "extends": "../../.eslintrc.js",
 
+  "parserOptions": {
+    "ecmaVersion": 8,
+  },
+
   "globals": {
     "Cc": true,
     "Ci": true,
     "Components": true,
     "Cr": true,
     "Cu": true,
     "dump": true,
     "TextDecoder": false,
@@ -27,17 +31,17 @@ module.exports = { // eslint-disable-lin
     "TabManager": true,
     "WindowListManager": true,
     "XPCOMUtils": true,
   },
 
   "rules": {
     // Rules from the mozilla plugin
     "mozilla/balanced-listeners": 2,
-    "mozilla/no-aArgs": 1,
+    "mozilla/no-aArgs": 2,
     "mozilla/no-cpows-in-tests": 1,
     "mozilla/var-only-at-top-level": 1,
 
     "valid-jsdoc": [2, {
       "prefer": {
         "return": "returns",
       },
       "preferType": {
@@ -75,17 +79,17 @@ module.exports = { // eslint-disable-lin
 
     // No space before always a space after a comma
     "comma-spacing": [2, {"before": false, "after": true}],
 
     // Commas at the end of the line not the start
     "comma-style": 2,
 
     // Don't require spaces around computed properties
-    "computed-property-spacing": [1, "never"],
+    "computed-property-spacing": [2, "never"],
 
     // Functions are not required to consistently return something or nothing
     "consistent-return": 0,
 
     // Require braces around blocks that start a new line
     "curly": [2, "all"],
 
     // Always require a trailing EOL
--- a/toolkit/components/extensions/test/mochitest/.eslintrc.js
+++ b/toolkit/components/extensions/test/mochitest/.eslintrc.js
@@ -15,9 +15,13 @@ module.exports = { // eslint-disable-lin
     "waitForLoad": true,
     "promiseConsoleOutput": true,
 
     "ExtensionTestUtils": false,
     "NetUtil": true,
     "webrequest_test": false,
     "XPCOMUtils": true,
   },
+
+  "rules": {
+    "no-shadow": 0,
+  },
 };
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html
@@ -59,17 +59,17 @@ add_task(function* () {
           is("test!", context.testThing, "global context is the background script context");
           resolve();
         }
       },
     });
   });
 
   let addon = yield new Promise((resolve, reject) => {
-    AddonManager.getAddonByID(ID, aAddon => aAddon ? resolve(aAddon) : reject());
+    AddonManager.getAddonByID(ID, addon => addon ? resolve(addon) : reject());
   });
 
   ok(addon, `Got the addon wrapper for ${addon.id}`);
 
   function waitForDebugGlobalChanges(times, initialAddonInstanceID) {
     return new Promise((resolve) => {
       AddonManager.addAddonListener({
         count: 0,
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
@@ -13,26 +13,25 @@
 
 <script type="text/javascript">
 "use strict";
 
 const BASE = "http://mochi.test:8888/chrome/toolkit/components/extensions/test/mochitest";
 
 add_task(function* test_contentscript() {
   function background() {
-    browser.runtime.onMessage.addListener((msg) => {
+    browser.runtime.onMessage.addListener(async (msg) => {
       if (msg == "loaded") {
-        browser.tabs.query({active: true, currentWindow: true}).then((tabs) => {
-          // NOTE: we're removing the tab from here because doing a win.close()
-          // from the chrome test code is raising a "TypeError: can 't access
-          // dead object" exception.
-          browser.tabs.remove(tabs[0].id);
+        // NOTE: we're removing the tab from here because doing a win.close()
+        // from the chrome test code is raising a "TypeError: can't access
+        // dead object" exception.
+        let tabs = await browser.tabs.query({active: true, currentWindow: true});
+        await browser.tabs.remove(tabs[0].id);
 
-          browser.test.notifyPass("content-script-loaded");
-        });
+        browser.test.notifyPass("content-script-loaded");
       }
     });
   }
 
   function contentScript() {
     chrome.runtime.sendMessage("loaded");
   }
 
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
@@ -10,25 +10,28 @@
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_downloads_saveAs() {
   function background() {
     const url = URL.createObjectURL(new Blob(["file content"]));
-    browser.test.onMessage.addListener(() =>
-      browser.downloads.download({url, saveAs: true})
-        .then(id => browser.downloads.onChanged.addListener(delta => {
+    browser.test.onMessage.addListener(async () => {
+      try {
+        let id = await browser.downloads.download({url, saveAs: true});
+        browser.downloads.onChanged.addListener(delta => {
           if (delta.state.current === "complete") {
             browser.test.sendMessage("done", {ok: true, id});
           }
-        })).catch(({message}) => {
-          browser.test.sendMessage("done", {ok: false, message});
-        }));
+        });
+      } catch ({message}) {
+        browser.test.sendMessage("done", {ok: false, message});
+      }
+    });
     browser.test.sendMessage("ready");
   }
 
   const {MockFilePicker} = SpecialPowers;
   const manifest = {background, manifest: {permissions: ["downloads"]}};
   const extension = ExtensionTestUtils.loadExtension(manifest);
 
   MockFilePicker.init(window);
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html
@@ -95,23 +95,22 @@ add_task(function* test_sdk_hybrid_addon
   function backgroundScript() {
     browser.runtime.sendMessage("background message", (reply) => {
       browser.test.assertEq("sdk received message: background message", reply,
                             "Got the expected reply from the SDK context");
       browser.test.notifyPass("sdk.webext-api.onmessage");
     });
   }
 
-  function sdkMainScript() {
+  async function sdkMainScript() {
     /* globals require */
     const webext = require("sdk/webextension");
-    webext.startup().then(({browser}) => {
-      browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
-        sendReply(`sdk received message: ${msg}`);
-      });
+    let {browser} = await webext.startup();
+    browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
+      sendReply(`sdk received message: ${msg}`);
     });
   }
 
   let id = "fake@sdk.hybrid.addon";
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "temporary",
     files: generateClassicExtensionFiles({
       id,
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
@@ -13,23 +13,22 @@
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* webnav_unresolved_uri_on_expected_URI_scheme() {
   function background() {
     let checkURLs;
 
-    browser.webNavigation.onCompleted.addListener((msg) => {
+    browser.webNavigation.onCompleted.addListener(async msg => {
       if (checkURLs.length > 0) {
         let expectedURL = checkURLs.shift();
         browser.test.assertEq(expectedURL, msg.url, "Got the expected URL");
-        browser.tabs.remove(msg.tabId).then(() => {
-          browser.test.sendMessage("next");
-        });
+        await browser.tabs.remove(msg.tabId);
+        browser.test.sendMessage("next");
       }
     });
 
     browser.test.onMessage.addListener((name, urls) => {
       if (name == "checkURLs") {
         checkURLs = urls;
       }
     });
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies.html
@@ -9,17 +9,17 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_cookies() {
-  function background() {
+  async function background() {
     function assertExpected(expected, cookie) {
       for (let key of Object.keys(cookie)) {
         browser.test.assertTrue(key in expected, `found property ${key}`);
         browser.test.assertEq(expected[key], cookie[key], `property value for ${key} is correct`);
       }
       browser.test.assertEq(Object.keys(expected).length, Object.keys(cookie).length, "all expected properties found");
     }
 
@@ -40,193 +40,195 @@ add_task(function* test_cookies() {
       path: "/",
       secure: false,
       httpOnly: false,
       session: false,
       expirationDate: THE_FUTURE,
       storeId: STORE_ID,
     };
 
-    browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", expirationDate: THE_FUTURE}).then(cookie => {
-      assertExpected(expected, cookie);
-      return browser.cookies.get({url: TEST_URL, name: "name1"});
-    }).then(cookie => {
-      assertExpected(expected, cookie);
-      return browser.cookies.getAll({name: "name1"});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one cookie found for matching name");
-      assertExpected(expected, cookies[0]);
-      return browser.cookies.getAll({domain: "example.org"});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one cookie found for matching domain");
-      assertExpected(expected, cookies[0]);
-      return browser.cookies.getAll({domain: "example.net"});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "no cookies found for non-matching domain");
-      return browser.cookies.getAll({secure: false});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one non-secure cookie found");
-      assertExpected(expected, cookies[0]);
-      return browser.cookies.getAll({secure: true});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "no secure cookies found");
-      return browser.cookies.getAll({storeId: STORE_ID});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one cookie found for valid storeId");
-      assertExpected(expected, cookies[0]);
-      return browser.cookies.getAll({storeId: "invalid_id"});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "no cookies found for invalid storeId");
-      return browser.cookies.remove({url: TEST_URL, name: "name1"});
-    }).then(details => {
-      assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
-      return browser.cookies.get({url: TEST_URL, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(null, cookie, "removed cookie not found");
-      return browser.cookies.getAllCookieStores();
-    }).then(stores => {
-      browser.test.assertEq(1, stores.length, "expected number of stores returned");
+    let cookie = await browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", expirationDate: THE_FUTURE});
+    assertExpected(expected, cookie);
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
+    assertExpected(expected, cookie);
+
+    let cookies = await browser.cookies.getAll({name: "name1"});
+    browser.test.assertEq(cookies.length, 1, "one cookie found for matching name");
+    assertExpected(expected, cookies[0]);
+
+    cookies = await browser.cookies.getAll({domain: "example.org"});
+    browser.test.assertEq(cookies.length, 1, "one cookie found for matching domain");
+    assertExpected(expected, cookies[0]);
+
+    cookies = await browser.cookies.getAll({domain: "example.net"});
+    browser.test.assertEq(cookies.length, 0, "no cookies found for non-matching domain");
+
+    cookies = await browser.cookies.getAll({secure: false});
+    browser.test.assertEq(cookies.length, 1, "one non-secure cookie found");
+    assertExpected(expected, cookies[0]);
+
+    cookies = await browser.cookies.getAll({secure: true});
+    browser.test.assertEq(cookies.length, 0, "no secure cookies found");
+
+    cookies = await browser.cookies.getAll({storeId: STORE_ID});
+    browser.test.assertEq(cookies.length, 1, "one cookie found for valid storeId");
+    assertExpected(expected, cookies[0]);
+
+    cookies = await browser.cookies.getAll({storeId: "invalid_id"});
+    browser.test.assertEq(cookies.length, 0, "no cookies found for invalid storeId");
+
+    let details = await browser.cookies.remove({url: TEST_URL, name: "name1"});
+    assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
+    browser.test.assertEq(null, cookie, "removed cookie not found");
+
+    let stores = await browser.cookies.getAllCookieStores();
+    browser.test.assertEq(1, stores.length, "expected number of stores returned");
+    browser.test.assertEq(STORE_ID, stores[0].id, "expected store id returned");
+    browser.test.assertEq(1, stores[0].tabIds.length, "one tab returned for store");
+
+    {
+      let privateWindow = await browser.windows.create({incognito: true});
+      let stores = await browser.cookies.getAllCookieStores();
+
+      browser.test.assertEq(2, stores.length, "expected number of stores returned");
       browser.test.assertEq(STORE_ID, stores[0].id, "expected store id returned");
       browser.test.assertEq(1, stores[0].tabIds.length, "one tab returned for store");
-      return browser.windows.create({incognito: true});
-    }).then(privateWindow => {
-      return browser.cookies.getAllCookieStores().then(stores => {
-        browser.test.assertEq(2, stores.length, "expected number of stores returned");
-        browser.test.assertEq(STORE_ID, stores[0].id, "expected store id returned");
-        browser.test.assertEq(1, stores[0].tabIds.length, "one tab returned for store");
-        browser.test.assertEq(PRIVATE_STORE_ID, stores[1].id, "expected private store id returned");
-        browser.test.assertEq(1, stores[0].tabIds.length, "one tab returned for private store");
-        return browser.windows.remove(privateWindow.id);
-      });
-    }).then(() => {
-      return browser.cookies.set({url: TEST_URL, name: "name2", domain: ".example.org", expirationDate: THE_FUTURE});
-    }).then(cookie => {
-      browser.test.assertEq(false, cookie.hostOnly, "cookie is not a hostOnly cookie");
-      return browser.cookies.remove({url: TEST_URL, name: "name2"});
-    }).then(details => {
-      assertExpected({url: TEST_URL, name: "name2", storeId: STORE_ID}, details);
-      // Create a session cookie.
-      return browser.cookies.set({url: TEST_URL, name: "name1", value: "value1"});
-    }).then(cookie => {
-      browser.test.assertEq(true, cookie.session, "session cookie set");
-      return browser.cookies.get({url: TEST_URL, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(true, cookie.session, "got session cookie");
-      return browser.cookies.getAll({session: true});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one session cookie found");
-      browser.test.assertEq(true, cookies[0].session, "found session cookie");
-      return browser.cookies.getAll({session: false});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "no non-session cookies found");
-      return browser.cookies.remove({url: TEST_URL, name: "name1"});
-    }).then(details => {
-      assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
-      return browser.cookies.get({url: TEST_URL, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(null, cookie, "removed cookie not found");
-      return browser.cookies.set({url: TEST_SECURE_URL, name: "name1", value: "value1", secure: true});
-    }).then(cookie => {
-      browser.test.assertEq(true, cookie.secure, "secure cookie set");
-      return browser.cookies.get({url: TEST_SECURE_URL, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(true, cookie.session, "got secure cookie");
-      return browser.cookies.getAll({secure: true});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one secure cookie found");
-      browser.test.assertEq(true, cookies[0].secure, "found secure cookie");
-      return browser.cookies.getAll({secure: false});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "no non-secure cookies found");
-      return browser.cookies.remove({url: TEST_SECURE_URL, name: "name1"});
-    }).then(details => {
-      assertExpected({url: TEST_SECURE_URL, name: "name1", storeId: STORE_ID}, details);
-      return browser.cookies.get({url: TEST_SECURE_URL, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(null, cookie, "removed cookie not found");
-      return browser.cookies.set({url: TEST_URL_WITH_PATH, path: TEST_COOKIE_PATH, name: "name1", value: "value1", expirationDate: THE_FUTURE});
-    }).then(cookie => {
-      browser.test.assertEq(TEST_COOKIE_PATH, cookie.path, "created cookie with path");
-      return browser.cookies.get({url: TEST_URL_WITH_PATH, name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(TEST_COOKIE_PATH, cookie.path, "got cookie with path");
-      return browser.cookies.getAll({path: TEST_COOKIE_PATH});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 1, "one cookie with path found");
-      browser.test.assertEq(TEST_COOKIE_PATH, cookies[0].path, "found cookie with path");
-      return browser.cookies.get({url: TEST_URL + "invalid_path", name: "name1"});
-    }).then(cookie => {
-      browser.test.assertEq(null, cookie, "get with invalid path returns null");
-      return browser.cookies.getAll({path: "/invalid_path"});
-    }).then(cookies => {
-      browser.test.assertEq(cookies.length, 0, "getAll with invalid path returns 0 cookies");
-      return browser.cookies.remove({url: TEST_URL_WITH_PATH, name: "name1"});
-    }).then(details => {
-      assertExpected({url: TEST_URL_WITH_PATH, name: "name1", storeId: STORE_ID}, details);
-      return browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", httpOnly: true});
-    }).then(cookie => {
-      browser.test.assertEq(true, cookie.httpOnly, "httpOnly cookie set");
-      return browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", httpOnly: false});
-    }).then(cookie => {
-      browser.test.assertEq(false, cookie.httpOnly, "non-httpOnly cookie set");
-      return browser.cookies.remove({url: TEST_URL, name: "name1"});
-    }).then(details => {
-      assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
-      return browser.cookies.set({url: TEST_URL});
-    }).then(cookie => {
-      browser.test.assertEq("", cookie.name, "default name set");
-      browser.test.assertEq("", cookie.value, "default value set");
-      browser.test.assertEq(true, cookie.session, "no expiry date created session cookie");
-      return browser.windows.create({incognito: true});
-    }).then(privateWindow => {
+      browser.test.assertEq(PRIVATE_STORE_ID, stores[1].id, "expected private store id returned");
+      browser.test.assertEq(1, stores[0].tabIds.length, "one tab returned for private store");
+
+      await browser.windows.remove(privateWindow.id);
+    }
+
+    cookie = await browser.cookies.set({url: TEST_URL, name: "name2", domain: ".example.org", expirationDate: THE_FUTURE});
+    browser.test.assertEq(false, cookie.hostOnly, "cookie is not a hostOnly cookie");
+
+    details = await browser.cookies.remove({url: TEST_URL, name: "name2"});
+    assertExpected({url: TEST_URL, name: "name2", storeId: STORE_ID}, details);
+
+    // Create a session cookie.
+    cookie = await browser.cookies.set({url: TEST_URL, name: "name1", value: "value1"});
+    browser.test.assertEq(true, cookie.session, "session cookie set");
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
+    browser.test.assertEq(true, cookie.session, "got session cookie");
+
+    cookies = await browser.cookies.getAll({session: true});
+    browser.test.assertEq(cookies.length, 1, "one session cookie found");
+    browser.test.assertEq(true, cookies[0].session, "found session cookie");
+
+    cookies = await browser.cookies.getAll({session: false});
+    browser.test.assertEq(cookies.length, 0, "no non-session cookies found");
+
+    details = await browser.cookies.remove({url: TEST_URL, name: "name1"});
+    assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
+    browser.test.assertEq(null, cookie, "removed cookie not found");
+
+    cookie = await browser.cookies.set({url: TEST_SECURE_URL, name: "name1", value: "value1", secure: true});
+    browser.test.assertEq(true, cookie.secure, "secure cookie set");
+
+    cookie = await browser.cookies.get({url: TEST_SECURE_URL, name: "name1"});
+    browser.test.assertEq(true, cookie.session, "got secure cookie");
+
+    cookies = await browser.cookies.getAll({secure: true});
+    browser.test.assertEq(cookies.length, 1, "one secure cookie found");
+    browser.test.assertEq(true, cookies[0].secure, "found secure cookie");
+
+    cookies = await browser.cookies.getAll({secure: false});
+    browser.test.assertEq(cookies.length, 0, "no non-secure cookies found");
+
+    details = await browser.cookies.remove({url: TEST_SECURE_URL, name: "name1"});
+    assertExpected({url: TEST_SECURE_URL, name: "name1", storeId: STORE_ID}, details);
+
+    cookie = await browser.cookies.get({url: TEST_SECURE_URL, name: "name1"});
+    browser.test.assertEq(null, cookie, "removed cookie not found");
+
+    cookie = await browser.cookies.set({url: TEST_URL_WITH_PATH, path: TEST_COOKIE_PATH, name: "name1", value: "value1", expirationDate: THE_FUTURE});
+    browser.test.assertEq(TEST_COOKIE_PATH, cookie.path, "created cookie with path");
+
+    cookie = await browser.cookies.get({url: TEST_URL_WITH_PATH, name: "name1"});
+    browser.test.assertEq(TEST_COOKIE_PATH, cookie.path, "got cookie with path");
+
+    cookies = await browser.cookies.getAll({path: TEST_COOKIE_PATH});
+    browser.test.assertEq(cookies.length, 1, "one cookie with path found");
+    browser.test.assertEq(TEST_COOKIE_PATH, cookies[0].path, "found cookie with path");
+
+    cookie = await browser.cookies.get({url: TEST_URL + "invalid_path", name: "name1"});
+    browser.test.assertEq(null, cookie, "get with invalid path returns null");
+
+    cookies = await browser.cookies.getAll({path: "/invalid_path"});
+    browser.test.assertEq(cookies.length, 0, "getAll with invalid path returns 0 cookies");
+
+    details = await browser.cookies.remove({url: TEST_URL_WITH_PATH, name: "name1"});
+    assertExpected({url: TEST_URL_WITH_PATH, name: "name1", storeId: STORE_ID}, details);
+
+    cookie = await browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", httpOnly: true});
+    browser.test.assertEq(true, cookie.httpOnly, "httpOnly cookie set");
+
+    cookie = await browser.cookies.set({url: TEST_URL, name: "name1", value: "value1", httpOnly: false});
+    browser.test.assertEq(false, cookie.httpOnly, "non-httpOnly cookie set");
+
+    details = await browser.cookies.remove({url: TEST_URL, name: "name1"});
+    assertExpected({url: TEST_URL, name: "name1", storeId: STORE_ID}, details);
+
+    cookie = await browser.cookies.set({url: TEST_URL});
+    browser.test.assertEq("", cookie.name, "default name set");
+    browser.test.assertEq("", cookie.value, "default value set");
+    browser.test.assertEq(true, cookie.session, "no expiry date created session cookie");
+
+    {
+      let privateWindow = await browser.windows.create({incognito: true});
+
       // Hacky work-around for bugzil.la/1309637
-      return new Promise(resolve => setTimeout(resolve, 700, privateWindow));
-    }).then(privateWindow => {
-      return browser.cookies.set({url: TEST_URL, name: "store", value: "private", expirationDate: THE_FUTURE, storeId: PRIVATE_STORE_ID}).then(cookie => {
-        browser.test.assertEq("private", cookie.value, "set the private cookie");
-        return browser.cookies.set({url: TEST_URL, name: "store", value: "default", expirationDate: THE_FUTURE, storeId: STORE_ID});
-      }).then(cookie => {
-        browser.test.assertEq("default", cookie.value, "set the default cookie");
-        return browser.cookies.get({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
-      }).then(cookie => {
-        browser.test.assertEq("private", cookie.value, "get the private cookie");
-        browser.test.assertEq(PRIVATE_STORE_ID, cookie.storeId, "get the private cookie storeId");
-        return browser.cookies.get({url: TEST_URL, name: "store", storeId: STORE_ID});
-      }).then(cookie => {
-        browser.test.assertEq("default", cookie.value, "get the default cookie");
-        browser.test.assertEq(STORE_ID, cookie.storeId, "get the default cookie storeId");
-        return browser.cookies.remove({url: TEST_URL, name: "store", storeId: STORE_ID});
-      }).then(details => {
-        assertExpected({url: TEST_URL, name: "store", storeId: STORE_ID}, details);
-        return browser.cookies.get({url: TEST_URL, name: "store", storeId: STORE_ID});
-      }).then(cookie => {
-        browser.test.assertEq(null, cookie, "deleted the default cookie");
-        return browser.cookies.remove({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
-      }).then(details => {
-        assertExpected({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID}, details);
-        return browser.cookies.get({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
-      }).then(cookie => {
-        browser.test.assertEq(null, cookie, "deleted the private cookie");
-        return browser.windows.remove(privateWindow.id);
-      });
-    }).then(() => {
-      browser.test.notifyPass("cookies");
-    });
+      await new Promise(resolve => setTimeout(resolve, 700));
+
+      let cookie = await browser.cookies.set({url: TEST_URL, name: "store", value: "private", expirationDate: THE_FUTURE, storeId: PRIVATE_STORE_ID});
+      browser.test.assertEq("private", cookie.value, "set the private cookie");
+
+      cookie = await browser.cookies.set({url: TEST_URL, name: "store", value: "default", expirationDate: THE_FUTURE, storeId: STORE_ID});
+      browser.test.assertEq("default", cookie.value, "set the default cookie");
+
+      cookie = await browser.cookies.get({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
+      browser.test.assertEq("private", cookie.value, "get the private cookie");
+      browser.test.assertEq(PRIVATE_STORE_ID, cookie.storeId, "get the private cookie storeId");
+
+      cookie = await browser.cookies.get({url: TEST_URL, name: "store", storeId: STORE_ID});
+      browser.test.assertEq("default", cookie.value, "get the default cookie");
+      browser.test.assertEq(STORE_ID, cookie.storeId, "get the default cookie storeId");
+
+      let details = await browser.cookies.remove({url: TEST_URL, name: "store", storeId: STORE_ID});
+      assertExpected({url: TEST_URL, name: "store", storeId: STORE_ID}, details);
+
+      cookie = await browser.cookies.get({url: TEST_URL, name: "store", storeId: STORE_ID});
+      browser.test.assertEq(null, cookie, "deleted the default cookie");
+
+      details = await browser.cookies.remove({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
+      assertExpected({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID}, details);
+
+      cookie = await browser.cookies.get({url: TEST_URL, name: "store", storeId: PRIVATE_STORE_ID});
+      browser.test.assertEq(null, cookie, "deleted the private cookie");
+
+      await browser.windows.remove(privateWindow.id);
+    }
+
+    browser.test.notifyPass("cookies");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["cookies", "*://example.org/"],
     },
   });
 
   yield extension.startup();
-  info("extension loaded");
   yield extension.awaitFinish("cookies");
   yield extension.unload();
-  info("extension unloaded");
 });
 
 </script>
 
 </body>
 </html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
@@ -17,17 +17,17 @@
 add_task(function* setup() {
   // make sure userContext is enabled.
   return SpecialPowers.pushPrefEnv({"set": [
     ["privacy.userContext.enabled", true],
   ]});
 });
 
 add_task(function* test_cookie_containers() {
-  function background() {
+  async function background() {
     function assertExpected(expected, cookie) {
       for (let key of Object.keys(cookie)) {
         browser.test.assertTrue(key in expected, `found property ${key}`);
         browser.test.assertEq(expected[key], cookie[key], `property value for ${key} is correct`);
       }
       browser.test.assertEq(Object.keys(expected).length, Object.keys(cookie).length, "all expected properties found");
     }
 
@@ -42,49 +42,42 @@ add_task(function* test_cookie_container
       path: "/",
       secure: false,
       httpOnly: false,
       session: false,
       expirationDate: THE_FUTURE,
       storeId: "firefox-container-1",
     };
 
-    browser.cookies.set({url: TEST_URL, name: "name1", value: "value1",
-                         expirationDate: THE_FUTURE, storeId: "firefox-container-1"})
-    .then(cookie => {
-      browser.test.assertEq("firefox-container-1", cookie.storeId, "the cookie has the correct storeId");
-      return browser.cookies.get({url: TEST_URL, name: "name1"});
-    })
-    .then(cookie => {
-      browser.test.assertEq(null, cookie, "get() without storeId returns null");
-      return browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
-    })
-    .then(cookie => {
-      assertExpected(expected, cookie);
-      return browser.cookies.getAll({storeId: "firefox-default"});
-    })
-    .then(cookies => {
-      browser.test.assertEq(0, cookies.length, "getAll() with default storeId returns an empty array");
-      return browser.cookies.getAll({storeId: "firefox-container-1"});
-    })
-    .then(cookies => {
-      browser.test.assertEq(1, cookies.length, "one cookie found for matching domain");
-      assertExpected(expected, cookies[0]);
-      return browser.cookies.remove({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
-    })
-    .then(details => {
-      assertExpected({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}, details);
-      return browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
-    })
-    .then(cookie => {
-      browser.test.assertEq(null, cookie, "removed cookie not found");
-    })
-    .then(() => {
-      browser.test.notifyPass("cookies");
+    let cookie = await browser.cookies.set({
+      url: TEST_URL, name: "name1", value: "value1",
+      expirationDate: THE_FUTURE, storeId: "firefox-container-1",
     });
+    browser.test.assertEq("firefox-container-1", cookie.storeId, "the cookie has the correct storeId");
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
+    browser.test.assertEq(null, cookie, "get() without storeId returns null");
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
+    assertExpected(expected, cookie);
+
+    let cookies = await browser.cookies.getAll({storeId: "firefox-default"});
+    browser.test.assertEq(0, cookies.length, "getAll() with default storeId returns an empty array");
+
+    cookies = await browser.cookies.getAll({storeId: "firefox-container-1"});
+    browser.test.assertEq(1, cookies.length, "one cookie found for matching domain");
+    assertExpected(expected, cookies[0]);
+
+    let details = await browser.cookies.remove({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
+    assertExpected({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}, details);
+
+    cookie = await browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
+    browser.test.assertEq(null, cookie, "removed cookie not found");
+
+    browser.test.notifyPass("cookies");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["cookies", "*://example.org/"],
     },
   });
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
@@ -14,17 +14,17 @@
 <script type="text/javascript">
 "use strict";
 
 function* testCookies(options) {
   // Changing the options object is a bit of a hack, but it allows us to easily
   // pass an expiration date to the background script.
   options.expiry = Date.now() / 1000 + 3600;
 
-  function background(backgroundOptions) {
+  async function background(backgroundOptions) {
     // Ask the parent scope to change some cookies we may or may not have
     // permission for.
     let awaitChanges = new Promise(resolve => {
       browser.test.onMessage.addListener(msg => {
         browser.test.assertEq("cookies-changed", msg, "browser.test.onMessage");
         resolve();
       });
     });
@@ -39,35 +39,35 @@ function* testCookies(options) {
     // Try to access some cookies in various ways.
     let {url, domain, secure} = backgroundOptions;
 
     let failures = 0;
     let tallyFailure = error => {
       failures++;
     };
 
-    awaitChanges.then(() => {
-      return browser.cookies.get({url, name: "foo"});
-    }).then(cookie => {
+    try {
+      await awaitChanges;
+
+      let cookie = await browser.cookies.get({url, name: "foo"});
       browser.test.assertEq(backgroundOptions.shouldPass, cookie != null, "should pass == get cookie");
 
-      return browser.cookies.getAll({domain});
-    }).then(cookies => {
+      let cookies = await browser.cookies.getAll({domain});
       if (backgroundOptions.shouldPass) {
         browser.test.assertEq(2, cookies.length, "expected number of cookies");
       } else {
         browser.test.assertEq(0, cookies.length, "expected number of cookies");
       }
 
-      return Promise.all([
+      await Promise.all([
         browser.cookies.set({url, domain, secure, name: "foo", "value": "baz", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
         browser.cookies.set({url, domain, secure, name: "bar", "value": "quux", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
         browser.cookies.remove({url, name: "deleted"}),
       ]);
-    }).then(() => {
+
       if (backgroundOptions.shouldPass) {
         // The order of eviction events isn't guaranteed, so just check that
         // it's there somewhere.
         let evicted = changed.indexOf("evicted:evicted");
         if (evicted < 0) {
           browser.test.fail("got no eviction event");
         } else {
           browser.test.succeed("got eviction event");
@@ -75,26 +75,27 @@ function* testCookies(options) {
         }
 
         browser.test.assertEq("x:explicit,x:overwrite,x:explicit,x:explicit,foo:overwrite,foo:explicit,bar:explicit,deleted:explicit",
                               changed.join(","), "expected changes");
       } else {
         browser.test.assertEq("", changed.join(","), "expected no changes");
       }
 
-      browser.test.notifyPass("cookie-permissions");
-    }).then(() => {
       if (!(backgroundOptions.shouldPass || backgroundOptions.shouldWrite)) {
         browser.test.assertEq(2, failures, "Expected failures");
       } else {
         browser.test.assertEq(0, failures, "Expected no failures");
       }
-    }).catch(error => {
+
+      browser.test.notifyPass("cookie-permissions");
+    } catch (error) {
       browser.test.fail(`Error: ${error} :: ${error.stack}`);
-    });
+      browser.test.notifyFail("cookie-permissions");
+    }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": options.permissions,
     },
 
     background: `(${background})(${JSON.stringify(options)})`,
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
@@ -178,27 +178,24 @@ add_task(function* test_get_accept_langu
 
     let tabId;
 
     browser.tabs.query({currentWindow: true, active: true}, tabs => {
       tabId = tabs[0].id;
       browser.test.sendMessage("ready");
     });
 
-    browser.test.onMessage.addListener(([msg, expected]) => {
-      Promise.all([
-        new Promise(
-          resolve => browser.tabs.sendMessage(tabId, "get-results", resolve)),
-        browser.i18n.getAcceptLanguages(),
-      ]).then(([contentResults, backgroundResults]) => {
-        checkResults("contentScript", contentResults, expected);
-        checkResults("background", backgroundResults, expected);
+    browser.test.onMessage.addListener(async ([msg, expected]) => {
+      let contentResults = await browser.tabs.sendMessage(tabId, "get-results");
+      let backgroundResults = await browser.i18n.getAcceptLanguages();
 
-        browser.test.sendMessage("done");
-      });
+      checkResults("contentScript", contentResults, expected);
+      checkResults("background", backgroundResults, expected);
+
+      browser.test.sendMessage("done");
     });
   }
 
   function content() {
     browser.runtime.onMessage.addListener((msg, sender, respond) => {
       browser.i18n.getAcceptLanguages(respond);
       return true;
     });
@@ -352,27 +349,24 @@ add_task(function* test_detect_language(
 
     let tabId;
 
     browser.tabs.query({currentWindow: true, active: true}, tabs => {
       tabId = tabs[0].id;
       browser.test.sendMessage("ready");
     });
 
-    browser.test.onMessage.addListener(([msg, expected]) => {
-      Promise.all([
-        browser.i18n.detectLanguage(msg),
-        new Promise(
-          resolve => browser.tabs.sendMessage(tabId, msg, resolve)),
-      ]).then(([backgroundResults, contentResults]) => {
-        checkResult("background", backgroundResults, expected);
-        checkResult("contentScript", contentResults, expected);
+    browser.test.onMessage.addListener(async ([msg, expected]) => {
+      let backgroundResults = await browser.i18n.detectLanguage(msg);
+      let contentResults = await browser.tabs.sendMessage(tabId, msg);
 
-        browser.test.sendMessage("done");
-      });
+      checkResult("background", backgroundResults, expected);
+      checkResult("contentScript", contentResults, expected);
+
+      browser.test.sendMessage("done");
     });
   }
 
   function content() {
     browser.runtime.onMessage.addListener((msg, sender, respond) => {
       browser.i18n.detectLanguage(msg, respond);
       return true;
     });
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
@@ -14,44 +14,44 @@
 
 // A 1x1 PNG image.
 // Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
 let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
                  "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
 const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer;
 
 add_task(function* test_notification() {
-  function background() {
+  async function background() {
     let opts = {
       type: "basic",
       title: "Testing Notification",
       message: "Carry on",
     };
 
-    browser.notifications.create(opts).then(id => {
-      browser.test.sendMessage("running", id);
-      browser.test.notifyPass("background test passed");
-    });
+    let id = await browser.notifications.create(opts);
+
+    browser.test.sendMessage("running", id);
+    browser.test.notifyPass("background test passed");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
   });
   yield extension.startup();
   let x = yield extension.awaitMessage("running");
   is(x, "0", "got correct id from notifications.create");
   yield extension.awaitFinish();
   yield extension.unload();
 });
 
 add_task(function* test_notification_events() {
-  function background() {
+  async function background() {
     let opts = {
       type: "basic",
       title: "Testing Notification",
       message: "Carry on",
     };
 
     // Test an ignored listener.
     browser.notifications.onButtonClicked.addListener(function() {});
@@ -61,21 +61,19 @@ add_task(function* test_notification_eve
     browser.notifications.onClicked.addListener(function() {});
 
     // Test onClosed listener.
     browser.notifications.onClosed.addListener(id => {
       browser.test.sendMessage("closed", id);
       browser.test.notifyPass("background test passed");
     });
 
-    browser.notifications.create("5", opts).then(id => {
-      return browser.notifications.create("5", opts);
-    }).then(id => {
-      browser.test.sendMessage("running", id);
-    });
+    await browser.notifications.create("5", opts);
+    let id = await browser.notifications.create("5", opts);
+    browser.test.sendMessage("running", id);
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
   });
@@ -84,33 +82,33 @@ add_task(function* test_notification_eve
   is(x, "5", "got correct id from onClosed listener");
   x = yield extension.awaitMessage("running");
   is(x, "5", "got correct id from notifications.create");
   yield extension.awaitFinish();
   yield extension.unload();
 });
 
 add_task(function* test_notification_clear() {
-  function background() {
+  async function background() {
     let opts = {
       type: "basic",
       title: "Testing Notification",
       message: "Carry on",
     };
 
     browser.notifications.onClosed.addListener(id => {
       browser.test.sendMessage("closed", id);
     });
 
-    browser.notifications.create("99", opts).then(id => {
-      return browser.notifications.clear(id);
-    }).then(wasCleared => {
-      browser.test.sendMessage("cleared", wasCleared);
-      browser.test.notifyPass("background test passed");
-    });
+    let id = await browser.notifications.create("99", opts);
+
+    let wasCleared = await browser.notifications.clear(id);
+    browser.test.sendMessage("cleared", wasCleared);
+
+    browser.test.notifyPass("background test passed");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
   });
@@ -119,62 +117,62 @@ add_task(function* test_notification_cle
   is(x, "99", "got correct id from onClosed listener");
   x = yield extension.awaitMessage("cleared");
   is(x, true, "got correct boolean from notifications.clear");
   yield extension.awaitFinish();
   yield extension.unload();
 });
 
 add_task(function* test_notifications_empty_getAll() {
-  function background() {
-    browser.notifications.getAll().then(notifications => {
-      browser.test.assertEq("object", typeof notifications, "getAll() returned an object");
-      browser.test.assertEq(0, Object.keys(notifications).length, "the object has no properties");
-      browser.test.notifyPass("getAll empty");
-    });
+  async function background() {
+    let notifications = await browser.notifications.getAll();
+
+    browser.test.assertEq("object", typeof notifications, "getAll() returned an object");
+    browser.test.assertEq(0, Object.keys(notifications).length, "the object has no properties");
+    browser.test.notifyPass("getAll empty");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
   });
   yield extension.startup();
   yield extension.awaitFinish("getAll empty");
   yield extension.unload();
 });
 
 add_task(function* test_notifications_populated_getAll() {
-  function background() {
+  async function background() {
     let opts = {
       type: "basic",
       iconUrl: "a.png",
       title: "Testing Notification",
       message: "Carry on",
     };
 
-    browser.notifications.create("p1", opts).then(() => {
-      return browser.notifications.create("p2", opts);
-    }).then(() => {
-      return browser.notifications.getAll();
-    }).then(notifications => {
-      browser.test.assertEq("object", typeof notifications, "getAll() returned an object");
-      browser.test.assertEq(2, Object.keys(notifications).length, "the object has 2 properties");
-      for (let notificationId of ["p1", "p2"]) {
-        for (let key of Object.keys(opts)) {
-          browser.test.assertEq(
-            opts[key],
-            notifications[notificationId][key],
-            `the notification has the expected value for option: ${key}`
-          );
-        }
+    await browser.notifications.create("p1", opts);
+    await browser.notifications.create("p2", opts);
+    let notifications = await browser.notifications.getAll();
+
+    browser.test.assertEq("object", typeof notifications, "getAll() returned an object");
+    browser.test.assertEq(2, Object.keys(notifications).length, "the object has 2 properties");
+
+    for (let notificationId of ["p1", "p2"]) {
+      for (let key of Object.keys(opts)) {
+        browser.test.assertEq(
+          opts[key],
+          notifications[notificationId][key],
+          `the notification has the expected value for option: ${key}`
+        );
       }
-      browser.test.notifyPass("getAll populated");
-    });
+    }
+
+    browser.test.notifyPass("getAll populated");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
     files: {
--- a/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
@@ -11,17 +11,17 @@
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 /* eslint-disable mozilla/balanced-listeners */
 
 add_task(function* test_simple() {
-  function runTests(cx) {
+  async function runTests(cx) {
     function xhr(XMLHttpRequest) {
       return (url) => {
         return new Promise((resolve, reject) => {
           let req = new XMLHttpRequest();
           req.open("GET", url);
           req.addEventListener("load", resolve);
           req.addEventListener("error", reject);
           req.send();
@@ -42,69 +42,69 @@ add_task(function* test_simple() {
       if (shouldFail) {
         return fetch("http://example.org/example.txt").then(failListener, passListener);
       } else {
         return fetch("http://example.com/example.txt").then(passListener, failListener);
       }
       /* eslint-enable no-else-return */
     }
 
-    return run(true, xhr(XMLHttpRequest))
-      .then(() => run(false, xhr(XMLHttpRequest)))
-      .then(() => run(true, xhr(window.XMLHttpRequest)))
-      .then(() => run(false, xhr(window.XMLHttpRequest)))
-      .then(() => run(true, fetch))
-      .then(() => run(false, fetch))
-      .then(() => run(true, window.fetch))
-      .then(() => run(false, window.fetch))
-      .catch(err => {
-        browser.test.fail(`Error: ${err} :: ${err.stack}`);
-        browser.test.notifyFail("permission_xhr");
-      });
+    try {
+      await run(true, xhr(XMLHttpRequest));
+      await run(false, xhr(XMLHttpRequest));
+      await run(true, xhr(window.XMLHttpRequest));
+      await run(false, xhr(window.XMLHttpRequest));
+      await run(true, fetch);
+      await run(false, fetch);
+      await run(true, window.fetch);
+      await run(false, window.fetch);
+    } catch (err) {
+      browser.test.fail(`Error: ${err} :: ${err.stack}`);
+      browser.test.notifyFail("permission_xhr");
+    }
   }
 
-  function background(runTestsFn) {
-    runTestsFn("bg").then(() => {
-      browser.test.notifyPass("permission_xhr");
-    });
+  async function background(runTestsFn) {
+    await runTestsFn("bg");
+    browser.test.notifyPass("permission_xhr");
   }
 
   let extensionData = {
     background: `(${background})(${runTests})`,
     manifest: {
       permissions: ["http://example.com/"],
       content_scripts: [{
         "matches": ["http://mochi.test/*/file_permission_xhr.html"],
         "js": ["content.js"],
       }],
     },
     files: {
-      "content.js": "new " + function(runTestsFn) {
-        runTestsFn("content").then(() => {
-          window.wrappedJSObject.privilegedFetch = fetch;
-          window.wrappedJSObject.privilegedXHR = XMLHttpRequest;
+      "content.js": `(${async runTestsFn => {
+        await runTestsFn("content");
 
-          window.addEventListener("message", function rcv({data}) {
-            switch (data.msg) {
-              case "test":
-                break;
+        window.wrappedJSObject.privilegedFetch = fetch;
+        window.wrappedJSObject.privilegedXHR = XMLHttpRequest;
+
+        window.addEventListener("message", function rcv({data}) {
+          switch (data.msg) {
+            case "test":
+              break;
 
-              case "assertTrue":
-                browser.test.assertTrue(data.condition, data.description);
-                break;
+            case "assertTrue":
+              browser.test.assertTrue(data.condition, data.description);
+              break;
 
-              case "finish":
-                window.removeEventListener("message", rcv, false);
-                browser.test.sendMessage("content-script-finished");
-                break;
-            }
-          }, false);
-          window.postMessage("test", "*");
-        });
-      } + `(${runTests})`,
+            case "finish":
+              window.removeEventListener("message", rcv, false);
+              browser.test.sendMessage("content-script-finished");
+              break;
+          }
+        }, false);
+        window.postMessage("test", "*");
+      }})(${runTests})`,
     },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
 
   let win = window.open("file_permission_xhr.html");
   yield extension.awaitMessage("content-script-finished");
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
@@ -11,38 +11,37 @@
 <body>
 
 <script type="application/javascript">
 "use strict";
 
 // Copied from toolkit/components/extensions/test/xpcshell/test_ext_storage.js.
 // The storage API in content scripts should behave identical to the storage API
 // in background pages.
-function contentScript() {
+async function contentScript() {
   let storage = browser.storage.local;
-  function check(prop, value) {
-    return storage.get(null).then(data => {
-      browser.test.assertEq(value, data[prop], "null getter worked for " + prop);
-      return storage.get(prop);
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "string getter worked for " + prop);
-      return storage.get([prop]);
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "array getter worked for " + prop);
-      return storage.get({[prop]: undefined});
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "object getter worked for " + prop);
-    });
+  async function check(prop, value) {
+    let data = await storage.get(null);
+    browser.test.assertEq(value, data[prop], "null getter worked for " + prop);
+
+    data = await storage.get(prop);
+    browser.test.assertEq(value, data[prop], "string getter worked for " + prop);
+
+    data = await storage.get([prop]);
+    browser.test.assertEq(value, data[prop], "array getter worked for " + prop);
+
+    data = await storage.get({[prop]: undefined});
+    browser.test.assertEq(value, data[prop], "object getter worked for " + prop);
   }
 
   let globalChanges = {};
 
-  browser.storage.onChanged.addListener((aChanges, aStorage) => {
-    browser.test.assertEq("local", aStorage, "storage is local");
-    Object.assign(globalChanges, aChanges);
+  browser.storage.onChanged.addListener((changes, storage) => {
+    browser.test.assertEq("local", storage, "storage is local");
+    Object.assign(globalChanges, changes);
   });
 
   function checkChanges(changes) {
     function checkSub(obj1, obj2) {
       for (let prop in obj1) {
         browser.test.assertEq(obj1[prop].oldValue, obj2[prop].oldValue);
         browser.test.assertEq(obj1[prop].newValue, obj2[prop].newValue);
       }
@@ -51,111 +50,102 @@ function contentScript() {
     checkSub(changes, globalChanges);
     checkSub(globalChanges, changes);
     globalChanges = {};
   }
 
   /* eslint-disable dot-notation */
 
   // Set some data and then test getters.
-  storage.set({"test-prop1": "value1", "test-prop2": "value2"}).then(() => {
+  try {
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
     checkChanges({"test-prop1": {newValue: "value1"}, "test-prop2": {newValue: "value2"}});
-    return check("test-prop1", "value1");
-  }).then(() => {
-    return check("test-prop2", "value2");
-  }).then(() => {
-    return storage.get({"test-prop1": undefined, "test-prop2": undefined, "other": "default"});
-  }).then(data => {
+
+    await check("test-prop1", "value1");
+    await check("test-prop2", "value2");
+
+    let data = await storage.get({"test-prop1": undefined, "test-prop2": undefined, "other": "default"});
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
     browser.test.assertEq("default", data["other"], "other correct");
-    return storage.get(["test-prop1", "test-prop2", "other"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2", "other"]);
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
     browser.test.assertFalse("other" in data, "other correct");
 
-  // Remove data in various ways.
-  }).then(() => {
-    return storage.remove("test-prop1");
-  }).then(() => {
+    // Remove data in various ways.
+    await storage.remove("test-prop1");
     checkChanges({"test-prop1": {oldValue: "value1"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertTrue("test-prop2" in data, "prop2 present");
 
-    return storage.set({"test-prop1": "value1"});
-  }).then(() => {
+    await storage.set({"test-prop1": "value1"});
     checkChanges({"test-prop1": {newValue: "value1"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
-  }).then(() => {
-    return storage.remove(["test-prop1", "test-prop2"]);
-  }).then(() => {
+
+    await storage.remove(["test-prop1", "test-prop2"]);
     checkChanges({"test-prop1": {oldValue: "value1"}, "test-prop2": {oldValue: "value2"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertFalse("test-prop2" in data, "prop2 absent");
 
-  // test storage.clear
-  }).then(() => {
-    return storage.set({"test-prop1": "value1", "test-prop2": "value2"});
-  }).then(() => {
-    return storage.clear();
-  }).then(() => {
+    // test storage.clear
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
+
+    await storage.clear();
     checkChanges({"test-prop1": {oldValue: "value1"}, "test-prop2": {oldValue: "value2"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertFalse("test-prop2" in data, "prop2 absent");
 
-  // Test cache invalidation.
-  }).then(() => {
-    return storage.set({"test-prop1": "value1", "test-prop2": "value2"});
-  }).then(() => {
+    // Test cache invalidation.
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
+
     globalChanges = {};
     // Schedule sendMessage after onMessage because the other end immediately
     // sends a message.
     Promise.resolve().then(() => {
       browser.test.sendMessage("invalidate");
     });
-    return new Promise(resolve => browser.test.onMessage.addListener(resolve));
-  }).then(() => {
-    return check("test-prop1", "value1");
-  }).then(() => {
-    return check("test-prop2", "value2");
+
+    await new Promise(resolve => browser.test.onMessage.addListener(resolve));
 
-  // Make sure we can store complex JSON data.
-  }).then(() => {
-    return storage.set({
+    await check("test-prop1", "value1");
+    await check("test-prop2", "value2");
+
+    // Make sure we can store complex JSON data.
+    await storage.set({
       "test-prop1": {
         str: "hello",
         bool: true,
         null: null,
         undef: undefined,
         obj: {},
         arr: [1, 2],
         date: new Date(0),
         regexp: /regexp/,
         func: function func() {},
         window,
       },
     });
-  }).then(() => {
-    return storage.set({"test-prop2": function func() {}});
-  }).then(() => {
+
+    await storage.set({"test-prop2": function func() {}});
     browser.test.assertEq("value1", globalChanges["test-prop1"].oldValue, "oldValue correct");
     browser.test.assertEq("object", typeof(globalChanges["test-prop1"].newValue), "newValue is obj");
     globalChanges = {};
-    return storage.get({"test-prop1": undefined, "test-prop2": undefined});
-  }).then(data => {
+
+    data = await storage.get({"test-prop1": undefined, "test-prop2": undefined});
     let obj = data["test-prop1"];
 
     browser.test.assertEq("hello", obj.str, "string part correct");
     browser.test.assertEq(true, obj.bool, "bool part correct");
     browser.test.assertEq(null, obj.null, "null part correct");
     browser.test.assertEq(undefined, obj.undef, "undefined part correct");
     browser.test.assertEq(undefined, obj.func, "function part correct");
     browser.test.assertEq(undefined, obj.window, "window part correct");
@@ -166,22 +156,22 @@ function contentScript() {
     browser.test.assertEq(1, obj.arr[0], "arr[0] part correct");
     browser.test.assertEq(2, obj.arr[1], "arr[1] part correct");
     browser.test.assertEq(2, obj.arr.length, "arr.length part correct");
 
     obj = data["test-prop2"];
 
     browser.test.assertEq("[object Object]", {}.toString.call(obj), "function serialized as a plain object");
     browser.test.assertEq(0, Object.keys(obj).length, "function serialized as an empty object");
-  }).then(() => {
+
     browser.test.notifyPass("storage");
-  }).catch(e => {
+  } catch (e) {
     browser.test.fail(`Error: ${e} :: ${e.stack}`);
     browser.test.notifyFail("storage");
-  });
+  }
 }
 
 let extensionData = {
   manifest: {
     content_scripts: [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
       "run_at": "document_idle",
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html
@@ -9,17 +9,17 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_multiple_pages() {
-  function background() {
+  async function background() {
     let tabReady = new Promise(resolve => {
       browser.runtime.onMessage.addListener(function listener(msg) {
         browser.test.log("onMessage " + msg);
         if (msg == "tab-ready") {
           browser.runtime.onMessage.removeListener(listener);
           resolve();
         }
       });
@@ -32,51 +32,52 @@ add_task(function* test_multiple_pages()
           browser.tabs.onRemoved.removeListener(listener);
 
           // Delay long enough to be sure the inner window has been nuked.
           setTimeout(resolve, 0);
         }
       });
     });
 
-    let storage = browser.storage.local;
+    try {
+      let storage = browser.storage.local;
 
-    browser.test.log("create");
-    browser.tabs.create({url: "tab.html"}).then(tabObj => {
-      tabId = tabObj.id;
+      browser.test.log("create");
+      let tab = await browser.tabs.create({url: "tab.html"});
+      tabId = tab.id;
 
-      return tabReady;
-    }).then(() => {
-      return storage.get("key");
-    }).then(result => {
+      await tabReady;
+
+      let result = await storage.get("key");
       browser.test.assertEq(undefined, result.key, "Key should be undefined");
 
-      return browser.runtime.sendMessage("tab-set-key");
-    }).then(() => {
-      return storage.get("key");
-    }).then(result => {
+      await browser.runtime.sendMessage("tab-set-key");
+
+      result = await storage.get("key");
       browser.test.assertEq(JSON.stringify({foo: {bar: "baz"}}),
                             JSON.stringify(result.key),
                             "Key should be set to the value from the tab");
-    }).then(() => {
+
       browser.test.log("Remove tab");
-      return Promise.all([browser.tabs.remove(tabId),
-                          tabRemoved]);
-    }).then(() => {
-      return storage.get("key");
-    }).then(result => {
+
+      await Promise.all([
+        browser.tabs.remove(tabId),
+        tabRemoved,
+      ]);
+
+      result = await storage.get("key");
       browser.test.assertEq(JSON.stringify({foo: {bar: "baz"}}),
                             JSON.stringify(result.key),
                             "Key should still be set to the value from the tab");
-    }).then(() => {
+
       browser.test.notifyPass("storage-multiple");
-    }).catch(e => {
+    } catch (e) {
       browser.test.fail(`Error: ${e} :: ${e.stack}`);
       browser.test.notifyFail("storage-multiple");
-    });
+    }
   }
 
   function tab() {
     browser.test.log("tab");
     browser.runtime.onMessage.addListener(msg => {
       if (msg == "tab-set-key") {
         return browser.storage.local.set({key: {foo: {bar: "baz"}}});
       }
--- a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html
@@ -10,48 +10,49 @@
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_webext_tab_subframe_privileges() {
   function background() {
-    browser.runtime.onMessage.addListener(({msg, success, tabId, error}) => {
+    browser.runtime.onMessage.addListener(async ({msg, success, tabId, error}) => {
       if (msg == "webext-tab-subframe-privileges") {
         if (success) {
-          browser.tabs.remove(tabId)
-            .then(() => browser.test.notifyPass(msg));
+          await browser.tabs.remove(tabId);
+
+          browser.test.notifyPass(msg);
         } else {
           browser.test.log(`Got an unexpected error: ${error}`);
-          browser.tabs.query({active: true})
-            .then(tabs => browser.tabs.remove(tabs[0].id))
-            .then(() => browser.test.notifyFail(msg));
+
+          let tabs = await browser.tabs.query({active: true});
+          await browser.tabs.remove(tabs[0].id);
+
+          browser.test.notifyFail(msg);
         }
       }
     });
     browser.tabs.create({url: browser.runtime.getURL("/tab.html")});
   }
 
-  function tabSubframeScript() {
+  async function tabSubframeScript() {
     browser.test.assertTrue(browser.tabs != undefined,
                             "Subframe of a privileged page has access to privileged APIs");
     if (browser.tabs) {
-      browser.tabs.getCurrent()
-        .then(tab => {
-          browser.runtime.sendMessage({
-            msg: "webext-tab-subframe-privileges",
-            success: true,
-            tabId: tab.id,
-          }, () => {
-            // NOTE: this empty callback prevents the promise returned from runtime.sendmessage
-            // to be reported as resolved after context unloaded.
-          });
-        })
-        .catch(e => browser.runtime.sendMessage({msg: "webext-tab-subframe-privileges", success: false, error: `${e}`}));
+      try {
+        let tab = await browser.tabs.getCurrent();
+        browser.runtime.sendMessage({
+          msg: "webext-tab-subframe-privileges",
+          success: true,
+          tabId: tab.id,
+        });
+      } catch (e) {
+        browser.runtime.sendMessage({msg: "webext-tab-subframe-privileges", success: false, error: `${e}`});
+      }
     } else {
       browser.runtime.sendMessage({
         msg: "webext-tab-subframe-privileges",
         success: false,
         error: `Privileged APIs missing in WebExtension tab sub-frame`,
       });
     }
   }
--- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
@@ -18,17 +18,17 @@
 SimpleTest.registerCleanupFunction(() => {
   SpecialPowers.clearUserPref("security.mixed_content.block_display_content");
 });
 
 let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
                  "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
 const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer;
 
-function testImageLoading(src, expectedAction) {
+async function testImageLoading(src, expectedAction) {
   let imageLoadingPromise = new Promise((resolve, reject) => {
     let cleanupListeners;
     let testImage = document.createElement("img");
     testImage.setAttribute("src", src);
 
     let loadListener = () => {
       cleanupListeners();
       resolve(expectedAction === "loaded");
@@ -45,19 +45,18 @@ function testImageLoading(src, expectedA
     };
 
     testImage.addEventListener("load", loadListener);
     testImage.addEventListener("error", errorListener);
 
     document.body.appendChild(testImage);
   });
 
-  imageLoadingPromise.then(success => {
-    browser.runtime.sendMessage({name: "image-loading", expectedAction, success});
-  });
+  let success = await imageLoadingPromise;
+  browser.runtime.sendMessage({name: "image-loading", expectedAction, success});
 }
 
 add_task(function* test_web_accessible_resources() {
   function background() {
     let gotURL;
     let tabId;
 
     function loadFrame(url) {
@@ -72,40 +71,36 @@ add_task(function* test_web_accessible_r
       [browser.extension.getURL("accessible.html"), true],
       [browser.extension.getURL("accessible.html") + "?foo=bar", true],
       [browser.extension.getURL("accessible.html") + "#!foo=bar", true],
       [browser.extension.getURL("forbidden.html"), false],
       [browser.extension.getURL("wild1.html"), true],
       [browser.extension.getURL("wild2.htm"), false],
     ];
 
-    function runTest() {
-      if (!urls.length) {
-        browser.test.notifyPass("web-accessible-resources");
-        return;
-      }
+    async function runTests() {
+      for (let [url, shouldLoad] of urls) {
+        let success = await loadFrame(url);
 
-      let [url, shouldLoad] = urls.shift();
-      return loadFrame(url).then(success => {
         browser.test.assertEq(shouldLoad, success, "Load was successful");
         if (shouldLoad) {
           browser.test.assertEq(url, gotURL, "Got expected url");
         } else {
           browser.test.assertEq(undefined, gotURL, "Got no url");
         }
         gotURL = undefined;
+      }
 
-        return runTest();
-      });
+      browser.test.notifyPass("web-accessible-resources");
     }
 
     browser.runtime.onMessage.addListener(([msg, url], sender) => {
       if (msg == "content-script-ready") {
         tabId = sender.tab.id;
-        runTest();
+        runTests();
       } else if (msg == "page-script") {
         browser.test.assertEq(undefined, gotURL, "Should have gotten only one message");
         browser.test.assertEq("string", typeof(url), "URL should be a string");
         gotURL = url;
       }
     });
 
     browser.test.sendMessage("ready");
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
@@ -30,21 +30,20 @@ add_task(function* test_alarm_fires() {
     browser.alarms.onAlarm.addListener(alarm => {
       browser.test.assertEq(ALARM_NAME, alarm.name, "alarm has the correct name");
       clearTimeout(timer);
       browser.test.notifyPass("alarm-fires");
     });
 
     browser.alarms.create(ALARM_NAME, {delayInMinutes: 0.02});
 
-    timer = setTimeout(() => {
+    timer = setTimeout(async () => {
       browser.test.fail("alarm fired within expected time");
-      browser.alarms.clear(ALARM_NAME).then(wasCleared => {
-        browser.test.assertTrue(wasCleared, "alarm was cleared");
-      });
+      let wasCleared = await browser.alarms.clear(ALARM_NAME);
+      browser.test.assertTrue(wasCleared, "alarm was cleared");
       browser.test.notifyFail("alarm-fires");
     }, 10000);
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
@@ -65,21 +64,20 @@ add_task(function* test_alarm_fires_with
     browser.alarms.onAlarm.addListener(alarm => {
       browser.test.assertEq(ALARM_NAME, alarm.name, "alarm has the expected name");
       clearTimeout(timer);
       browser.test.notifyPass("alarm-when");
     });
 
     browser.alarms.create(ALARM_NAME, {when: Date.now() + 1000});
 
-    timer = setTimeout(() => {
+    timer = setTimeout(async () => {
       browser.test.fail("alarm fired within expected time");
-      browser.alarms.clear(ALARM_NAME).then(wasCleared => {
-        browser.test.assertTrue(wasCleared, "alarm was cleared");
-      });
+      let wasCleared = await browser.alarms.clear(ALARM_NAME);
+      browser.test.assertTrue(wasCleared, "alarm was cleared");
       browser.test.notifyFail("alarm-when");
     }, 10000);
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
@@ -88,121 +86,112 @@ add_task(function* test_alarm_fires_with
 
   yield extension.startup();
   yield extension.awaitFinish("alarm-when");
   yield extension.unload();
 });
 
 
 add_task(function* test_alarm_clear_non_matching_name() {
-  function backgroundScript() {
+  async function backgroundScript() {
     let ALARM_NAME = "test_ext_alarms";
 
     browser.alarms.create(ALARM_NAME, {when: Date.now() + 2000});
 
-    browser.alarms.clear(ALARM_NAME + "1").then(wasCleared => {
-      browser.test.assertFalse(wasCleared, "alarm was not cleared");
-      return browser.alarms.getAll();
-    }).then(alarms => {
-      browser.test.assertEq(1, alarms.length, "alarm was not removed");
-      browser.test.notifyPass("alarm-clear");
-    });
+    let wasCleared = await browser.alarms.clear(ALARM_NAME + "1");
+    browser.test.assertFalse(wasCleared, "alarm was not cleared");
+
+    let alarms = await browser.alarms.getAll();
+    browser.test.assertEq(1, alarms.length, "alarm was not removed");
+    browser.test.notifyPass("alarm-clear");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("alarm-clear");
   yield extension.unload();
 });
 
 
 add_task(function* test_alarm_get_and_clear_single_argument() {
-  function backgroundScript() {
+  async function backgroundScript() {
     browser.alarms.create({when: Date.now() + 2000});
 
-    browser.alarms.get().then(alarm => {
-      browser.test.assertEq("", alarm.name, "expected alarm returned");
-      return browser.alarms.clear();
-    }).then(wasCleared => {
-      browser.test.assertTrue(wasCleared, "alarm was cleared");
-      return browser.alarms.getAll();
-    }).then(alarms => {
-      browser.test.assertEq(0, alarms.length, "alarm was removed");
-      browser.test.notifyPass("alarm-single-arg");
-    });
+    let alarm = await browser.alarms.get();
+    browser.test.assertEq("", alarm.name, "expected alarm returned");
+
+    let wasCleared = await browser.alarms.clear();
+    browser.test.assertTrue(wasCleared, "alarm was cleared");
+
+    let alarms = await browser.alarms.getAll();
+    browser.test.assertEq(0, alarms.length, "alarm was removed");
+
+    browser.test.notifyPass("alarm-single-arg");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
     },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("alarm-single-arg");
   yield extension.unload();
 });
 
 
 add_task(function* test_get_get_all_clear_all_alarms() {
-  function backgroundScript() {
+  async function backgroundScript() {
     const ALARM_NAME = "test_alarm";
 
     let suffixes = [0, 1, 2];
 
     for (let suffix of suffixes) {
       browser.alarms.create(ALARM_NAME + suffix, {when: Date.now() + (suffix + 1) * 10000});
     }
 
-    browser.alarms.getAll().then(alarms => {
-      browser.test.assertEq(suffixes.length, alarms.length, "expected number of alarms were found");
-      alarms.forEach((alarm, index) => {
-        browser.test.assertEq(ALARM_NAME + index, alarm.name, "alarm has the expected name");
-      });
+    let alarms = await browser.alarms.getAll();
+    browser.test.assertEq(suffixes.length, alarms.length, "expected number of alarms were found");
+    alarms.forEach((alarm, index) => {
+      browser.test.assertEq(ALARM_NAME + index, alarm.name, "alarm has the expected name");
+    });
+
 
-      return Promise.all(
-        suffixes.map(suffix => {
-          return browser.alarms.get(ALARM_NAME + suffix).then(alarm => {
-            browser.test.assertEq(ALARM_NAME + suffix, alarm.name, "alarm has the expected name");
-            browser.test.sendMessage(`get-${suffix}`);
-          });
-        })
-      );
-    }).then(() => {
-      return browser.alarms.clear(ALARM_NAME + suffixes[0]);
-    }).then(wasCleared => {
-      browser.test.assertTrue(wasCleared, "alarm was cleared");
+    for (let suffix of suffixes) {
+      let alarm = await browser.alarms.get(ALARM_NAME + suffix);
+      browser.test.assertEq(ALARM_NAME + suffix, alarm.name, "alarm has the expected name");
+      browser.test.sendMessage(`get-${suffix}`);
+    }
+
+    let wasCleared = await browser.alarms.clear(ALARM_NAME + suffixes[0]);
+    browser.test.assertTrue(wasCleared, "alarm was cleared");
 
-      return browser.alarms.getAll();
-    }).then(alarms => {
-      browser.test.assertEq(2, alarms.length, "alarm was removed");
+    alarms = await browser.alarms.getAll();
+    browser.test.assertEq(2, alarms.length, "alarm was removed");
 
-      return browser.alarms.get(ALARM_NAME + suffixes[0]);
-    }).then(alarm => {
-      browser.test.assertEq(undefined, alarm, "non-existent alarm is undefined");
-      browser.test.sendMessage(`get-invalid`);
+    let alarm = await browser.alarms.get(ALARM_NAME + suffixes[0]);
+    browser.test.assertEq(undefined, alarm, "non-existent alarm is undefined");
+    browser.test.sendMessage(`get-invalid`);
 
-      return browser.alarms.clearAll();
-    }).then(wasCleared => {
-      browser.test.assertTrue(wasCleared, "alarms were cleared");
+    wasCleared = await browser.alarms.clearAll();
+    browser.test.assertTrue(wasCleared, "alarms were cleared");
 
-      return browser.alarms.getAll();
-    }).then(alarms => {
-      browser.test.assertEq(0, alarms.length, "no alarms exist");
-      browser.test.sendMessage("clearAll");
-      browser.test.sendMessage("clear");
-      browser.test.sendMessage("getAll");
-    });
+    alarms = await browser.alarms.getAll();
+    browser.test.assertEq(0, alarms.length, "no alarms exist");
+    browser.test.sendMessage("clearAll");
+    browser.test.sendMessage("clear");
+    browser.test.sendMessage("getAll");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
     },
   });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
@@ -1,28 +1,28 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* test_cleared_alarm_does_not_fire() {
-  function backgroundScript() {
+  async function backgroundScript() {
     let ALARM_NAME = "test_ext_alarms";
 
     browser.alarms.onAlarm.addListener(alarm => {
       browser.test.fail("cleared alarm does not fire");
       browser.test.notifyFail("alarm-cleared");
     });
     browser.alarms.create(ALARM_NAME, {when: Date.now() + 1000});
 
-    browser.alarms.clear(ALARM_NAME).then(wasCleared => {
-      browser.test.assertTrue(wasCleared, "alarm was cleared");
-      setTimeout(() => {
-        browser.test.notifyPass("alarm-cleared");
-      }, 2000);
-    });
+    let wasCleared = await browser.alarms.clear(ALARM_NAME);
+    browser.test.assertTrue(wasCleared, "alarm was cleared");
+
+    await new Promise(resolve => setTimeout(resolve, 2000));
+
+    browser.test.notifyPass("alarm-cleared");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
     },
   });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
@@ -3,34 +3,35 @@
 "use strict";
 
 add_task(function* test_periodic_alarm_fires() {
   function backgroundScript() {
     const ALARM_NAME = "test_ext_alarms";
     let count = 0;
     let timer;
 
-    browser.alarms.onAlarm.addListener(alarm => {
+    browser.alarms.onAlarm.addListener(async alarm => {
       browser.test.assertEq(alarm.name, ALARM_NAME, "alarm has the expected name");
       if (count++ === 3) {
         clearTimeout(timer);
-        browser.alarms.clear(ALARM_NAME).then(wasCleared => {
-          browser.test.assertTrue(wasCleared, "alarm was cleared");
-          browser.test.notifyPass("alarm-periodic");
-        });
+        let wasCleared = await browser.alarms.clear(ALARM_NAME);
+        browser.test.assertTrue(wasCleared, "alarm was cleared");
+
+        browser.test.notifyPass("alarm-periodic");
       }
     });
 
     browser.alarms.create(ALARM_NAME, {periodInMinutes: 0.02});
 
-    timer = setTimeout(() => {
+    timer = setTimeout(async () => {
       browser.test.fail("alarm fired expected number of times");
-      browser.alarms.clear(ALARM_NAME).then(wasCleared => {
-        browser.test.assertTrue(wasCleared, "alarm was cleared");
-      });
+
+      let wasCleared = await browser.alarms.clear(ALARM_NAME);
+      browser.test.assertTrue(wasCleared, "alarm was cleared");
+
       browser.test.notifyFail("alarm-periodic");
     }, 30000);
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background: `(${backgroundScript})()`,
     manifest: {
       permissions: ["alarms"],
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js
@@ -2,32 +2,31 @@
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 
 add_task(function* test_duplicate_alarm_name_replaces_alarm() {
   function backgroundScript() {
     let count = 0;
 
-    browser.alarms.onAlarm.addListener(alarm => {
+    browser.alarms.onAlarm.addListener(async alarm => {
       if (alarm.name === "master alarm") {
         browser.alarms.create("child alarm", {delayInMinutes: 0.05});
-        browser.alarms.getAll().then(results => {
-          browser.test.assertEq(2, results.length, "exactly two alarms exist");
-          browser.test.assertEq("master alarm", results[0].name, "first alarm has the expected name");
-          browser.test.assertEq("child alarm", results[1].name, "second alarm has the expected name");
-        }).then(() => {
-          if (count++ === 3) {
-            browser.alarms.clear("master alarm").then(wasCleared => {
-              return browser.alarms.clear("child alarm");
-            }).then(wasCleared => {
-              browser.test.notifyPass("alarm-duplicate");
-            });
-          }
-        });
+        let results = await browser.alarms.getAll();
+
+        browser.test.assertEq(2, results.length, "exactly two alarms exist");
+        browser.test.assertEq("master alarm", results[0].name, "first alarm has the expected name");
+        browser.test.assertEq("child alarm", results[1].name, "second alarm has the expected name");
+
+        if (count++ === 3) {
+          await browser.alarms.clear("master alarm");
+          await browser.alarms.clear("child alarm");
+
+          browser.test.notifyPass("alarm-duplicate");
+        }
       } else {
         browser.test.fail("duplicate named alarm replaced existing alarm");
         browser.test.notifyFail("alarm-duplicate");
       }
     });
 
     browser.alarms.create("master alarm", {delayInMinutes: 0.025, periodInMinutes: 0.025});
   }
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js
@@ -40,55 +40,51 @@ function setup() {
     }
 
     downloadDir.remove(false);
   });
 }
 
 function backgroundScript() {
   let blobUrl;
-  browser.test.onMessage.addListener((msg, ...args) => {
+  browser.test.onMessage.addListener(async (msg, ...args) => {
     if (msg == "download.request") {
       let options = args[0];
 
       if (options.blobme) {
         let blob = new Blob(options.blobme);
         delete options.blobme;
         blobUrl = options.url = window.URL.createObjectURL(blob);
       }
 
-      // download() throws on bad arguments, we can remove the extra
-      // promise when bug 1250223 is fixed.
-      return Promise.resolve().then(() => browser.downloads.download(options))
-                    .then(id => {
-                      browser.test.sendMessage("download.done", {status: "success", id});
-                    })
-                    .catch(error => {
-                      browser.test.sendMessage("download.done", {status: "error", errmsg: error.message});
-                    });
+      try {
+        let id = await browser.downloads.download(options);
+        browser.test.sendMessage("download.done", {status: "success", id});
+      } catch (error) {
+        browser.test.sendMessage("download.done", {status: "error", errmsg: error.message});
+      }
     } else if (msg == "killTheBlob") {
       window.URL.revokeObjectURL(blobUrl);
       blobUrl = null;
     }
   });
 
   browser.test.sendMessage("ready");
 }
 
 // This function is a bit of a sledgehammer, it looks at every download
 // the browser knows about and waits for all active downloads to complete.
 // But we only start one at a time and only do a handful in total, so
 // this lets us test download() without depending on anything else.
-function waitForDownloads() {
-  return Downloads.getList(Downloads.ALL)
-                  .then(list => list.getAll())
-                  .then(downloads => {
-                    let inprogress = downloads.filter(dl => !dl.stopped);
-                    return Promise.all(inprogress.map(dl => dl.whenSucceeded()));
-                  });
+async function waitForDownloads() {
+  let list = await Downloads.getList(Downloads.ALL);
+  let downloads = await list.getAll();
+
+  let inprogress = downloads.filter(dl => !dl.stopped);
+  return Promise.all(inprogress.map(dl => dl.whenSucceeded()));
 }
 
 // Create a file in the downloads directory.
 function touch(filename) {
   let file = downloadDir.clone();
   file.append(filename);
   file.create(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
 }
@@ -110,27 +106,28 @@ add_task(function* test_downloads() {
     },
   });
 
   function download(options) {
     extension.sendMessage("download.request", options);
     return extension.awaitMessage("download.done");
   }
 
-  function testDownload(options, localFile, expectedSize, description) {
-    return download(options).then(msg => {
-      equal(msg.status, "success", `downloads.download() works with ${description}`);
-      return waitForDownloads();
-    }).then(() => {
-      let localPath = downloadDir.clone();
-      let parts = Array.isArray(localFile) ? localFile : [localFile];
-      parts.map(p => localPath.append(p));
-      equal(localPath.fileSize, expectedSize, "Downloaded file has expected size");
-      localPath.remove(false);
-    });
+  async function testDownload(options, localFile, expectedSize, description) {
+    let msg = await download(options);
+    equal(msg.status, "success", `downloads.download() works with ${description}`);
+
+    await waitForDownloads();
+
+    let localPath = downloadDir.clone();
+    let parts = Array.isArray(localFile) ? localFile : [localFile];
+
+    parts.map(p => localPath.append(p));
+    equal(localPath.fileSize, expectedSize, "Downloaded file has expected size");
+    localPath.remove(false);
   }
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
   do_print("extension started");
 
   // Call download() with just the url property.
   yield testDownload({url: FILE_URL}, FILE_NAME, FILE_LEN, "just source");
@@ -277,20 +274,22 @@ add_task(function* test_download_post() 
     if (body) {
       const str = NetUtil.readInputStreamToString(received.bodyInputStream,
         received.bodyInputStream.available());
       equal(str, body, "body is correct");
     }
   }
 
   function background() {
-    browser.test.onMessage.addListener(options => {
-      Promise.resolve()
-        .then(() => browser.downloads.download(options))
-        .catch(err => browser.test.sendMessage("done", {err: err.message}));
+    browser.test.onMessage.addListener(async options => {
+      try {
+        await browser.downloads.download(options);
+      } catch (err) {
+        browser.test.sendMessage("done", {err: err.message});
+      }
     });
     browser.downloads.onChanged.addListener(({state}) => {
       if (state && state.current === "complete") {
         browser.test.sendMessage("done", {ok: true});
       }
     });
   }
 
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js
@@ -161,81 +161,81 @@ function backgroundScript() {
           fail(`Mismatched event: expecting ${JSON.stringify(expected[0])} but got ${JSON.stringify(Array.from(remaining)[0])}`);
         }
       }
       eventWaiter = check;
       check();
     });
   }
 
-  browser.test.onMessage.addListener(function(msg, ...args) {
+  browser.test.onMessage.addListener(async (msg, ...args) => {
     let match = msg.match(/(\w+).request$/);
     if (!match) {
       return;
     }
+
     let what = match[1];
     if (what == "waitForEvents") {
-      waitForEvents(...args).then(() => {
+      try {
+        await waitForEvents(...args);
         browser.test.sendMessage("waitForEvents.done", {status: "success"});
-      }).catch(error => {
+      } catch (error) {
         browser.test.sendMessage("waitForEvents.done", {status: "error", errmsg: error.message});
-      });
+      }
     } else if (what == "clearEvents") {
       events = new Set();
       browser.test.sendMessage("clearEvents.done", {status: "success"});
     } else {
-      // extension functions throw on bad arguments, we can remove the extra
-      // promise when bug 1250223 is fixed.
-      Promise.resolve().then(() => {
-        return browser.downloads[what](...args);
-      }).then(result => {
+      try {
+        let result = await browser.downloads[what](...args);
         browser.test.sendMessage(`${what}.done`, {status: "success", result});
-      }).catch(error => {
+      } catch (error) {
         browser.test.sendMessage(`${what}.done`, {status: "error", errmsg: error.message});
-      });
+      }
     }
   });
 
   browser.test.sendMessage("ready");
 }
 
 let downloadDir;
 let extension;
 
-function clearDownloads(callback) {
-  return Downloads.getList(Downloads.ALL).then(list => {
-    return list.getAll().then(downloads => {
-      return Promise.all(downloads.map(download => list.remove(download)))
-                    .then(() => downloads);
-    });
-  });
+async function clearDownloads(callback) {
+  let list = await Downloads.getList(Downloads.ALL);
+  let downloads = await list.getAll();
+
+  await Promise.all(downloads.map(download => list.remove(download)));
+
+  return downloads;
 }
 
 function runInExtension(what, ...args) {
   extension.sendMessage(`${what}.request`, ...args);
   return extension.awaitMessage(`${what}.done`);
 }
 
 // This is pretty simplistic, it looks for a progress update for a
 // download of the given url in which the total bytes are exactly equal
 // to the given value.  Unless you know exactly how data will arrive from
 // the server (eg see interruptible.sjs), it probably isn't very useful.
-function waitForProgress(url, bytes) {
-  return Downloads.getList(Downloads.ALL)
-                  .then(list => new Promise(resolve => {
-                    const view = {
-                      onDownloadChanged(download) {
-                        if (download.source.url == url && download.currentBytes == bytes) {
-                          list.removeView(view);
-                          resolve();
-                        }
-                      },
-                    };
-                    list.addView(view);
-                  }));
+async function waitForProgress(url, bytes) {
+  let list = await Downloads.getList(Downloads.ALL);
+
+  return new Promise(resolve => {
+    const view = {
+      onDownloadChanged(download) {
+        if (download.source.url == url && download.currentBytes == bytes) {
+          list.removeView(view);
+          resolve();
+        }
+      },
+    };
+    list.addView(view);
+  });
 }
 
 add_task(function* setup() {
   const nsIFile = Ci.nsIFile;
   downloadDir = FileUtils.getDir("TmpD", ["downloads"]);
   downloadDir.createUnique(nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
   do_print(`downloadDir ${downloadDir.path}`);
 
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js
@@ -34,52 +34,47 @@ function backgroundScript() {
   browser.downloads.onChanged.addListener(change => {
     if (change.state && change.state.current == "complete") {
       // Make sure we have a promise.
       waitForComplete(change.id);
       complete.get(change.id).resolve();
     }
   });
 
-  browser.test.onMessage.addListener(function(msg) {
-    // extension functions throw on bad arguments, we can remove the extra
-    // promise when bug 1250223 is fixed.
+  browser.test.onMessage.addListener(async (msg, ...args) => {
     if (msg == "download.request") {
-      Promise.resolve().then(() => browser.downloads.download(arguments[1]))
-                       .then(id => {
-                         browser.test.sendMessage("download.done", {status: "success", id});
-                       })
-                       .catch(error => {
-                         browser.test.sendMessage("download.done", {status: "error", errmsg: error.message});
-                       });
+      try {
+        let id = await browser.downloads.download(args[0]);
+        browser.test.sendMessage("download.done", {status: "success", id});
+      } catch (error) {
+        browser.test.sendMessage("download.done", {status: "error", errmsg: error.message});
+      }
     } else if (msg == "search.request") {
-      Promise.resolve().then(() => browser.downloads.search(arguments[1]))
-                       .then(downloads => {
-                         browser.test.sendMessage("search.done", {status: "success", downloads});
-                       })
-                       .catch(error => {
-                         browser.test.sendMessage("search.done", {status: "error", errmsg: error.message});
-                       });
+      try {
+        let downloads = await browser.downloads.search(args[0]);
+        browser.test.sendMessage("search.done", {status: "success", downloads});
+      } catch (error) {
+        browser.test.sendMessage("search.done", {status: "error", errmsg: error.message});
+      }
     } else if (msg == "waitForComplete.request") {
-      waitForComplete(arguments[1]).then(() => {
-        browser.test.sendMessage("waitForComplete.done");
-      });
+      await waitForComplete(args[0]);
+      browser.test.sendMessage("waitForComplete.done");
     }
   });
 
   browser.test.sendMessage("ready");
 }
 
-function clearDownloads(callback) {
-  return Downloads.getList(Downloads.ALL).then(list => {
-    return list.getAll().then(downloads => {
-      return Promise.all(downloads.map(download => list.remove(download)))
-                    .then(() => downloads);
-    });
-  });
+async function clearDownloads(callback) {
+  let list = await Downloads.getList(Downloads.ALL);
+  let downloads = await list.getAll();
+
+  await Promise.all(downloads.map(download => list.remove(download)));
+
+  return downloads;
 }
 
 add_task(function* test_search() {
   const nsIFile = Ci.nsIFile;
   let downloadDir = FileUtils.getDir("TmpD", ["downloads"]);
   downloadDir.createUnique(nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
   do_print(`downloadDir ${downloadDir.path}`);
 
@@ -87,46 +82,46 @@ add_task(function* test_search() {
     let path = downloadDir.clone();
     path.append(filename);
     return path.path;
   }
 
   Services.prefs.setIntPref("browser.download.folderList", 2);
   Services.prefs.setComplexValue("browser.download.dir", nsIFile, downloadDir);
 
-  do_register_cleanup(() => {
+  do_register_cleanup(async () => {
     Services.prefs.clearUserPref("browser.download.folderList");
     Services.prefs.clearUserPref("browser.download.dir");
-    return cleanupDir(downloadDir).then(clearDownloads);
+    await cleanupDir(downloadDir);
+    await clearDownloads();
   });
 
   yield clearDownloads().then(downloads => {
     do_print(`removed ${downloads.length} pre-existing downloads from history`);
   });
 
   let extension = ExtensionTestUtils.loadExtension({
     background: backgroundScript,
     manifest: {
       permissions: ["downloads"],
     },
   });
 
-  function download(options) {
+  async function download(options) {
     extension.sendMessage("download.request", options);
-    return extension.awaitMessage("download.done").then(result => {
-      let promise;
-      if (result.status == "success") {
-        do_print(`wait for onChanged event to indicate ${result.id} is complete`);
-        extension.sendMessage("waitForComplete.request", result.id);
-        promise = extension.awaitMessage("waitForComplete.done");
-      } else {
-        promise = Promise.resolve();
-      }
-      return promise.then(() => result);
-    });
+    let result = await extension.awaitMessage("download.done");
+
+    if (result.status == "success") {
+      do_print(`wait for onChanged event to indicate ${result.id} is complete`);
+      extension.sendMessage("waitForComplete.request", result.id);
+
+      await extension.awaitMessage("waitForComplete.done");
+    }
+
+    return result;
   }
 
   function search(query) {
     extension.sendMessage("search.request", query);
     return extension.awaitMessage("search.done");
   }
 
   yield extension.startup();
--- a/toolkit/components/extensions/test/xpcshell/test_ext_extension.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_extension.js
@@ -1,18 +1,18 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* test_is_allowed_incognito_access() {
-  function background() {
-    browser.extension.isAllowedIncognitoAccess().then(isAllowedIncognitoAccess => {
-      browser.test.assertEq(true, isAllowedIncognitoAccess, "isAllowedIncognitoAccess is true");
-      browser.test.notifyPass("isAllowedIncognitoAccess");
-    });
+  async function background() {
+    let allowed = await browser.extension.isAllowedIncognitoAccess();
+
+    browser.test.assertEq(true, allowed, "isAllowedIncognitoAccess is true");
+    browser.test.notifyPass("isAllowedIncognitoAccess");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {},
   });
 
   yield extension.startup();
@@ -32,21 +32,21 @@ add_task(function* test_in_incognito_con
   });
 
   yield extension.startup();
   yield extension.awaitFinish("inIncognitoContext");
   yield extension.unload();
 });
 
 add_task(function* test_is_allowed_file_scheme_access() {
-  function background() {
-    browser.extension.isAllowedFileSchemeAccess().then(isAllowedFileSchemeAccess => {
-      browser.test.assertEq(false, isAllowedFileSchemeAccess, "isAllowedFileSchemeAccess is false");
-      browser.test.notifyPass("isAllowedFileSchemeAccess");
-    });
+  async function background() {
+    let allowed = await browser.extension.isAllowedFileSchemeAccess();
+
+    browser.test.assertEq(false, allowed, "isAllowedFileSchemeAccess is false");
+    browser.test.notifyPass("isAllowedFileSchemeAccess");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {},
   });
 
   yield extension.startup();
--- a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
@@ -26,23 +26,23 @@ add_task(function* test_legacy_extension
       // Extract the assigned uuid from the background page url.
       uuid: window.location.hostname,
     };
 
     browser.test.sendMessage("webextension-ready", extensionInfo);
 
     let port;
 
-    browser.test.onMessage.addListener(msg => {
+    browser.test.onMessage.addListener(async msg => {
       if (msg == "do-send-message") {
-        browser.runtime.sendMessage("webextension -> legacy_extension message").then(reply => {
-          browser.test.assertEq("legacy_extension -> webextension reply", reply,
-                                "Got the expected message from the LegacyExtensionContext");
-          browser.test.sendMessage("got-reply-message");
-        });
+        let reply = await browser.runtime.sendMessage("webextension -> legacy_extension message");
+
+        browser.test.assertEq("legacy_extension -> webextension reply", reply,
+                              "Got the expected message from the LegacyExtensionContext");
+        browser.test.sendMessage("got-reply-message");
       } else if (msg == "do-connect") {
         port = browser.runtime.connect();
 
         port.onMessage.addListener(msg => {
           browser.test.assertEq("legacy_extension -> webextension port message", msg,
                                 "Got the expected message from the LegacyExtensionContext");
           port.postMessage("webextension -> legacy_extension port message");
         });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
@@ -170,33 +170,34 @@ if (AppConstants.platform == "win") {
     let exitPromise = waitForSubprocessExit();
     yield extension.unload();
     yield exitPromise;
   });
 }
 
 // Test sendNativeMessage()
 add_task(function* test_sendNativeMessage() {
-  function background() {
+  async function background() {
     let MSG = {test: "hello world"};
 
     // Check error handling
-    browser.runtime.sendNativeMessage("nonexistent", MSG).then(() => {
+    await browser.runtime.sendNativeMessage("nonexistent", MSG).then(() => {
       browser.test.fail("sendNativeMessage() to a nonexistent app should have failed");
     }, err => {
       browser.test.succeed("sendNativeMessage() to a nonexistent app failed");
-    }).then(() => {
-      // Check regular message exchange
-      return browser.runtime.sendNativeMessage("echo", MSG);
-    }).then(reply => {
-      let expected = JSON.stringify(MSG);
-      let received = JSON.stringify(reply);
-      browser.test.assertEq(expected, received, "Received echoed native message");
-      browser.test.sendMessage("finished");
     });
+
+    // Check regular message exchange
+    let reply = await browser.runtime.sendNativeMessage("echo", MSG);
+
+    let expected = JSON.stringify(MSG);
+    let received = JSON.stringify(reply);
+    browser.test.assertEq(expected, received, "Received echoed native message");
+
+    browser.test.sendMessage("finished");
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       applications: {gecko: {id: ID}},
       permissions: ["nativeMessaging"],
     },
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
@@ -3,24 +3,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 add_task(function* setup() {
   ExtensionTestUtils.mockAppInfo();
 });
 
 add_task(function* test_getBrowserInfo() {
-  function background() {
-    browser.runtime.getBrowserInfo().then(info => {
-      browser.test.assertEq(info.name, "XPCShell", "name is valid");
-      browser.test.assertEq(info.vendor, "Mozilla", "vendor is Mozilla");
-      browser.test.assertEq(info.version, "48", "version is correct");
-      browser.test.assertEq(info.buildID, "20160315", "buildID is correct");
+  async function background() {
+    let info = await browser.runtime.getBrowserInfo();
 
-      browser.test.notifyPass("runtime.getBrowserInfo");
-    });
+    browser.test.assertEq(info.name, "XPCShell", "name is valid");
+    browser.test.assertEq(info.vendor, "Mozilla", "vendor is Mozilla");
+    browser.test.assertEq(info.version, "48", "version is correct");
+    browser.test.assertEq(info.buildID, "20160315", "buildID is correct");
+
+    browser.test.notifyPass("runtime.getBrowserInfo");
   }
 
   const extension = ExtensionTestUtils.loadExtension({background});
   yield extension.startup();
   yield extension.awaitFinish("runtime.getBrowserInfo");
   yield extension.unload();
 });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
@@ -1,14 +1,14 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* test_sendMessage_error() {
-  function background() {
+  async function background() {
     let circ = {};
     circ.circ = circ;
     let testCases = [
       // [arguments, expected error string],
       [[], "runtime.sendMessage's message argument is missing"],
       [[null, null, null, null], "runtime.sendMessage's last argument is not a function"],
       [[null, null, 1], "runtime.sendMessage's options argument is invalid"],
       [[1, null, null], "runtime.sendMessage's extensionId argument is invalid"],
@@ -30,31 +30,28 @@ add_task(function* test_sendMessage_erro
     ];
 
     // Repeat all tests with the undefined value instead of null.
     for (let [args, expectedError] of testCases.slice()) {
       args = args.map(arg => arg === null ? undefined : arg);
       testCases.push([args, expectedError]);
     }
 
-    function next() {
-      if (!testCases.length) {
-        browser.test.notifyPass("sendMessage parameter validation");
-        return;
-      }
-      let [args, expectedError] = testCases.shift();
+    for (let [args, expectedError] of testCases) {
       let description = `runtime.sendMessage(${args.map(String).join(", ")})`;
-      return browser.runtime.sendMessage(...args)
+
+      await browser.runtime.sendMessage(...args)
         .then(() => {
           browser.test.fail(`Unexpectedly got no error for ${description}`);
         }, err => {
           browser.test.assertEq(expectedError, err.message, `expected error message for ${description}`);
-        }).then(next);
+        });
     }
-    next();
+
+    browser.test.notifyPass("sendMessage parameter validation");
   }
   let extensionData = {
     background,
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
 
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
@@ -1,27 +1,26 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
-function backgroundScript() {
+async function backgroundScript() {
   let storage = browser.storage.local;
-  function check(prop, value) {
-    return storage.get(null).then(data => {
-      browser.test.assertEq(value, data[prop], "null getter worked for " + prop);
-      return storage.get(prop);
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "string getter worked for " + prop);
-      return storage.get([prop]);
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "array getter worked for " + prop);
-      return storage.get({[prop]: undefined});
-    }).then(data => {
-      browser.test.assertEq(value, data[prop], "object getter worked for " + prop);
-    });
+  async function check(prop, value) {
+    let data = await storage.get(null);
+    browser.test.assertEq(value, data[prop], "null getter worked for " + prop);
+
+    data = await storage.get(prop);
+    browser.test.assertEq(value, data[prop], "string getter worked for " + prop);
+
+    data = await storage.get([prop]);
+    browser.test.assertEq(value, data[prop], "array getter worked for " + prop);
+
+    data = await storage.get({[prop]: undefined});
+    browser.test.assertEq(value, data[prop], "object getter worked for " + prop);
   }
 
   let globalChanges = {};
 
   browser.storage.onChanged.addListener((changes, storage) => {
     browser.test.assertEq("local", storage, "storage is local");
     Object.assign(globalChanges, changes);
   });
@@ -37,111 +36,100 @@ function backgroundScript() {
     checkSub(changes, globalChanges);
     checkSub(globalChanges, changes);
     globalChanges = {};
   }
 
   /* eslint-disable dot-notation */
 
   // Set some data and then test getters.
-  storage.set({"test-prop1": "value1", "test-prop2": "value2"}).then(() => {
+
+  try {
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
     checkChanges({"test-prop1": {newValue: "value1"}, "test-prop2": {newValue: "value2"}});
-    return check("test-prop1", "value1");
-  }).then(() => {
-    return check("test-prop2", "value2");
-  }).then(() => {
-    return storage.get({"test-prop1": undefined, "test-prop2": undefined, "other": "default"});
-  }).then(data => {
+
+    await check("test-prop1", "value1");
+    await check("test-prop2", "value2");
+
+    let data = await storage.get({"test-prop1": undefined, "test-prop2": undefined, "other": "default"});
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
     browser.test.assertEq("default", data["other"], "other correct");
-    return storage.get(["test-prop1", "test-prop2", "other"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2", "other"]);
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
     browser.test.assertFalse("other" in data, "other correct");
 
-  // Remove data in various ways.
-  }).then(() => {
-    return storage.remove("test-prop1");
-  }).then(() => {
+    // Remove data in various ways.
+    await storage.remove("test-prop1");
     checkChanges({"test-prop1": {oldValue: "value1"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertTrue("test-prop2" in data, "prop2 present");
 
-    return storage.set({"test-prop1": "value1"});
-  }).then(() => {
+
+    await storage.set({"test-prop1": "value1"});
     checkChanges({"test-prop1": {newValue: "value1"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertEq("value1", data["test-prop1"], "prop1 correct");
     browser.test.assertEq("value2", data["test-prop2"], "prop2 correct");
-  }).then(() => {
-    return storage.remove(["test-prop1", "test-prop2"]);
-  }).then(() => {
+
+    await storage.remove(["test-prop1", "test-prop2"]);
     checkChanges({"test-prop1": {oldValue: "value1"}, "test-prop2": {oldValue: "value2"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertFalse("test-prop2" in data, "prop2 absent");
 
-  // test storage.clear
-  }).then(() => {
-    return storage.set({"test-prop1": "value1", "test-prop2": "value2"});
-  }).then(() => {
-    return storage.clear();
-  }).then(() => {
+    // test storage.clear
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
+    await storage.clear();
+
     checkChanges({"test-prop1": {oldValue: "value1"}, "test-prop2": {oldValue: "value2"}});
-    return storage.get(["test-prop1", "test-prop2"]);
-  }).then(data => {
+    data = await storage.get(["test-prop1", "test-prop2"]);
     browser.test.assertFalse("test-prop1" in data, "prop1 absent");
     browser.test.assertFalse("test-prop2" in data, "prop2 absent");
 
-  // Test cache invalidation.
-  }).then(() => {
-    return storage.set({"test-prop1": "value1", "test-prop2": "value2"});
-  }).then(() => {
+    // Test cache invalidation.
+    await storage.set({"test-prop1": "value1", "test-prop2": "value2"});
+
     globalChanges = {};
     // Schedule sendMessage after onMessage because the other end immediately
     // sends a message.
     Promise.resolve().then(() => {
       browser.test.sendMessage("invalidate");
     });
-    return new Promise(resolve => browser.test.onMessage.addListener(resolve));
-  }).then(() => {
-    return check("test-prop1", "value1");
-  }).then(() => {
-    return check("test-prop2", "value2");
+    await new Promise(resolve => browser.test.onMessage.addListener(resolve));
 
-  // Make sure we can store complex JSON data.
-  }).then(() => {
-    return storage.set({
+    await check("test-prop1", "value1");
+    await check("test-prop2", "value2");
+
+    // Make sure we can store complex JSON data.
+    await storage.set({
       "test-prop1": {
         str: "hello",
         bool: true,
         null: null,
         undef: undefined,
         obj: {},
         arr: [1, 2],
         date: new Date(0),
         regexp: /regexp/,
         func: function func() {},
         window,
       },
     });
-  }).then(() => {
-    return storage.set({"test-prop2": function func() {}});
-  }).then(() => {
+
+    await storage.set({"test-prop2": function func() {}});
     browser.test.assertEq("value1", globalChanges["test-prop1"].oldValue, "oldValue correct");
     browser.test.assertEq("object", typeof(globalChanges["test-prop1"].newValue), "newValue is obj");
     globalChanges = {};
-    return storage.get({"test-prop1": undefined, "test-prop2": undefined});
-  }).then(data => {
+
+    data = await storage.get({"test-prop1": undefined, "test-prop2": undefined});
     let obj = data["test-prop1"];
 
     browser.test.assertEq("hello", obj.str, "string part correct");
     browser.test.assertEq(true, obj.bool, "bool part correct");
     browser.test.assertEq(null, obj.null, "null part correct");
     browser.test.assertEq(undefined, obj.undef, "undefined part correct");
     browser.test.assertEq(undefined, obj.func, "function part correct");
     browser.test.assertEq(undefined, obj.window, "window part correct");
@@ -152,22 +140,22 @@ function backgroundScript() {
     browser.test.assertEq(1, obj.arr[0], "arr[0] part correct");
     browser.test.assertEq(2, obj.arr[1], "arr[1] part correct");
     browser.test.assertEq(2, obj.arr.length, "arr.length part correct");
 
     obj = data["test-prop2"];
 
     browser.test.assertEq("[object Object]", {}.toString.call(obj), "function serialized as a plain object");
     browser.test.assertEq(0, Object.keys(obj).length, "function serialized as an empty object");
-  }).then(() => {
+
     browser.test.notifyPass("storage");
-  }).catch(e => {
+  } catch (e) {
     browser.test.fail(`Error: ${e} :: ${e.stack}`);
     browser.test.notifyFail("storage");
-  });
+  }
 }
 
 let extensionData = {
   background: backgroundScript,
   manifest: {
     permissions: ["storage"],
   },
 };