Can I test cross-browser javascript via the command line? - javascript

Firefox has the JSShell for SpiderMonkey. Do the other major browsers Chrome and Safari have a command-line interface to their javascript engines? If so, this would be a great lightweight way to test javascript to ensure that it runs cross-browser without having to open a full browser.

Related

Node.js web browser with JavaScript execution

Is there a node / npm module which would scrape the contents of a web page or a given URL and execute and evaluate it's JavaScript as a real-life web browser, including XMLHttpRequest object and alike?
I thought that scraperjs was the solution, but sadly it isn't.
All help very appreciated!
Headless browsers based on rendering engine:
Chrome (blink) => Playwright or Puppeteer
Firefox (gecko) => Playwright
Safari (webkit) => Playwright
Puppeteer is the official automation tool for Chrome. It only supports Chrome/Chromium browsers, (with experimental support for Firefox).
Playwright is an alternative to Puppeteer, with support for more browsers, written by the original creators of puppeteer, who jumped ship from Google to Microsoft. It supports Chrome, Firefox and Safari browsers
Previous versions of my answer, included PhantomJS, SlimerJS,CasperJS and Nightmare all of which are no longer maintaned. For modern browsers, just use one of the above

Headless browser for FireFox (similar to PhantomJS for Chrome)

Is there a headless browser for FireFox (similar to PhantomJS for Chrome), that can be used with Karma?
Using the Grunt FireFox Launcher plugin causes, the browser to be launched every single time we build our JavaScript using GRUNT. We would like something which is more silent and redirects its output to the console window. Very similar to how PhantomJS works for Chrome. Any ideas?
First and foremost: Phantomjs does not launch Chrome. Phantomjs is a javascript implementation of Webkit.
Now, if you want to run firefox headlessly you can run it inside XVFB. Without knowing anything about your build since you haven't included that, I'll just link to node xvfb which is probably a good place to get started: https://github.com/proxv/node-xvfb
PhantomJS runs webkit not Chrome. It is the same engine but Chrome adds quite a bit more (ie Intl support). There is no equivalent for Gecko -- the equivalent of webkit for Firefox. On Linux or OS X, you can use xvfb with Firefox to stop the window from popping up.

Changing the JavaScript engine in side a web browser

It is possible to change the JavaScript engine being used inside a Web Browser?
Some additional information:
For testing mobile applications, I would like to be able to emulate the exact JavaScript engine being used by a web browser to find bugs.
If there anyway to change the javascript engine being used in a Browser such as Chrome or would I need to build my own browser?
This is an interesting feature. I'd like to test Safari Javascriptcore engine in Chrome browser instead of V8. Because I noticed that some of my angular code is not rendered correcty on JavascriptCore engine and rendered correctly on other browsers. It'll be in handy when you found some bugs on ios devices and you have no mac device nearby.
UPD
I found browsers where you can change browser engine lunascape and avant. these browsers are triple engine browsers and you can switch between engines.
There are a number of open source browsers. It is theoretically possible to replace the JavaScript engines they use and compile your own executable. Indeed a number of browsers have changed engines during their history.
You'll probably need to make changes to the API to make them compatible though.
There's no way to do this from JavaScript, of course.
Generally, a given browser ships with a single JavaScript engine. There is no need to ship with multiple engines, because if additional features are required of the engine, they'll simply be added to the engine which the browser ships with.
I could potentially see the existence of a modular web browser which requires plugging in a JS engine separate from the main program (which could then result in the user having multiple JS engines on their machine), but I know of no such browser, and thus know of no means by which JS could be used to swap the engine.
I suppose you could implement EMCAScript in JavaScript, but that seems like a tremendous hassle.
In response to the edits to your question: I believe Chrome Dev Tools' mobile emulation will get you what you want instead of what you've asked for.

javascript engine before nitro (in Mobile Safari)

Lots of articles deal with the "new" js engine nitro on iOS.
For developing and comfortable testing for older iOS devices, I would like to install an outdated browser on windows or ubuntu which is using the same js interpreter?
It's so sad that the js interpreter or js engine differs so much, even with parsing scripts.
To find the right WebKit port, I have to know the name of the "old" js engine. Where to find it?
Thanks
In the case of the pastebin example, there is a syntax error because class is a reserved word and can not be written (with strict js settings like on the old ios webkit).
Use .className instead!
To test with different JavaScript engines and browsers I would recommend using the genius Browserstack. It offers emulators for iOS 3.2 to 6.0 for either the iPhone or iPad. With a comprehensive unit testing suite for your app it should be easy to find engine specific errors.

Does Google Dart JavaScript converter support older browsers?

Does the Google Dart JavaScript converter support older browsers or is it only supporting modern browsers?
According to technical overview of its official site :
You will be able to run Dart code in several ways:
1.Translate Dart code to JavaScript that can run in any modern browser: Chrome, Safari 5+, and Firefox 4+ (more browser support coming shortly).
2.Execute Dart code directly in a VM on the server side
3.Use Dartboard to write, modify, and execute small Dart programs within any browser window
There is little chance that the Dart -> JavaScript compiler will support older browsers.
It's supported in no browsers currently. However code in dart can be compiled to JavaScript.

Categories

Resources