Bug 1489814 - Add 'populate' parameter in 'tabs.highlight'. r=mixedpuppy
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Fri, 05 Oct 2018 13:42:33 +0000
changeset 495535 7be15d7f2e61b94ab7cea2e806ccb9e12d693e83
parent 495534 bf17ad5b022fd82b89695a945a687b1a6aef5f7d
child 495536 60713d0fd643ddaec675161eabc6538301f51b1c
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1489814
milestone64.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 1489814 - Add 'populate' parameter in 'tabs.highlight'. r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D7240
browser/components/extensions/parent/ext-tabs.js
browser/components/extensions/schemas/tabs.json
browser/components/extensions/test/browser/browser_ext_tabs_highlight.js
--- a/browser/components/extensions/parent/ext-tabs.js
+++ b/browser/components/extensions/parent/ext-tabs.js
@@ -1277,32 +1277,32 @@ this.tabs = class extends ExtensionAPI {
           }
           return hidden;
         },
 
         highlight(highlightInfo) {
           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;
           }
           let window = windowTracker.getWindow(windowId, context);
           if (!Array.isArray(tabs)) {
             tabs = [tabs];
           } else if (tabs.length == 0) {
             throw new ExtensionError("No highlighted tab.");
           }
           window.gBrowser.selectedTabs = tabs.map((tabIndex) => {
             let tab = window.gBrowser.tabs[tabIndex];
             if (!tab) {
               throw new ExtensionError("No tab at index: " + tabIndex);
             }
             return tab;
           });
-          return windowManager.convert(window, {populate: true});
+          return windowManager.convert(window, {populate});
         },
       },
     };
     return self;
   }
 };
--- a/browser/components/extensions/schemas/tabs.json
+++ b/browser/components/extensions/schemas/tabs.json
@@ -795,16 +795,22 @@
             "name": "highlightInfo",
             "properties": {
                "windowId": {
                  "type": "integer",
                  "optional": true,
                  "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 <var>tabs</var> property that contains a list of the $(ref:tabs.Tab) objects. The <code>Tab</code> objects only contain the <code>url</code>, <code>title</code> and <code>favIconUrl</code> properties if the extension's manifest file includes the <code>\"tabs\"</code> permission. If false, the $(ref:windows.Window) won't have the <var>tabs</var> property."
+               },
                "tabs": {
                  "description": "One or more tab indices to highlight.",
                  "choices": [
                    {"type": "array", "items": {"type": "integer", "minimum": 0}},
                    {"type": "integer"}
                  ]
                }
              }
--- a/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_highlight.js
@@ -63,16 +63,19 @@ add_task(async function test_highlighted
       await testHighlighted(1, [0]);
 
       browser.test.log("Highlight last tab");
       let window = await browser.tabs.highlight({tabs: 2});
       await testHighlighted(2, []);
 
       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");
     },
   });
 
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
 
   await extension.startup();