use of "self" module methods in content scripts is unclear

RESOLVED FIXED in 1.1

Status

Add-on SDK
Documentation
P2
normal
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: Jan D, Assigned: wbamberg)

Tracking

unspecified
All
Other

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [cherry-pick-1.1])

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110615151330

Steps to reproduce:

I wanted to find informations on what the "self"-object is and which methods it has.


Actual results:

I found a small section on self in the "addon-kit" section of the SDK documentation, listing two methods. 
In the section Programming Guides/Working with Content Scripts there are semingly methods of "self" described that were not included in the add-on-kit/self section:
- self.port.on
- self.port.emit
Reading in the Content Scripts-Section it seems that these seem to be related to the contend script rather than to the add-on as a whole but this would be in contradiction with the statement "The self module provides access to data that is bundled with the add-on as a whole"


Expected results:

It should be described in the "self" section when and why methods like self.port.on and self.port.emit can be awoken on the self object.
(Assignee)

Updated

7 years ago
Assignee: nobody → wbamberg
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Target Milestone: --- → 1.1
(Assignee)

Comment 1

7 years ago
Created attachment 551902 [details] [diff] [review]
Clarified that self module is different from the content script global self object

I think this is quite an unfortunate naming clash. All I've done here is added some text in the places where it might be helpful, to clarify that the two things called 'self' are completely different.
Attachment #551902 - Flags: review?(warner-bugzilla)
Comment on attachment 551902 [details] [diff] [review]
Clarified that self module is different from the content script global self object

Looks good. Yeah, this is a really unfortunate collision. Maybe we should consider renaming require("self").. require("addon") ? "main"? "aboutme"?
Attachment #551902 - Flags: review?(warner-bugzilla) → review+
Could be painful for addon devs to change "self" to something else at this point.

Of the suggested new names, though, "addon" makes the most sense to me.
(Assignee)

Comment 4

7 years ago
Thanks Brian! Fixed in https://github.com/mozilla/addon-sdk/commit/e5c289eac375d2d7d69c62c3e4c492acc66a0072

I think "addon" is a good suggestion, too - except that not all packages are addons. require("package")? I don't know whether it's already too late to make the change (obviously the old way would still be supported, but at least newcomers would be spared the confusion).
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
Whiteboard: [cherry-pick-1.1]
You need to log in before you can comment on or make changes to this bug.