Closed Bug 1464862 Opened 6 years ago Closed 6 years ago

Expose multiselected status to "tabs.Tab.highlighted", and allow to change it via "browser.tabs.highlight()"

Categories

(WebExtensions :: Untriaged, enhancement, P5)

enhancement

Tracking

(firefox62 wontfix, firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox62 --- wontfix
firefox63 --- fixed

People

(Reporter: yuki, Assigned: Oriol)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

By the bug 1458010 and the bug 1458013, now tabs can have multiselected status. On the other hand, there is no way to know the status via WebExtensions APIs, and it is also impossible to change the status via APIs. The status should be exposed to WE APIs for tab related addons.
I believe this is achieved in Chrome by setting highlighted to true on the tabs that are selected.

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/highlight
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab

So the title of this bug could be "Support browser.tabs.highlight".
Summary: Expose multiselected status to tabs.Tab → Expose multiselected status to "tabs.Tab.highlighted", and allow to change it via "browser.tabs.highlight()"
Priority: -- → P5
I've looked the patch and I think something mechanism to notify updated "highlighted" status to listeners of tabs.onUpdated looks necessary.
Not sure what to do if the pref is disabled. Then a webextension may highlight tabs, and the user won't be able to clear them by clicking a tab.

Also, some things I did for compatibility with Chrome, but I'm not sure if they are good ideas:
 - The schema enforces a minimum index of 0 when using an array, but not when using a single integer, then you only get a rejection. So it's not consistent.
 - The method rejects if the array is empty, but this could be enforced in the schema.
 - The returned window is populated with all its tabs (even if you only highlighted one). This will be slow if there are lots of tabs, IMO seems unnecessary, and the documentation doesn't mention it.


(In reply to YUKI "Piro" Hiroshi from comment #3)
> I've looked the patch and I think something mechanism to notify updated
> "highlighted" status to listeners of tabs.onUpdated looks necessary.

This can be a different bug, together with onHighlighted, which should be moved outside of bug 1465170 anyways, because it's not related at all to tabs.query
(In reply to Oriol Brufau [:Oriol] from comment #4)
> Not sure what to do if the pref is disabled. Then a webextension may
> highlight tabs, and the user won't be able to clear them by clicking a tab.

If the pref is disabled then we should just do nothing I would propose. Extensions could check if the `tabs.Tab.highlighted` to see if it was effective.
(In reply to Jared Wein [:jaws] (please needinfo? me) from comment #5)
> If the pref is disabled then we should just do nothing I would propose.
> Extensions could check if the `tabs.Tab.highlighted` to see if it was
> effective.

Do nothing and throw an error or just fail silently?

Ideally I would like browser.tabs.highlight to become undefined when the pref is false, but it seems there is no easy way to do this.
If the pref is false, highlight should behave however it currently behaves.
(In reply to Shane Caraveo (:mixedpuppy) from comment #7)
> If the pref is false, highlight should behave however it currently behaves.

Currently it's not supported:

  browser.tabs.highlight; // undefined

How can I make this depend on a pref?
Product: Toolkit → WebExtensions
Assignee: nobody → oriol-bugzilla
Comment on attachment 8982916 [details]
Bug 1464862 - Expose multiselected status to "tabs.Tab.highlighted", and allow to change it via "browser.tabs.highlight()"

https://reviewboard.mozilla.org/r/248742/#review258510

::: browser/components/extensions/parent/ext-tabs.js:1240
(Diff revision 1)
>            }
>            return hidden;
>          },
> +
> +        highlight(highlightInfo) {
> +          let {windowId, tabs} = highlightInfo;

Check the multiselect pref here and throw an error if it is false.

::: browser/components/extensions/test/browser/browser_ext_tabs_highlight.js:7
(Diff revision 1)
> +/* vim: set sts=2 sw=2 et tw=80: */
> +/* global gBrowser SessionStore */
> +"use strict";
> +
> +add_task(async function test_highlighted() {
> +  let extension = ExtensionTestUtils.loadExtension({

You need to use specialpowers.pushprefenv to ensure the multiselect pref is true.

::: mobile/android/components/extensions/ext-utils.js:523
(Diff revision 1)
> +  get highlighted() {
> +    return this.active;
> +  }

be sure this platform difference is documented on mdn correctly.
Attachment #8982916 - Flags: review?(mixedpuppy) → review+
The selected tab should be part of the multi-selection (bug 1468443).
Keywords: checkin-needed
Pushed by nbeleuzu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4e78d806cb63
Expose multiselected status to "tabs.Tab.highlighted", and allow to change it via "browser.tabs.highlight()" r=mixedpuppy
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4e78d806cb63
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Keywords: dev-doc-needed
Depends on: 1472305
Is manual testing required on this bug? If yes, please provide some STR and the proper extension(if required) or set the “qe-verify -“ flag.

Thanks!
Flags: needinfo?(oriol-bugzilla)
Covered by automated tests
Flags: needinfo?(oriol-bugzilla) → qe-verify-
Depends on: 1489814
Created a pull request to update the compatibility data and added the following to the release notes:

tabs.Tab property properly reflects which tabs in a browser window are selected (highlighted) and tabs.highlight supports changing the highlighted status of multiple tabs (bug 1464862).
Flags: needinfo?(oriol-bugzilla)
Looks good, thanks
Flags: needinfo?(oriol-bugzilla)
Duplicate of this bug: 1464601
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: