w3c / webextensions

Charter and administrivia for the WebExtensions Community Group (WECG)
Other
595 stars 56 forks source link

Proposal: tabs.Tab should include the documentId. #495

Closed newRoland closed 10 months ago

newRoland commented 10 months ago

Context

The documentId has use cases throughout the WebExtensions APIs, and more is to come. However, the only ways to retrieve it seems to be by pinging a content script or using the WebNavigation permission (getFrame, onCommitted).

The WebNavigation permission has a permissions warning that many extension publishers will like to avoid. It's also safer for the user if the extension doesn't need it. The developer might also not have a content script available for pinging.

Proposal

The Tab object already includes information on the tab's main frame like URL, pendingURL, favicon, etc. I propose also including the documentId and pendingDocumentId. That way it can be retrieved through tabs.get or tabs.query.

newRoland commented 10 months ago

Turns out you can also retrieve the documentId from pinging a content script and getting a reply. OnMessage sender includes documentId. The proposal is still useful, but it's no longer necessary for me.

fregante commented 10 months ago

This would still be useful and make a lot of sense. Having to ping the content script means you also need the scripting permission, whereas accessing this documentId probably wouldn't even need tabs

newRoland commented 10 months ago

I can't think about specific examples it would be needed. It's worth it for the convenience alone, but I don't think they will implement the proposal without a stronger justification.

fregante commented 10 months ago

If you reopen they will decide. If not I'll reopen the issue myself

newRoland commented 10 months ago

A better proposal might be to alias getFrame, and getAllFrames, so it's accessible from both webNavigation and tabs.