window.onclick assignment doesn't work in content scripts

RESOLVED FIXED

Status

Add-on SDK
General
P1
normal
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: wbamberg, Assigned: ochameau)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
In a content script, adding an event listener to window by assignment doesn't work:

window.onclick = function() {
  window.alert("You clicked me 1");
};

All these alternatives do work:

// assignment to a different object than window
window.document.onclick = function() {
  window.alert("You clicked me 2");
};

// addEventListener on window
window.addEventListener("click", function() {
  window.alert("You clicked me 3");
}, false);

// assignment to unsafeWindow
unsafeWindow.onclick = function() {
  window.alert("You clicked me 4");
};

This was reported in the forum: https://forums.mozilla.org/addons/viewtopic.php?f=27&t=11255.
Alex, same question here about content proxy removal?
Whiteboard: [triage:followup]

Updated

6 years ago
Assignee: nobody → poirot.alex

Updated

6 years ago
Priority: -- → P1
Whiteboard: [triage:followup]
(Assignee)

Comment 2

5 years ago
Do works now. (FF18, sdk master)
window.onload still fails but other events do works (tested input, click, scroll).
So load seems to be a special case.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.