Closed Bug 1491397 Opened 6 years ago Closed 6 years ago

Falsey userScriptOptions.scriptMetadata are not available

Categories

(WebExtensions :: General, defect, P5)

defect

Tracking

(firefox64 fixed, firefox65 verified)

VERIFIED FIXED
mozilla64
Tracking Status
firefox64 --- fixed
firefox65 --- verified

People

(Reporter: robwu, Assigned: robwu)

References

Details

Attachments

(2 files)

If scriptMetadata is falsey (false, 0, "", null, undefined), then the metadata is always undefined. STR: 1. Load attached extension in Nightly (including patch for bug 1437864). 2. Visit example.com Expected: - "Got expected data: 0" Actual: - "Unexpected metadata, expected 0, got undefined" This is caused by the following: https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/toolkit/components/extensions/ExtensionContent.jsm#650-651 const clonedMetadata = scriptMetadata ? Cu.cloneInto(scriptMetadata, apiScope) : undefined; How about just declaring clonedMetadata and then lazily cloning the metadata when needed? If the metadata is a large, rarely used object, then that would bring performance benefits.
Priority: -- → P5
Assignee: nobody → rob
Status: NEW → ASSIGNED
This also adds new test coverage for the previously untested features: - "file" in "js" param to userScripts.register works. - "allFrames" set to true in userScripts.register works. - scriptMetadata accepts primitive values, and in particular falsey values in particular (= bug 1491397 ). - scriptMetadata is the same object in all API script calls.
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/84ceb42728e4 Correctly forward falsey scriptMetadata in userScripts API r=rpl
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Depends on: 1499363
Thank you for the test extension and STR. Validated the fix as per expected results from the description using the provided extension on: latest Nightly: 65.0a1 running on Windows 10 x64 and Nightly on Ubuntu 18.04.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: