w3c / webextensions

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

Proposal: Dispatch DOM events to content script handlers first #651

Closed MoeBazziGIT closed 4 months ago

MoeBazziGIT commented 4 months ago

A technical limitation extension developers often deal with is their content script's DOM event listeners are not dispatched because of the document's other script listeners being dispatched first and potentially stopping propagation. In order for web extension's to truly be an extension of a browser, I think they should be able to listen to DOM events before non-extension scripts do. Currently, this is only possible by adding event listeners when your content script run_at is set to document_start, however, it is not possible when you inject a content script at other time later in the document.

I havent thought much to how this feature could be potentially toggled on/off by the extension (e.g. an extension's content script might want to listen to evens in the natural order they are propagated), nor other potential downfalls of this. Regarding the order of dispatching for all attached content scripts, it can follow the install date of the extensions, similar to how other APIs deal with this.

hanguokai commented 4 months ago

This is a duplicate of #375

MoeBazziGIT commented 4 months ago

This is a duplicate of #375

Right, I missed it! Thank you!