Closed Bug 1377510 Opened 7 years ago Closed 7 years ago

Add the ability to install extensions using the WebExtension API via mozprofile

Categories

(Testing :: Mozbase, enhancement)

Version 3
enhancement
Not set
normal

Tracking

(firefox56 fixed)

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: tarek, Assigned: tarek)

References

Details

Attachments

(1 file, 3 obsolete files)

Currently, Mozprofile will let you install addons but won't work with web extensions because it will look for an 'install.rdf' file in the xpi.

We should extend the API so it can install web extensions as well.

I'll dig into this by looking how marionette does it, but happy to get extra guidance :)
(In reply to Tarek Ziadé (:tarek) from comment #0)

> I'll dig into this by looking how marionette does it, but happy to
> get extra guidance :)

The remote protocol (Marionette) has an addon service that exposes
two commands for installing and uninstalling addons:

  Addon:Install
    Takes a JSON Object with |path| (string) and |temporary|
    (optional boolean) fields, which tells it where to find the full
    path to the .xpi file and whether the addon should be installed
    temporarily (cleaned when the Firefox session ends).

    Returns the string ID of the installed addon.

  Addon:Uninstall
    Takes a JSON Object with |id| (string) that identifies the addon
    to be uninstalled.

The code we use to do this is located in
https://searchfox.org/mozilla-central/source/testing/marionette/addon.js
and is run in chrome space.

It uses the AddonManager.jsm module which you can find in
https://searchfox.org/mozilla-central/source/toolkit/mozapps/extensions/AddonManager.jsm.

Please let me know if there is anything specific you’re looking
for.  I don’t know mozprofile intimately, but I can help out with
the remote protocol.
Andreas, this bug is about mozprofile and not marionette. Anything left for Marionette (like installing from a remote URL) should be handled on a different bug.

I discussed this problem with Tarek during the workweek, and as such the bug has been filed.
(In reply to Henrik Skupin (:whimboo) [partly available 07/10 -07/14] from comment #2)
> Andreas, this bug is about mozprofile and not marionette. Anything left for
> Marionette (like installing from a remote URL) should be handled on a
> different bug.

I know this is about mozprofile, but Tarek asked about pointers to how
Marionette deals with addon installation in comment #0.
Thanks for the pointers Andreas! I am back from leave today and will be working on this this week
Attached patch savepoint.patch (obsolete) — Splinter Review
This is a first attempt at adding a feature. It works but not a final version by all means.

One question:

- do we want to implement the feature as a special case in the existing code like I started to do, or treat webextension separately from add ons ? 

Stuff I am digging into:

- the web extension id is optional, the addon-id is mandatory. I have added that id for the test, but I am not sure what should be the proper install behavior when there's no id in the webextensions. 
- not sure how to treat unpack as well  
- signature verification 

If you think of other things let me know!
Flags: needinfo?(hskupin)
Digs:

1/ for the id, I am thinking about duplicating the behavior found in generateTemporaryInstallID() at https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/internal/XPIInstall.jsm#757-769

2/ unpack is false for webextensions - https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/internal/XPIInstall.jsm#358
Attached patch savepoint.patch (obsolete) — Splinter Review
Attachment #8889344 - Attachment is obsolete: true
Attached patch savepoint.patch (obsolete) — Splinter Review
Attachment #8889456 - Attachment is obsolete: true
Attachment #8889460 - Attachment is obsolete: true
Comment on attachment 8889566 [details]
Bug 1377510 - Add the ability to install webextensions with mozprofile

https://reviewboard.mozilla.org/r/160580/#review166262
Attachment #8889566 - Flags: review?(dburns) → review+
Blocks: 1384137
Moved the needinfo to Andrew. I guess the patch I have on reviewboard is good enough to make it work for webextensions, but maybe that's not the way you would like to see this feature added? let me know
Flags: needinfo?(hskupin) → needinfo?(ahalberstadt)
If that's all it takes, I think your patch is good enough!

Mozprofile has been in maintenance mode for many years now, you'll probably have trouble finding anyone who cares overly much about its architecture. As long as it doesn't break anything and isn't horrible is usually good enough for me.
Flags: needinfo?(ahalberstadt)
Pushed by tziade@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7b98f21c8b79
Add the ability to install webextensions with mozprofile r=automatedtester
https://hg.mozilla.org/mozilla-central/rev/7b98f21c8b79
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Sorry for the late reply but I was on PTO all last week...

(In reply to Tarek Ziadé (:tarek) from comment #5)
> - do we want to implement the feature as a special case in the existing code
> like I started to do, or treat webextension separately from add ons ? 

Extensions using the Webextension API are add-ons which are the ones which we ONLY support from Firefox 57 onward. It means legacy extensions are no longer supported, and as such the code path to install those should have as best gotten the `else` part in your patch. But it's vise versa right now. It's nothing we have to change now, but once we remove the old code it means a bit more changes.

> - the web extension id is optional, the addon-id is mandatory. I have added
> that id for the test, but I am not sure what should be the proper install
> behavior when there's no id in the webextensions. 
> - not sure how to treat unpack as well  
> - signature verification 

If there is no ID specified the extension can only be installed temporarily, but not permanently. If that is a need we would still have to add this, right?
Flags: needinfo?(tarek)
Summary: Add the ability to install webextensions in mozprofile → Add the ability to install extensions using the WebExtension API via mozprofile
Flags: needinfo?(tarek)
You need to log in before you can comment on or make changes to this bug.