Вопрос

I'm building an extension using trigger.io's opensourced browser extension framework called forge. You can check out the documentation here. The docs are pretty good and everything seems to be working great with the exception of Firefox: I can't seem to be able to get a background.js script to behave how it should (which is like it how it behaves in Chrome)

The newly created forge project includes an src directory which in turn contains a config.json which is meant to mimic Chrome's manifest v2. There, one can include background scripts and content scripts (which are actually referred to as "Activations").

I've surmised that the Firefox builder uses the this addon-sdk (Jetpack?). Unlike IE and Chrome, Firefox builder ditches the background.js page, and doesn't seem to use the forge.html page at all, even though it is present in the extension code. alert() placed in the background.js included in config.json doesn't seem to do work.

Why is the background script ignored? How do I create a background script to use with Jetpack so I can access forge's APIs in order to set up messaging and such?

There's too many files to include here so I've uploaded the development folder with the .xpi file.

Это было полезно?

Решение

A quick investigation revealed the following

  • Forge background scripts on Firefox are implemented as PageWorker scripts. PageWorker scripts run on a hidden page. A consequence of this detail is that alert() fails.

  • The alert call fails with an error message (quite cryptic for a beginner)

  • At this point you might want to check the Browser Console. If you don't see a message complaining about not being able to call openModalWindow on a hidden window, you probably have not set the logging level.

So, your background script runs just fine. It's the framework that doesn't deliver on its cross-browser promise.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top