addon is not defined in page-worker

VERIFIED FIXED in Firefox 41

Status

P1
blocker
VERIFIED FIXED
3 years ago
3 years ago

People

(Reporter: sriharsha.angara, Assigned: mossop, NeedInfo)

Tracking

unspecified
mozilla43
x86_64
Mac OS X

Firefox Tracking Flags

(firefox41 fixed, firefox42 fixed, firefox43 verified)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12

Steps to reproduce:

I am following the steps on this link below
https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-worker#Scripting_trusted_page_content

In my content script that gets loaded by the page-worker. 

When I try to access the global "addon" object


Actual results:

Error message is received: ReferenceError: addon is not defined


Expected results:

Addon object should be available.
(Reporter)

Updated

3 years ago
OS: Unspecified → Mac OS X
Priority: -- → P2
Hardware: Unspecified → x86_64
Version: Trunk → 40 Branch
(Reporter)

Comment 1

3 years ago
Messaging between pageworker's trusted content scripts and main.js is broken. This is a blocker for us. Can someone help us out please ?
Severity: normal → blocker
Priority: P2 → P1
(Reporter)

Updated

3 years ago
Component: Untriaged → General
Product: Firefox → Add-on SDK
Version: 40 Branch → unspecified
Mossop, do you know if this is a regression or an intentional change?
Flags: needinfo?(dtownsend)
(Assignee)

Comment 3

3 years ago
(In reply to Jorge Villalobos [:jorgev] from comment #2)
> Mossop, do you know if this is a regression or an intentional change?

I doubt it is intentional. Do we know which version of Firefox this started with?
Flags: needinfo?(dtownsend)
(Reporter)

Comment 4

3 years ago
The problem started with firefox 40. Firefox 39 works just fine.
From a different developer (possibly the same problem):

> After many hours of mucking around, it seems that the old postMessage message passing functionality to
> and from a PageWorker was broken:  
> Previously, if you created a page with:
>
> page = pageWorker.Page({ ... })
>
> you could pass messages to it using page.postMessage, and receive messages using self.on. 
> This seems to still work correctly with PageMod, but not when creating a page with PageWorker.
(Assignee)

Comment 6

3 years ago
Broken by bug 870677
Blocks: 870677
(Assignee)

Comment 7

3 years ago
Created attachment 8652414 [details] [diff] [review]
patch

There turn out to be two bugs here. The first makes page.contentURL be null until the page loads properly since it uses the data-src attribute which isn't set in the constructor. That means addon isn't defined until after the load. The second bug is that add-on doesn't get defined at all when using the new e10s compatible worker. The simple fix here is to switch back to the sync loader and since page-worker doesn't load anything remotely that shouldn't cause any issues.
Assignee: nobody → dtownsend
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8652414 - Flags: review?(jsantell)
Attachment #8652414 - Flags: review?(jsantell) → review+
https://hg.mozilla.org/mozilla-central/rev/3120499da074
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox43: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43

Comment 10

3 years ago
will this fix be ported into  FF40.0.3?
or atleast "beta" channel?

this bug is blocker.
(Assignee)

Comment 11

3 years ago
(In reply to nkanand from comment #10)
> will this fix be ported into  FF40.0.3?

No, we generally only take security fixes on the release channel.

> or atleast "beta" channel?

I'll be nominating it after it has baked on nightly for a few days, I would guess at a good chance for aurora, not so sure about beta at this point.
(Assignee)

Comment 12

3 years ago
Comment on attachment 8652414 [details] [diff] [review]
patch

Approval Request Comment
[Feature/regressing bug #]: Certain parts of the page-worker SDK module have been broken, most recent breakage affects Firefox 40.
[User impact if declined]: Some add-ons won't work
[Describe test coverage new/current, TreeHerder]: On m-c with automated tests
[Risks and why]: Low risk, only affects add-on SDK code and has tests to ensure it does what it means to
[String/UUID change made/needed]: None
Attachment #8652414 - Flags: approval-mozilla-beta?
Attachment #8652414 - Flags: approval-mozilla-aurora?
status-firefox41: --- → affected
status-firefox42: --- → affected
Comment on attachment 8652414 [details] [diff] [review]
patch

Sure, let's take it for aurora. Ritu will make the call for 41.
Attachment #8652414 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Dimitri, Nkanand, could you please verify this fix works well on the latest Nightly 8/27 or later build? Thanks.
Flags: needinfo?(sriharsha.angara)
Flags: needinfo?(nkanand)
Comment on attachment 8652414 [details] [diff] [review]
patch

Approving for uplift to Beta41 as this is a severe issue and the patch seems simple. It is also nice to see more automated tests for this one.
Attachment #8652414 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
(Reporter)

Comment 18

3 years ago
Fix looks good in Firefox nightly. Thank you!
Flags: needinfo?(sriharsha.angara)
Thanks Dimitri. Based on comment 18, updating status to verified where relevant.
Status: RESOLVED → VERIFIED
status-firefox43: fixed → verified

Comment 20

3 years ago
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/40232ea9e193ea1060abe05d07d0b51c022141ff
Bug 1195589: addon is not defined in page-worker scripts. r=jsantell
You need to log in before you can comment on or make changes to this bug.