From 82cfa8e2d94aa2ccd5ac96a0495a3c1c37594126 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Fri, 5 Oct 2018 13:42:33 +0000 Subject: [PATCH] Bug 1489814 - Add 'populate' parameter in 'tabs.highlight'. r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D7240 --HG-- extra : moz-landing-system : lando --- browser/components/extensions/parent/ext-tabs.js | 4 ++-- browser/components/extensions/schemas/tabs.json | 6 ++++++ .../extensions/test/browser/browser_ext_tabs_highlight.js | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index 2ee4a31d2431..2816f3906f79 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -1282,7 +1282,7 @@ this.tabs = class extends ExtensionAPI { if (!gMultiSelectEnabled) { throw new ExtensionError(`tabs.highlight is currently experimental and must be enabled with the ${MULTISELECT_PREFNAME} preference.`); } - let {windowId, tabs} = highlightInfo; + let {windowId, tabs, populate} = highlightInfo; if (windowId == null) { windowId = Window.WINDOW_ID_CURRENT; } @@ -1299,7 +1299,7 @@ this.tabs = class extends ExtensionAPI { } return tab; }); - return windowManager.convert(window, {populate: true}); + return windowManager.convert(window, {populate}); }, }, }; diff --git a/browser/components/extensions/schemas/tabs.json b/browser/components/extensions/schemas/tabs.json index f137c2922c2f..6a7f8ae95dd4 100644 --- a/browser/components/extensions/schemas/tabs.json +++ b/browser/components/extensions/schemas/tabs.json @@ -800,6 +800,12 @@ "description": "The window that contains the tabs.", "minimum": -2 }, + "populate": { + "type": "boolean", + "optional": true, + "default": true, + "description": "If true, the $(ref:windows.Window) returned will have a tabs property that contains a list of the $(ref:tabs.Tab) objects. The Tab objects only contain the url, title and favIconUrl properties if the extension's manifest file includes the \"tabs\" permission. If false, the $(ref:windows.Window) won't have the tabs property." + }, "tabs": { "description": "One or more tab indices to highlight.", "choices": [ diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js b/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js index c0b44a81aaad..7adce4bc247c 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js @@ -68,6 +68,9 @@ add_task(async function test_highlighted() { browser.test.assertEq(3, window.tabs.length, "Returned window should be populated"); + window = await browser.tabs.highlight({tabs: 2, populate: false}); + browser.test.assertFalse("tabs" in window, "Returned window shouldn't be populated"); + browser.test.notifyPass("test-finished"); }, });