Using document events directly in WebExtensions override them
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(Not tracked)
People
(Reporter: sami.vanttinen, Unassigned, NeedInfo)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:66.0) Gecko/20100101 Firefox/66.0
Steps to reproduce:
Our WebExtension's content script had one function calling directly document.onclick() event instead of addEventListener('click').
An example is to use a page https://doc.rust-lang.org/std/fs/struct.File.html and click the expand/collapse (+/-) buttons with a WebExtension that uses document.onclick in the content script.
Actual results:
The document.onclick event was overridden and the page's own scripts didn't work properly anymore.
Expected results:
Any direct calls to document events should be at least wrapped as event listeners. Using direct calls should not override page's own events.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Hi sami.vanttinen,
I wasn't able to reproduce this issue. I have tested it on latest Nightly version (68.0a1 (2019-04-24)
Would you kindly provide an example or webextension you use to reproduce it?
Please could you try to retest this on the latest Nightly Version?
You can downloaded to https://www.mozilla.org/en-US/firefox/nightly/all/
Comment 2•5 years ago
|
||
Extension content scripts share the same DOM with the page. That is by design, and the only way most of extensions could work.
Each content script gets its own JS properties on DOM nodes, variables, and indeed event listeners. It is responsibility of extension authors to be careful about not breaking the web page.
Updated•5 years ago
|
Description
•