Closed Bug 1852249 Opened 2 years ago Closed 2 years ago

Permissions of APIs defined outside of toolkit are not listed in the Add-ons Manager

Categories

(Toolkit :: Add-ons Manager, defect, P3)

Firefox 115
defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox-esr115 --- fixed
firefox117 --- wontfix
firefox118 --- wontfix
firefox119 --- fixed
firefox120 --- fixed

People

(Reporter: TbSync, Assigned: TbSync)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

After moving locales to fluent in bug 1793557, the AddonPermissionsList CustomElement is locked onto the mozilla-central/toolkit locale definitions.

The "default" Localization object is defined here

ExtensionData.formatPermissionStrings is using it as a fallback here

The implementation of AddonPermissionsList is currently not using the localization member of the second parameter of formatPermissionStrings:

This causes Thunderbird to print "null" for its own permissions. I assume the android platform will suffer the same issue, if it uses custom android-only permissions.

The proposed patch causes AddonPermissionsList to use this.localization:

    let permissions = Extension.formatPermissionStrings(
      {
        permissions: requiredPerms,
        optionalPermissions: optionalPerms,
      },
      {
        buildOptionalOrigins: manifestV3enabled,
        localization: this.localization,
      }
    );

which allows Thunderbird to override the implementation:

  await customElements.whenDefined("addon-permissions-list");
  AddonPermissionsList.prototype.localization = l10n;

Is there an alternative approach?

Type: task → defect
Keywords: regression
Regressed by: 1793557
Assignee: nobody → john
Status: NEW → ASSIGNED

Set release status flags based on info from the regressing bug 1793557

Blocks: 1842490

The write-up below elaborates my thought process, and concludes with an alternative approach than proposed here.

The "new" implementation from bug 1793557 offers the ability to define custom permissions and/or permission warnings (for new or existing permission names):

The current implementation assumes all permission strings to be defined by the hardcoded list of files at https://searchfox.org/mozilla-central/rev/0afa5b067589195a45ed5e858b51a4ee30c8c0a7/toolkit/components/extensions/Extension.sys.mjs#79-84
Thunderbird however defines additional strings in messenger/extensionPermissions.ftl, e.g. for permission prompts whose Localization instance override is defined at https://searchfox.org/comm-central/rev/933a56297d54b40a9fab147e93eefe226e413f77/mail/modules/ExtensionsUI.jsm#42

The about:addons code goes through a different code path, and because of that, the default Localization instance without Thunderbird-specific strings is used. The proposed patch patches m-c code to forward a localization instance member to the formatPermissionStrings call (this.localization is undefined on m-c, but intended to be defined in Thunderbird as sketched in the initial report).

The intended way to extend the localizations was through ExtensionPermissionMessages.sys.mjs, with all permission strings defined in toolkit/locales/en-US/toolkit/global/extensionPermissions.ftl. Clearly, this doesn't work sufficiently because the list of ftl files cannot be overridden. I'm not very keen on introducing a seemingly unused instance member.

How about the following:

  • Remove the extensionPermissions.ftl reference from Extension.sys.mjs
  • Add a new lazy Localization instance in ExtensionPermissionMessages.sys.mjs, which constructs itself based on an exported array.
  • From Thunderbird, extend that array with the Thunderbird-specific ftl file, before the first access to any formatPermissionStrings` call.
Severity: -- → N/A
Type: task → defect
Priority: -- → P3
Attachment #9352214 - Attachment is obsolete: true
Attachment #9353859 - Attachment description: Bug 1852249 - Allow to override default list of permission fluent files. r=#extension-reviewers → Bug 1852249 - Use a central/exported permission Localization object, to allow builds to modify it. r=#extension-reviewers
Blocks: 1854074
Summary: Allow AddonPermissionsList CustomElement to override localization → Permissions of APIs defned outside of toolkit are not listed in the Add-ons Manager
Pushed by john@thunderbird.net: https://hg.mozilla.org/integration/autoland/rev/527e70e2625a Use a central/exported permission Localization object, to allow builds to modify it. r=extension-reviewers,robwu
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

Comment on attachment 9353859 [details]
Bug 1852249 - Use a central/exported permission Localization object, to allow builds to modify it. r=#extension-reviewers

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: The fluent migration done for 115 was not complete and other builds like Thunderbird fail to display permission strings. This was not caught in time.
  • User impact if declined: Thunderbird ESR115 will not be able to print permission strings.
    https://bug1842490.bmoattachments.org/attachment.cgi?id=9342957
  • Fix Landed on Version: 120
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): We added tests to verify the fix is working properly.
Attachment #9353859 - Flags: approval-mozilla-esr115?

The patch landed in nightly and beta is affected.
:TbSync, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox119 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(john)

Comment on attachment 9353859 [details]
Bug 1852249 - Use a central/exported permission Localization object, to allow builds to modify it. r=#extension-reviewers

Beta/Release Uplift Approval Request

  • User impact if declined: Other builds (for example Thunderbird) will not be able to print permission strings in the AOM permission tab.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): We added tests to verify the fix is working properly.
  • String changes made/needed:
  • Is Android affected?: Unknown
Flags: needinfo?(john)
Attachment #9353859 - Flags: approval-mozilla-beta?

Comment on attachment 9353859 [details]
Bug 1852249 - Use a central/exported permission Localization object, to allow builds to modify it. r=#extension-reviewers

Approved for 119.0b3

Attachment #9353859 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Summary: Permissions of APIs defned outside of toolkit are not listed in the Add-ons Manager → Permissions of APIs defined outside of toolkit are not listed in the Add-ons Manager

Comment on attachment 9353859 [details]
Bug 1852249 - Use a central/exported permission Localization object, to allow builds to modify it. r=#extension-reviewers

Approved for 115.4esr. Thanks for including a test.

Attachment #9353859 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: