Bug 1245355 - Add a unit test for tabs.getAllInWindow r=kmag
☠☠ backed out by 03bf161a225e ☠ ☠
authorMatthew Wein <mwein@mozilla.com>
Tue, 15 Mar 2016 12:01:40 +0100
changeset 289062 562dbcad5a6e32ad1a1bfa544f83c62066cd4dbf
parent 289061 31f70cb239b384697e7882661b311b6709b1cd15
child 289063 06ae85d888e8b112a60cf34fe2f1a305ea92d8c0
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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
@@ -35,16 +35,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();
+});