Sha256: 10d69f0e3d5567e9524580c6e5b64413370de2f7f565ae662f235c562f27f70e
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 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 = system.stdin.read(); /* * 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; case 'env': return JSON.stringify(system.env); case 'argv': return JSON.stringify(system.args.slice(1)); default: console.error('Unknown callback data: ', data); } }; page.onError = function(msg, trace) { trace = (trace && trace.length) ? trace : []; var format_trace = function(trace) { var file = trace.file || trace.sourceURL, line = trace.line, method = trace['function']; method = method ? "`"+method+"'" : '~unknown~'; return file+': '+line+':in '+method; }; var msgStack = [format_trace(trace[0])+': '+msg]; trace.slice(1).forEach(function(t) { msgStack.push(" from "+format_trace(t)); }); system.stderr.write(msgStack.join('\n')+'\n'); phantom_exit(1); }; 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-0.11.0.rc1 | lib/opal/cli_runners/phantom.js |