Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
/ osx-browser-vm Public archive

Evaluate JavaScript in local OS X browsers

Notifications You must be signed in to change notification settings

jed/osx-browser-vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Evaluate JavaScript in local OS X browsers

Resources

Stars

Watchers

Forks

Packages

No packages published