Sha256: 341d89868901bedbc124dccb39fc2763f240518bacade60a72319c723547cd6f

Contents?: true

Size: 1.02 KB

Versions: 17

Compression:

Stored size: 1.02 KB

Contents

var log = require('../logger').create('launcher');

/**
 * Kill browser if it does not capture in given `captureTimeout`.
 */
var CaptureTimeoutLauncher = function(timer, captureTimeout) {
  if (!captureTimeout) {
    return;
  }

  var self = this;
  var pendingTimeoutId = null;

  this.on('start', function() {
    pendingTimeoutId = timer.setTimeout(function() {
      pendingTimeoutId = null;
      if (self.state !== self.STATE_BEING_CAPTURED) {
        return;
      }

      log.warn('%s have not captured in %d ms, killing.', self.name, captureTimeout);
      self.error = 'timeout';
      self.kill();
    }, captureTimeout);
  });

  this.on('done', function() {
    if (pendingTimeoutId) {
      timer.clearTimeout(pendingTimeoutId);
      pendingTimeoutId = null;
    }
  });
};


CaptureTimeoutLauncher.decoratorFactory = function(timer,
    /* config.captureTimeout */ captureTimeout) {
  return function(launcher) {
    CaptureTimeoutLauncher.call(launcher, timer, captureTimeout);
  };
};

module.exports = CaptureTimeoutLauncher;

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.4.1 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.4.0 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.3.0 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.2.1 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.2.0 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.1.0 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.0.8 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.0.7 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
hooch-0.0.6 jasmine/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/lib/launchers/capture_timeout.js