Bug 1315872: Refactor browser_ext_tabs_cookieStoreId. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Mon, 07 Nov 2016 22:08:24 -0800
changeset 351849 9e5ff7c0e899b12583deb2a74ea81f6ad197e33e
parent 351848 a57a92087010c2814d3f65dd95beaebf1b94a966
child 351850 364305744e4c027386acbd7e2d2a6d55b8729eb3
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
bugs1315872
milestone52.0a1
Bug 1315872: Refactor browser_ext_tabs_cookieStoreId. r=aswan MozReview-Commit-ID: J4diktOFIQR
browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
--- a/browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_cookieStoreId.js
@@ -40,25 +40,27 @@ add_task(function* () {
         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");
       }
 
       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) => {
+          let tab;
+          try {
+            tab = await browser.tabs.create({
+              windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
+              cookieStoreId: data.cookieStoreId,
+            });
+
+            browser.test.assertTrue(!data.failure, "we want a success");
+          } catch (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") {
@@ -67,38 +69,40 @@ add_task(function* () {
                                       "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;
-          });
+            browser.test.sendMessage("test-done");
+            return;
+          }
 
-          if (tab) {
-            {
-              // Tests for tab querying
-              let [tab] = await browser.tabs.query({
-                windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
-                cookieStoreId: data.cookieStoreId,
-              });
+          // Tests for tab creation
+          testTab(data, tab);
 
-              browser.test.assertTrue(tab != undefined, "Tab found!");
-              testTab(data, tab);
-            }
-
-            let stores = await browser.cookies.getAllCookieStores();
+          {
+            // Tests for tab querying
+            let [tab] = await browser.tabs.query({
+              windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
+              cookieStoreId: data.cookieStoreId,
+            });
 
-            let store = stores.find(store => store.id === tab.cookieStoreId);
-            browser.test.assertTrue(!!store, "We have a store for this tab.");
+            browser.test.assertTrue(tab != undefined, "Tab found!");
+            testTab(data, tab);
+          }
 
-            await browser.tabs.remove(tab.id);
-          }
+          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);
 
           browser.test.sendMessage("test-done");
         } catch (e) {
           browser.test.fail("An exception has been thrown");
         }
       }
 
       async function initialize() {