Closed Bug 1298716 Opened 8 years ago Closed 8 years ago

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

Categories

(WebExtensions :: Untriaged, defect, P2)

51 Branch
defect

Tracking

(firefox51 fixed)

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: robwu, Assigned: robwu)

Details

(Whiteboard: triaged)

Attachments

(2 files)

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
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+
Keywords: checkin-needed
Looks like autoland hit conflicts trying to land this.
Keywords: checkin-needed
Rebased.
Keywords: checkin-needed
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
https://hg.mozilla.org/mozilla-central/rev/0e36be603b70
https://hg.mozilla.org/mozilla-central/rev/d316aa33106d
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: