laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 259 forks source link

Running slimerjs with Add-on (extension) #401

Open rwrnet opened 8 years ago

rwrnet commented 8 years ago

I'm desperately trying to run slimerjs with an activated extension. According to http://docs.slimerjs.org/current/installation.html#creating-extensions its not impossible, so I wonder, what I'm doing wrong.

I tried:

The Add-on I'm trying to load is https://addons.mozilla.org/en-US/firefox/addon/firehbbtv/.

laurentj commented 8 years ago

You should understand that SlimerJS may not be able to run Firefox's extensions. Probably the documentation is not clear : I did not write that you can install Firefox extensions into SlimerJS. I wrote that you can create and install extensions made with the same technologies as Firefox extensions.

The extension will not load into SlimerJS if it is not an extension made for SlimerJS. The install.rdf file of the extension should list Slimerjs (slimerjs@slimerjs.org) or the gecko toolkit (toolkit@mozilla.org) as a target application.

Probably there are also some preferences to set to disable some restrictions (for instance xpinstall.signatures.required to false on latest firefoxes).

Note also, in the case of an extension made for firefox (like firehbbtv), all the UI content of the extension (buttons etc) will not be shown in the UI, as XUL overlays of the extension are declared for the browser.xul of Firefox, and don't match UI elements of slimerjs.xul.

And because XUL overlays of such extensions are not loaded, initializations made by some javascript files declared in the overlays are not done, so the core of the extension may not work at all.

laurentj commented 8 years ago

A thing that it is missing in application.ini of SlimerJS, is

[XRE]
EnableExtensionManager=1

I think it should help...

rwrnet commented 8 years ago

Excellent. Thanks a lot Laurent, that gave me a very good direction:

Now I see System JS : ERROR file:...hbbtv-streamconverter.js:44 - TypeError: scope is null, means extension is loading now and I can finally start looking into adopting it to slimer. How great. :)

I'm now looking into building a docker receipt which sets environment properly. Let me know, whether the result might be interesting for the documentation or how I could bring a little support to the project otherwise.

laurentj commented 8 years ago

Thank you for the feedback.

I'm interesting by your project based on docker. We could reference it on the web site or the documentation.

If you have time, you could help me to improve the documentation on how to install extensions (see docs/ or website/ in the repository)

rwrnet commented 8 years ago

Progressing slowly. So far, the following steps are required:

I solved some bugs in firehbbtv, e.g. related to loading extension with developer shortcut, but now I stuck with an issue, that doesn't seem to be related purely to firehbbtv extension.

Fuel API doesn't seem to be availabe with slimerjs:

Components.classes['@mozilla.org/fuel/application;1'] is undefined

and it doesn't help to run it with a firefox launcher:

export SLIMERJSLAUNCHER=.../Firefox39.app/Contents/MacOS/firefox

I understand that Fuel is dedicated to Firefox, as Thunderbird uses Steel and Seamonkey uses Smile for the same purpose. So I wonder, whether this extIApplication Interface is available in slimerjs at all.

laurentj commented 8 years ago

No, it is not available since it is a part of Firefox package (browser/omni.ja), not Gecko package (omni.ja).