Closed Bug 630016 Opened 13 years ago Closed 13 years ago

Addon builder XPI with toolbar buttons code to respond to clicks is broken by default

Categories

(addons.mozilla.org Graveyard :: Developer Pages, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 624245

People

(Reporter: mike.maccana, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.83 Safari/534.13
Build Identifier: 

Using the extension builder and checking toolbar button results in the following code inside overlay.js. The code does not create any prompts, apparently as 'this' cannot be used in onLoad. The code has not been modified in any way from the XPI produced by Addon Builder.

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

	  onMenuItemCommand: function(e) {
	    var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
	                                  .getService(Components.interfaces.nsIPromptService);
	    promptService.alert(window, this.strings.getString("helloMessageTitle"),
	                                this.strings.getString("helloMessage"));
	  },

	  onToolbarButtonCommand: function(e) {
	    // just reuse the function above.  you can change this, obviously!
	    mytestextension.onMenuItemCommand(e);
	  }
	};



Reproducible: Always

Steps to Reproduce:
1.Create extension with 'Toolbar button'.
2.Load extension
3.Click toolbar button
Actual Results:  
No response to clicking.

Expected Results:  
A hello message should be presented.

Further details and discussion are at http://stackoverflow.com/questions/4831459/firefox-addon-promptservice-doesnt-work-from-mozillas-own-sample-code
Blocks: 628654
No longer blocks: 628654
Will, any idea what this person is talking about? This code is clearly not Add-on SDK code.
I've never seen that! I thought this was related to the Add-on Builder (https://builder.addons.mozilla.org/).

Apparently AMO has two products with the same name.
Component: Add-on Builder → Developer Pages
QA Contact: add-on-builder → developers
To confirm, the product mentioned is indeed the one that appears at 
https://addons.mozilla.org/en-US/developers/tools/builder per Wes' comment.
I believe this is the same issue as bug 624245 ('this' not referencing the correct thing in within onload.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Ah, yup!
Status: RESOLVED → VERIFIED
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.