Closed Bug 788981 Opened 12 years ago Closed 12 years ago

self.port.removeListener() in a content script isn't functional

Categories

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

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jwkbugzilla, Unassigned)

References

()

Details

Attachments

(1 file)

It seems that self.port.removeListener() isn't working at all in content scripts, self.port.once() isn't working properly either for that reason. The bug in is this line api-utils/lib/content/content-worker.js:

        let index = listeners[name].indexOf(name);

This should search the callback, not the event type:

        let index = listeners[name].indexOf(callback);

With this change things work properly.
Attached patch s/name/callback/Splinter Review
All tests seem to pass with this change applied.
Attachment #658964 - Flags: review?(poirot.alex)
Comment on attachment 658964 [details] [diff] [review]
s/name/callback/

Thanks for the patch :)
Attachment #658964 - Flags: review?(poirot.alex) → review+
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/2190a6471c9b65fd5d1c2b9d71b6ec9c89d7dfe3
Bug 788981:  self.port.removeListener() in a content script isn't functional r=@ochameau
Wes, I don't think it would justify spinning another rc, but in case we do, it would be worth shipping that into 1.10.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.11
(In reply to Alexandre Poirot (:ochameau) from comment #5)
> Wes, I don't think it would justify spinning another rc, but in case we do,
> it would be worth shipping that into 1.10.

I think Will was wanting to get some doc changes into 1.10, so if he gets those in before we need to make the final call for 1.10, I'll pull this in, too.
+1 for putting this in 1.10.
Commit pushed to stabilization at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/5703e32f2e1b4de7fd88b34473f6d0d9c13176ca
Bug 788981:  self.port.removeListener() in a content script isn't functional r=@ochameau
(cherry picked from commit 2190a6471c9b65fd5d1c2b9d71b6ec9c89d7dfe3)
The fix is probably correct, but self.port.removeListener() is still not functional when a different listener is reassigned afterwards: In this case the old ("removed") listener is magically reproduced and executed.

Created new bug 844433 for this to let this here sleep. Just wanted to mention it.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: