简体   繁体   中英

Bootstrapped extension with new jpm Firefox

I'm realizing a Firefox extension using one of the last (or the last) version of jpm (1.0.5) but the extension does not call the startup() or shutdown() methods. I know that should be mandatory to declare the extension as

<em:bootstrap>true</em:bootstrap>

into the install.rdf file, but when I have created my namespace (using jpm init) there was not this file, that it is replaced from package.json. In this case how I should modify the files to use startup and shutdown methods working?

What type of add-on do you have?

Sounds like an XUL/Overlay add-on using the legacy API. If that is the case, then you must create your own bootstrap.js file. Have you gone through all the steps to convert an overlay extension to restartless ?

jpm init will create the bootstrap code only when using the Addons-SDK. I'm not sure of any benefit to using jpm unless you are creating an add-on using the new Addons-SDK API, except perhaps the ability to package and submit the add-on to AMO from the command line. The debugging/validation checks of jpm just don't seem to catch many problems, almost none in XUL/Overlay API based add-ons.

Perhaps you have looked here already? Bootstrapped extensions , which links to a documented skeleton bootstrap.js .

Note, though, that in the chrome.manifest , the overlay instruction is not supported in bootstrapped extensions.

These and other topics are also covered in the "convert" document, referenced above.

In my main.js I listen for load and unload like this.

exports.main = function(options, callbacks) {
    if (options.loadReason == "install" || options.loadReason == "startup") {
        factory = new Factory(AboutDualView);
        factory = new Factory(AboutEPFViewer);
        registerRemotePages();
    }
}

exports.onUnload = function (reason) {
    if (reason == "shutdown") {
        factory.unregister();
        RemotePageManager.removeRemotePageListener("about:dualview");
        RemotePageManager.removeRemotePageListener("about:epfviewer");
    }
};

function registerRemotePages(){
    let DualViewmanager = new RemotePages("about:dualview");
    let EPFViewmanager = new RemotePages("about:epfviewer");
}

Reference https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/SDK/Tutorials/Listening_for_load_and_unload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM