laurentj / slimerjs

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

SlimerJS not compatible with Firefox 63 #708

Open kaosko opened 5 years ago

kaosko commented 5 years ago

versions

Steps to reproduce the issue

Try to set a viewportSize on a webpage with slimer.js: page.viewportSize = { width : width, height : height };

Actual results:

JavaScript error: resource://gre/modules/ActorManagerChild.jsm, line 192: TypeError: singletons is null

Script Error: Stack: -> resource://slimerjs/slimer-sdk/webpage.js: 998 (in function set viewportSize) -> file:///mnt/raid1/personal/slimerjs/src/custom_renderwebpage.js: 80 (in function renderUrl)

Expected results:

Able to set the viewportSize.

Firefox 63 removed XPCOMUtils.generateQI but you can just replace that with ChromeUtils.generateQI (ChromeUtils doesn't need to be imported). Once that's done, the remaining issue "singletons is null". Apparently ActorManagerParent seems to be loaded/initialized somehow, these issues seem related: https://bugzilla.mozilla.org/show_bug.cgi?id=1485649 https://bugzilla.mozilla.org/show_bug.cgi?id=1499896

kaosko commented 5 years ago

I don't see how you could monkeypatch ActorManagerChild (see the second issue) because the error happens as soon as you try to import it Cu.import("resource://gre/modules/ActorManagerChild.jsm");

MarkR42 commented 5 years ago

I created a new branch, https://github.com/MarkR42/slimerjs/tree/firefox63

I think the viewportSize works on this build; many unit tests still fail but at least basic functionality is working (load pages, screenshot etc). Most of the event-based tests are failing though

MarkR42 commented 5 years ago

As of Firefox 66.0, some more functionality has been removed from Firefox which makes the JS xpcom module work. This means that essentially, all of SlimerJS functionality is incompatible with 66.0 and will probably be forever, unless we can work out some way of making it all work without the deprecated / removed interfaces.

mikeperalta1 commented 4 years ago

Any update on this issue, or suggestions for drop-in replacements for SlimerJs?

MarkR42 commented 4 years ago

No.

Firefox has done a fundamental redesign which makes SlimerJS impossible / difficult to continue. SlimerJS would need to hook into Firefox at a much lower level than it currently does, which would probably need a special build of Firefox. Although that is theoretically feasible, it would make it much more sensitive to future architectural changes.

PhantomJS also failed due to the difficulty of keeping up with Webkit changes (and the maintainer quit), PhantomJS is in C++ and those interfaces were changed often.

I think your best bet is to use Webdriver from Selenium, that's also cross-browser. If you can do what you want with Webdriver, great.

Otherwise, write a Firefox extension and load that, the API is totally different and intended for different purposes. Some things, such as getting data from the DOM or injecting scripts, are really different. Firefox web-extensions have many limitations e.g. they can't access native files or other low-level APIs, that's by design too.

mikeperalta1 commented 4 years ago

Hrm okay thanks. I think maybe I'll start learning to adapt some of my code over to webdriver or headless chrome or something, eventually.

kaosko commented 4 years ago

Slimer.js still works great for what it does, it's just that you can't use FF newer than 62 with it. If you are using Debian/Ubuntu, you can easily get Firefox 60 ESR from the PPA repos.

mikeperalta1 commented 4 years ago

Thank you, yes. I currently have a fully functional SlimerJs project but I'm just bummed I may eventually have to migrate away from it. It was my first choice after PhantomJs died.

kensoh commented 4 years ago

Hi @MarkR42 PhantomJS creator recently got back into action and it looks like his initial focus is Linux, with macOS and Windows as second priorities - https://github.com/ariya/phantomjs/issues

kensoh commented 4 years ago

Also copying @laurentj for info -

mwbelt commented 4 years ago

@kensoh , did you see any remarks from the PhantomJS creator that said he was back in action? I didn't find any comments from him in a cursory review of the issues, but I may have missed something.