Closed Bug 1301609 Opened 8 years ago Closed 8 years ago

Cyclical reference to unsafeWindow in PageMod content script when installing extension via mozAddonManager.

Categories

(Toolkit :: Add-ons Manager, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: chuck, Unassigned)

Details

Cyclical reference to unsafeWindow in PageMod content script when installing extension via mozAddonManager.

Test Pilot uses a PageMod [1] with a content script [2] to add a property to existing windows that let the website [3] know that the add-on has been successfully installed. This works brilliantly when using normal extension installation methods, but fails when installing via mozAddonManager.

Some debugging shows that an attempt to `console.log(unsafeWindow)` in the content script errors with `TypeError: cyclic object value`, which seems to silently prevent those properties from being set. Installation succeeds otherwise (enable code run, etc).

Code can be browsed here: https://github.com/chuckharmston/testpilot/tree/1223-mozaddonmanager
The new code to call mozAddonManager is here: https://github.com/chuckharmston/testpilot/blob/1223-mozaddonmanager/frontend/src/app/lib/install-addon.js#L13-L21

Stack trace:

onEvent@
resource://gre/modules/commonjs/toolkit/loader.js ->
resource://gre/modules/commonjs/sdk/loader/sandbox.js ->
resource://gre/modules/commonjs/sdk/content/content-worker.js:76:17@resource://gre/modules/commonjs/toolkit/loader.js ->
resource://gre/modules/commonjs/sdk/loader/sandbox.js ->
resource://testpilot-addon/data/set-installed-flag.js:11:1

[1] https://github.com/mozilla/testpilot/blob/94eb542ebeec0342eecbbea45be07dbdeb09f963/addon/lib/app.js#L43
[2] https://github.com/mozilla/testpilot/blob/9c06d9293d6655721a0a4cf53262ecf7b92c8954/addon/data/set-installed-flag.js
[3] https://github.com/mozilla/testpilot/blob/6bd599eb1c3396883a7a98acaf6671dd49e03132/frontend/src/app/lib/install-addon.js#L23-L25
So my diagnosis is a bit misleading; :John-Galt pointed out that all windows are cyclical object references, and this error indicates that it can't be serialized to JSON.

The symptom still remains, though: the properties in the content script are not set when the extension is installed via mozAddonManager, though they are when installed using traditional means.
This was my mistake, totally unrelated. Sorry for the noise!
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.