From 9cfc1cd3411036ba314cdbb2b9f85ff804768e70 Mon Sep 17 00:00:00 2001 From: Schmulik Raskin Date: Tue, 28 Jul 2015 12:05:52 +0300 Subject: [PATCH] fix(server): Update timers for limited execution environments 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 --- lib/server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index cce0127ab..35e7b38fb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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') @@ -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