Bug 1245355 Add a unit test for tabs.getAllInWindow r?kmag draft
authorMatthew Wein <mwein@mozilla.com>
Tue, 15 Mar 2016 12:01:40 +0100
changeset 340479 d8814d1f6e04d40987c21cfa3ef97a05e27cafe0
parent 338095 05c087337043dd8e71cc27bdb5b9d55fd00aaa26
child 516194 0d98fc7407ca45107bae9f7165778abd56f785a8
push id12974
push usermwein@mozilla.com
push dateTue, 15 Mar 2016 11:06:26 +0000
reviewerskmag
bugs1245355
milestone48.0a1
Bug 1245355 Add a unit test for tabs.getAllInWindow r?kmag MozReview-Commit-ID: 5wVRCLdCuq9
browser/components/extensions/ext-tabs.js
browser/components/extensions/test/browser/browser.ini
browser/components/extensions/test/browser/browser_ext_tabs_getAllInWindow.js
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -538,21 +538,18 @@ extensions.registerSchemaAPI("tabs", nul
         let tab;
         if (context.tabId) {
           tab = TabManager.convert(extension, TabManager.getTab(context.tabId));
         }
         return Promise.resolve(tab);
       },
 
       getAllInWindow: function(windowId) {
-        if (windowId === null) {
-          windowId = WindowManager.topWindow.windowId;
-        }
-
-        return self.tabs.query({windowId});
+        let window = WindowManager.getWindow(windowId, context);
+        return Promise.resolve(TabManager.for(extension).getTabs(window));
       },
 
       query: function(queryInfo) {
         let pattern = null;
         if (queryInfo.url !== null) {
           pattern = new MatchPattern(queryInfo.url);
         }
 
--- a/browser/components/extensions/test/browser/browser.ini
+++ b/browser/components/extensions/test/browser/browser.ini
@@ -33,16 +33,17 @@ support-files =
 [browser_ext_tabs_detectLanguage.js]
 [browser_ext_tabs_events.js]
 [browser_ext_tabs_executeScript.js]
 [browser_ext_tabs_executeScript_good.js]
 [browser_ext_tabs_executeScript_bad.js]
 [browser_ext_tabs_executeScript_runAt.js]
 [browser_ext_tabs_insertCSS.js]
 [browser_ext_tabs_query.js]
+[browser_ext_tabs_getAllInWindow.js]
 [browser_ext_tabs_getCurrent.js]
 [browser_ext_tabs_create.js]
 [browser_ext_tabs_create_invalid_url.js]
 [browser_ext_tabs_duplicate.js]
 [browser_ext_tabs_update.js]
 [browser_ext_tabs_update_url.js]
 [browser_ext_tabs_onUpdated.js]
 [browser_ext_tabs_sendMessage.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_getAllInWindow.js
@@ -0,0 +1,22 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(function* () {
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "permissions": ["tabs"],
+    },
+
+    background: function() {
+      browser.tabs.getAllInWindow(browser.windows.WINDOW_ID_CURRENT, tabs => {
+        browser.test.assertEq(1, tabs.length, "There should be only 1 tab in the window");
+        browser.test.notifyPass("tabs.getAllInWindow");
+      });
+    },
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("tabs.getAllInWindow");
+  yield extension.unload();
+});