ExtensionTestUtils.loadExtension from ExtensionTestUtils.js does not serialize function keys

RESOLVED FIXED in Firefox 51

Status

()

Toolkit
WebExtensions: Untriaged
P2
normal
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: robwu, Assigned: robwu)

Tracking

51 Branch
mozilla51
Points:
---

Firefox Tracking Flags

(firefox51 fixed)

Details

(Whiteboard: triaged)

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(2 attachments)

(Assignee)

Description

2 years ago
There are two ExtensionTestUtils.loadExtension methods with seemingly the same API:
- ExtensionXPCShellUtils.jsm [1]
- ExtensionTestUtils.js [2]

The first file supports functions that are automatically serialized to strings:

function background() { /* ... */ }
ExtensionTestUtils.loadExtension({
  background,
});

The second file does not, because the functions are lost by SpecialPowers.loadExtension [3].
The work-around is to explicitly pass a string:

function background() { /* ... */ }
ExtensionTestUtils.loadExtension({
  background: `(${background})();`,
});


... but ideally this should be fixed because this difference in the seemingly identical APIs are causing unexpected issues when writing tests.


[1] http://searchfox.org/mozilla-central/rev/f80822840bc5f3d2d3cae3ece621ddbce72e7f54/toolkit/components/extensions/ExtensionXPCShellUtils.jsm#294
[2] http://searchfox.org/mozilla-central/rev/f80822840bc5f3d2d3cae3ece621ddbce72e7f54/testing/mochitest/tests/SimpleTest/ExtensionTestUtils.js#3
[3] http://searchfox.org/mozilla-central/rev/f80822840bc5f3d2d3cae3ece621ddbce72e7f54/testing/specialpowers/content/specialpowersAPI.js#1933
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Updated

2 years ago
Priority: -- → P2
Whiteboard: triaged
Comment on attachment 8785751 [details]
Bug 1298716 - Serialize extension in ExtensionTestUtils.loadExtension

https://reviewboard.mozilla.org/r/74838/#review73284
Attachment #8785751 - Flags: review?(wmccloskey) → review+
Comment on attachment 8785752 [details]
Bug 1298716 - Unify use of ExtensionTestUtils.loadExtension

https://reviewboard.mozilla.org/r/74840/#review73286
Attachment #8785752 - Flags: review?(wmccloskey) → review+
(Assignee)

Updated

2 years ago
Keywords: checkin-needed
Looks like autoland hit conflicts trying to land this.
Keywords: checkin-needed
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
(Assignee)

Comment 8

2 years ago
Rebased.
Keywords: checkin-needed

Comment 9

2 years ago
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/0e36be603b70
Serialize extension in ExtensionTestUtils.loadExtension r=billm
https://hg.mozilla.org/integration/autoland/rev/d316aa33106d
Unify use of ExtensionTestUtils.loadExtension r=billm
Keywords: checkin-needed

Comment 10

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/0e36be603b70
https://hg.mozilla.org/mozilla-central/rev/d316aa33106d
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox51: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.