How do I install WebExtension that developed by myself to Firefox Nightly?
Asked Answered
S

3

9

I already know the way to temporarily install an add-on for debugging. However, I want to install it persistently. I do not want to upload it to AMO, because I've developed it for use by myself only.

How do I install it on Firefox Nightly?

Browser: Firefox Nightly 56a1
OS: macOS 10.12.5

Edit

I attempted Andrew's way while referring to Getting started with firefox-addon, but an error occurred (This add-on could not be installed because it appears to be corrupt.), despite that temporary installation was successful.
Why did installation fail only when installing it from Install Add-on from File...?

Source code is here https://github.com/KiYugadgeter/webext

Edit2:

The following is Error message on browser console.

1497764354857   addons.xpi  WARN    Invalid XPI: Error: Cannot find id for 

addon /
Users/username/jsworks/webextensions/stacknotifier/something.xpi (resource://gre/modules/addons/XPIInstall.jsm:1642:17) JS Stack trace: [email protected]:1642:17 <
async*[email protected]:2122:13 < async*[email protected]:4820:12 < [email protected]:3437:5 < [email protected]:297:12 <
promiseCallProvider/<@AddonManager.jsm:321:53 < [email protected]:390:5 <
[email protected]:320:10 < getInstallForFile/<@AddonManager.jsm:1856:29
< async*[email protected]:1854:13 < [email protected]:
3560:7 < doCommand/<@extensions.js:1472:13

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.hostPort]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://gre/modules/PopupNotifications.jsm :: PopupNotifications_refreshPanel/< :: line 806"  data: no]
Sandrocottus answered 14/6, 2017 at 6:56 Comment(2)
See: Installing add-ons for development in documentation.Emory
The quoted error is "Cannot find id for addon" - do you have one set in the manifest?Psychologist
P
9

Your error is: Invalid XPI: Error: Cannot find id for addon

Quoting WebExtension documentation:

When do you need an Add-on ID?

  • If you are loading the add-on from it's XPI file, are not loading it temporarily using about:debugging and it is not signed.
  • ...

This is your situation; as such, you need to fill out the applications.gecko.id key in the manifest. This plays the similar role as setting key key in Chrome (in Chrome, the ID of a packed extension is a hash of the key field).

Alternatively (and possibly preferably), you can sign your XPI as indicated by Forivin's answer, because loading unsigned WebExtensions is only possible in Nightly. That would require interaction with AMO - but there's no requirement to host there.

Psychologist answered 19/6, 2017 at 11:43 Comment(0)
T
10

Recent versions of Firefox require you to sign the extension before you can permanently install it. To get your extension signed you don't have to publish it. All you need is a tool called web-ext. Then you can simply run this from your terminal:

web-ext sign --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRET

Getting started with web-ext:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext

web-ext sign:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/web-ext_command_reference#web-ext_sign

Getting your AMO_JWT_ISSUER and AMO_JWT_SECRET:
https://addons.mozilla.org/en-US/developers/addon/api/key/

In short:

  • Downlaod and Install NodeJS
  • Open a new terminal and run npm install --global web-ext
  • Go to api key site and get your AMO_JWT_ISSUER and AMO_JWT_SECRET
  • Open a new terminal, go into the folder which contains your extension sources and run

    web-ext sign --api-key=xxxx:xxxxxxx:xxx --api-secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
Toilsome answered 14/6, 2017 at 11:18 Comment(0)
P
9

Your error is: Invalid XPI: Error: Cannot find id for addon

Quoting WebExtension documentation:

When do you need an Add-on ID?

  • If you are loading the add-on from it's XPI file, are not loading it temporarily using about:debugging and it is not signed.
  • ...

This is your situation; as such, you need to fill out the applications.gecko.id key in the manifest. This plays the similar role as setting key key in Chrome (in Chrome, the ID of a packed extension is a hash of the key field).

Alternatively (and possibly preferably), you can sign your XPI as indicated by Forivin's answer, because loading unsigned WebExtensions is only possible in Nightly. That would require interaction with AMO - but there's no requirement to host there.

Psychologist answered 19/6, 2017 at 11:43 Comment(0)
C
2

Since you said you're using Nightly, you can also go to about:config, find the preference "xpinstall.signatures.required" and flip it to false. Then you should be able to install your extension from about:addons -> "Install Add-on from File..."

Celiotomy answered 14/6, 2017 at 16:32 Comment(4)
I tried this way but it occured a error (This add-on could not be installed because it appears to be corrupt.)despite temporary installation be successful.Sandrocottus
Did you generate the xpi with web-ext or manually? Is there anything in the browser console (not the regular web console)?Celiotomy
@Sandrocottus Does it even work if you install it from about:debugging? To me this sound like your addon is actually corrupt.Toilsome
my extension works when it installed from about:debugging. (about:debugging use for only temporary installation)Sandrocottus

© 2022 - 2024 — McMap. All rights reserved.