Sha256: d1f543553231d14b0f27c30a6711945ff22e1ed2499291584dadc22938969117
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
var page = require('webpage').create(); var fs = require('fs'); var system = require('system'); page.onConsoleMessage = function(msg) { system.stdout.write(msg); }; var opal_code = fs.read('/dev/stdin'); /* * Exit phantom instance "safely" see - https://github.com/ariya/phantomjs/issues/12697 * https://github.com/nobuoka/gulp-qunit/commit/d242aff9b79de7543d956e294b2ee36eda4bac6c */ function phantom_exit(code) { page.close(); setTimeout(function () { phantom.exit(code); }, 0); } page.onCallback = function(data) { switch (data[0]) { case 'exit': var status = data[1] || 0; phantom_exit(status); case 'stdout': system.stdout.write(data[1] || ''); break; case 'stderr': system.stderr.write(data[1] || ''); break; default: console.error('Unknown callback data: ', data); } }; page.onInitialized = function() { page.evaluate('function(code) {window.eval(code)}', opal_code) }; page.setContent("<!doctype html>\n"+ "<html>"+ "<head><meta charset='utf-8'/></head><body>"+ "</body></html>", 'http://www.example.com');
Version data entries
5 entries across 5 versions & 1 rubygems