Skip to content

Commit

Permalink
fix(server): Update timers for limited execution environments
Browse files Browse the repository at this point in the history
In limited execution environments the setTimeout/clearTimeout functions
need to be delegated to, rather than stored as references, otherwise an
Illegal Invocation error is thrown by the runtime.

Closes #1519
  • Loading branch information
schmuli committed Jul 28, 2015
1 parent f60e194 commit 9cfc1cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/server.js
Expand Up @@ -3,6 +3,8 @@ var di = require('di')
var util = require('util')
var Promise = require('bluebird')

var root = global || window || this

var cfg = require('./config')
var logger = require('./logger')
var constant = require('./constants')
Expand Down Expand Up @@ -72,7 +74,10 @@ var Server = function (cliOptions, done) {
reporter: ['factory', reporter.createReporters],
capturedBrowsers: ['type', BrowserCollection],
args: ['value', {}],
timer: ['value', {setTimeout: setTimeout, clearTimeout: clearTimeout}]
timer: ['value', {
setTimeout: function () { return setTimeout.apply(root, arguments)},
clearTimeout: function (timeoutId) { clearTimeout(timeoutId)}
}]
}]

// Load the plugins
Expand Down

0 comments on commit 9cfc1cd

Please sign in to comment.