Sha256: 239d976460786fe31541a298700fee8b1d6204abdbc094320bbd017f1c1d1f09

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

/*
 * Test runner for phantomjs
 */
var system = require('system');
var args = phantom.args ? phantom.args : system.args.slice(1);
var page = require('webpage').create();
var url  = args[0];


/*
 * 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.onConsoleMessage = function(msg) {
  console.log(msg);
};

page.onInitialized = function() {
  page.evaluate(function () {
    window.OPAL_SPEC_PHANTOM = true;
  });
};

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.open(url, function(status) {
  if (status !== 'success') {
    console.error("Cannot load: " + url);
    phantom_exit(1);
  }
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-0.9.4 tasks/testing/sprockets-phantomjs.js
opal-0.9.3 tasks/testing/sprockets-phantomjs.js
opal-0.9.2 tasks/testing/sprockets-phantomjs.js
opal-0.9.0 tasks/testing/sprockets-phantomjs.js
opal-0.9.0.rc1 tasks/testing/sprockets-phantomjs.js