All Projects → jed → osx-browser-vm

jed / osx-browser-vm

Licence: other
Evaluate JavaScript in local OS X browsers

Programming Languages

javascript
184084 projects - #8 most used programming language

os-browser-vm

This library lets you evaluate arbitary JavaScript on the browsers installed on your local OS X machine, through Node.js. It currently supports Safari, Google Chrome, and Google Chrome Canary (Firefox support is apparently not possible). It works thanks to support for JavaScript automation in modern releases of OS X, and is similar to the Node.js vm module.

API

This library exports three properties: safari, chrome, and canary.

{safari|chrome|canary}.run(code, callback)

code is the JavaScript string to be evaluated. The result of the last expression in this string is passed to the callback in the usual Node.js (err, data) signature.

A function can also be passed for code, in which case it is stringified as an IIFE.

Example

import {safari, chrome, canary} from 'osx-browser-vm'

var vms = [safari, chrome, canary]
var code = 'Object.getOwnPropertyNames(window).length'

console.log("Number of properties on window:")

vms.forEach(vm => {
  vm.run(code, (err, count) => {
    console.log("- %s: %s", vm.name, count)
  })
})

// Number of properties on window:
// - Google Chrome Canary: 694
// - Google Chrome: 682
// - Safari: 607
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].