Add-on builder incorrectly generates window "load" listeners.

RESOLVED DUPLICATE of bug 556754

Status

--
major
RESOLVED DUPLICATE of bug 556754
8 years ago
4 years ago

People

(Reporter: kmag, Unassigned)

Tracking

Details

(URL)

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110109 Firefox/4.0b9pre
Build Identifier: 

I've rejected quite a lot of add-ons for this bug already. The "load" event listener generated by the add-on builder calls the event handler with its 'this' object bound to the global window rather than the namespace object in question, and thereby leaks the variables 'strings' and 'initialized' to the global namespace. Rather than:

var fooAddon = {
  onLoad: function() {
    // initialization code
    this.initialized = true;
    this.strings = document.getElementById("foo-addon-strings");
  },
  ...
};

window.addEventListener("load", fooAddon.onLoad, false);

It should generate:

var fooAddon = {
  onLoad: function() {
    // initialization code
    this.initialized = true;
    this.strings = document.getElementById("foo-addon-strings");
  },
  ...
};

window.addEventListener("load", function (event) fooAddon.onLoad(event), false);



Reproducible: Always
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 556754
(Assignee)

Updated

4 years ago
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.