Bug 1261185 - Complete test coverage for browser.windows.create, r=kmag
☠☠ backed out by 4b3a929c9249 ☠ ☠
authorbsilverberg <bsilverberg@mozilla.com>
Thu, 31 Mar 2016 18:01:45 -0400
changeset 291727 ffd37011577923985b68a6e7b5c2699771dc2cdd
parent 291726 74445dd48b67cae0aeb13f29a8cb46160f45fa46
child 291728 0712c02d259e1e0dab776372bc52ee22b0c92091
push id74648
push usercbook@mozilla.com
push dateTue, 05 Apr 2016 14:54:47 +0000
treeherdermozilla-inbound@98a2f0b4690a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1261185
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1261185 - Complete test coverage for browser.windows.create, r=kmag Add coverage for: * passing an invalid |tabId| * passing an array of URLs to open in |url| MozReview-Commit-ID: EW8sh0p6hgB
browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
--- a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js
@@ -8,16 +8,27 @@ add_task(function* testWindowCreate() {
       return new Promise(resolve => {
         browser.tabs.onAttached.addListener(function listener() {
           browser.tabs.onAttached.removeListener(listener);
           resolve();
         });
       });
     };
 
+    let promiseTabUpdated = (expected) => {
+      return new Promise(resolve => {
+        browser.tabs.onUpdated.addListener(function listener(tabId, changeInfo, tab) {
+          if (changeInfo.url === expected) {
+            browser.tabs.onUpdated.removeListener(listener);
+            resolve();
+          }
+        });
+      });
+    };
+
     let windowId;
     browser.windows.getCurrent().then(window => {
       windowId = window.id;
 
       browser.test.log("Create additional tab in window 1");
       return browser.tabs.create({windowId, url: "about:blank"});
     }).then(tab => {
       browser.test.log("Create a new window, adopting the new tab");
@@ -81,16 +92,45 @@ add_task(function* testWindowCreate() {
           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 an invalid tabId");
+
+      return 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 browser.windows.create({url: ["http://example.com/", "http://example.org/"]});
+    }).then(window => {
+      return Promise.all([
+        promiseTabUpdated("http://example.com/"),
+        promiseTabUpdated("http://example.org/"),
+        Promise.resolve(window),
+      ]);
+    }).then(([, , window]) => {
+      return browser.windows.get(window.id, {populate: true});
+    }).then(window => {
+      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(() => {
       browser.test.notifyPass("window-create");
     }).catch(e => {
       browser.test.fail(`${e} :: ${e.stack}`);
       browser.test.notifyFail("window-create");
     });
   }
 
   let extension = ExtensionTestUtils.loadExtension({