Closed Bug 1722966 Opened 4 years ago Closed 4 years ago

Cannot install manifest v2 extension with host_permissions or action key in manifest file

Categories

(WebExtensions :: General, defect, P1)

defect

Tracking

(firefox-esr78 unaffected, firefox90 unaffected, firefox91+ verified, firefox92+ verified)

VERIFIED FIXED
92 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox90 --- unaffected
firefox91 + verified
firefox92 + verified

People

(Reporter: robwu, Assigned: zombie)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(3 files)

We've got a user report that this extension cannot be loaded on Nightly: https://addons.mozilla.org/en-US/firefox/addon/omnivore/

This extension has "manifest_version": 2, in manifest.json and the following keys:

  "permissions": [
    "activeTab",
    "storage",
    "scripting",
    "https://*/**",
    "http://*/**"
  ],
  "host_permissions": [
    "https://*/**",
    "http://*/**"
  ],

host_permissions is unsupported in Manifest v2. The desired behavior is to not reject installation of extensions that use manifest v3 properties, but to just ignore the key and print a warning in the console.

Console output upon trying to install the extension:

 1627577008271	addons.webextension.<unknown>	ERROR	Loading extension 'null': Reading manifest: Property "host_permissions" is unsupported in Manifest Version 2
    append resource://gre/modules/Log.jsm:723
    log resource://gre/modules/Log.jsm:379
    error resource://gre/modules/Log.jsm:387
    _logMessage resource://gre/modules/Extension.jsm:560
    logError resource://gre/modules/Extension.jsm:556
    packagingError resource://gre/modules/Extension.jsm:543
    manifestError resource://gre/modules/Extension.jsm:529
    parseManifest resource://gre/modules/Extension.jsm:1001
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
    (Async: async)
    loadManifest resource://gre/modules/Extension.jsm:1294
    loadManifestFromWebManifest resource://gre/modules/addons/XPIInstall.jsm:454
    loadManifest resource://gre/modules/addons/XPIInstall.jsm:657
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
    (Async: async)
    loadManifest resource://gre/modules/addons/XPIInstall.jsm:1542
    onStopRequest resource://gre/modules/addons/XPIInstall.jsm:2460

This also goes for "action" and maybe other v3 keys in v2 manifests.

On Beta, the warning is different, because host_permissions is not recognized on Beta. The extension can still not load because the extension (version 0.1.14) has the following manifest:

  "action": {
    "default_icon": {
      "16": "images/toolbar/icon-16.png",
      "19": "images/toolbar/icon-19.png",
      "24": "images/toolbar/icon-24.png",
      "32": "images/toolbar/icon-32.png",
      "38": "images/toolbar/icon-38.png"
    },
    "default_title": "Omnivore Save Article"
  },
addons.webextension.<unknown>	ERROR	Loading extension 'null': Reading manifest: Property "action" is unsupported in Manifest Version 2
    append resource://gre/modules/Log.jsm:723
    log resource://gre/modules/Log.jsm:379
    error resource://gre/modules/Log.jsm:387
    _logMessage resource://gre/modules/Extension.jsm:558
    logError resource://gre/modules/Extension.jsm:554
    packagingError resource://gre/modules/Extension.jsm:541
    manifestError resource://gre/modules/Extension.jsm:527
    parseManifest resource://gre/modules/Extension.jsm:995
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
    (Async: async)
    loadManifest resource://gre/modules/Extension.jsm:1286
    loadManifestFromWebManifest resource://gre/modules/addons/XPIInstall.jsm:454
    loadManifest resource://gre/modules/addons/XPIInstall.jsm:657
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
    (Async: async)
    loadManifest resource://gre/modules/addons/XPIInstall.jsm:1542
    onStopRequest resource://gre/modules/addons/XPIInstall.jsm:2460
Regressed by: 1706398
Summary: Cannot install manifest v2 extension with host_permissions key in manifest file → Cannot install manifest v2 extension with host_permissions or action key in manifest file
Has Regression Range: --- → yes

We'll want to upload the "action" one to beta, so I'll it as two patches.

Also, without major jumping through hoops, we'll not be able to have a test for "host_permissions" because of the test helper that just merges that key into "permissions" for manifest version 2.

Assignee: nobody → tomica
Severity: -- → S2
Priority: -- → P1

action is in beta, so this needs a fix and uplift. at least one addon on AMO has an action key.

Sorry for the repeat comment.

[Tracking Requested - why for this release]: Some existing extensions uploaded to/installed from AMO will stop working once users update to 91.

Comment on attachment 9233783 [details]
Bug 1722966 - Warn and ignore new MV3 keys in existing MV2 extensions

Beta/Release Uplift Approval Request

  • User impact if declined: some addons (70+) released on AMO fail to install
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Install https://addons.mozilla.org/en-US/firefox/addon/omnivore/

It currently fails to install on beta. With this patch landed, it will install.

  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Some addons have taken advantage of lax restrictions in our manifest handling and have included both manifest v2 and v3 keys. Till now we only warned on them. With some mv3 changes, we now throw an error, resulting in a failed install.

This change issues a console warning (rather than throwing an error) if an addon includes MV3 keys in its manifest, and strips those keys from the normalized manifest.

The change is minimal and has a test.

  • String changes made/needed: none
Attachment #9233783 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Pushed by tjovanovic@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cbf0b6867654 Warn and ignore new MV3 keys in existing MV2 extensions r=mixedpuppy,robwu

Tomislav and I took a look into why the xpcshell test is failing on Android but passes successfully on Android, and we identified that the different behavior is due to the different value set for the extensions.webextensions.warnings-as-errors pref on Desktop.

  • On Desktop, extensions.webextensions.warnings-as-errors is set to true (I think that the value set to true is coming from the user pref file here https://searchfox.org/mozilla-central/source/testing/profiles/xpcshell/user.js)
  • On Android (where it is set to false, which it may be due to not picking up that testing/profiles/xpcshell/user.js user prefs file, but I have to double-check if that is actually the case)

In my opinion, technically the android run is the one right, the test case is currently testing a test-only behavior instead of the behavior without that pref set as it was meant to do.

We will agree on how to update the patch to make the test to pass (and possibly test the behaviors that it is supposed to cover) and re-land the fix as soon as possible.

Flags: needinfo?(tomica)
Pushed by tjovanovic@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e2cba77bdbbc Warn and ignore new MV3 keys in existing MV2 extensions r=mixedpuppy,robwu,rpl
Blocks: 1723189
See Also: → 1723198

Added as a see also a link to the new addons-linter pull request that is meant to align the addons-linter behavior (and the validation on submissions to AMO):

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch

Hello,

Verified the fix on the latest Nightly (92.0a1/20210801214108) under Windows 10 x64 and Ubuntu 16.04 LTS.

The add-on can be properly installed from AMO (https://addons.mozilla.org/en-US/firefox/addon/omnivore/) and a warning is printed in the browser console, as per the desired behavior mentioned in the original description of the issue – see screenshot. No related errors are shown in the console either.

Status: RESOLVED → VERIFIED
Attached image 2021-08-02_09h39_54.png

Comment on attachment 9233783 [details]
Bug 1722966 - Warn and ignore new MV3 keys in existing MV2 extensions

approved for 91 rc1

Attachment #9233783 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Hello,

Verified the fix on the latest Beta (91.0/20210802144751) under Windows 10 x64 and Ubuntu 16.04 LTS.

The add-on can be properly installed from AMO (https://addons.mozilla.org/en-US/firefox/addon/omnivore/) and a warning is printed in the browser console, as per the desired behavior mentioned in the original description of the issue – see screenshot. No related errors are shown in the console either.

Flags: qe-verify+
Attached image 2021-08-03_09h11_22.png
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: