Closed Bug 1546335 Opened 5 years ago Closed 5 years ago

Using document events directly in WebExtensions override them

Categories

(WebExtensions :: Untriaged, defect)

66 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1330113

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.

Product: Firefox → WebExtensions

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/

Flags: needinfo?(sami.vanttinen)

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.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
Resolution: INVALID → DUPLICATE
You need to log in before you can comment on or make changes to this bug.