Closed Bug 787345 Opened 12 years ago Closed 11 years ago

window.onclick assignment doesn't work in content scripts

Categories

(Add-on SDK Graveyard :: General, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wbamberg, Assigned: ochameau)

Details

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]
Priority: -- → P1
Whiteboard: [triage:followup]
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
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.