diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 6939bd8f..67e5424f 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3224,6 +3224,9 @@ getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { return CompleteOnFirstErrorSkipPolicy; }; +// Warning: don't add "use strict" to this file. Doing so potentially changes +// the behavior of user code that does things like setTimeout("var x = 1;") +// while the mock clock is installed. getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { function DelayedFunctionScheduler() { this.scheduledLookup_ = []; @@ -3249,6 +3252,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { ) { let f; if (typeof funcToCall === 'string') { + // setTimeout("some code") and setInterval("some code") are legal, if + // not recommended. We don't do that ourselves, but user code might. + // This allows such code to work when the mock clock is installed. f = function() { // eslint-disable-next-line no-eval return eval(funcToCall); diff --git a/src/core/DelayedFunctionScheduler.js b/src/core/DelayedFunctionScheduler.js index ef2c2f4f..9ea6c5f3 100644 --- a/src/core/DelayedFunctionScheduler.js +++ b/src/core/DelayedFunctionScheduler.js @@ -1,3 +1,6 @@ +// Warning: don't add "use strict" to this file. Doing so potentially changes +// the behavior of user code that does things like setTimeout("var x = 1;") +// while the mock clock is installed. getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { function DelayedFunctionScheduler() { this.scheduledLookup_ = []; @@ -23,6 +26,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { ) { let f; if (typeof funcToCall === 'string') { + // setTimeout("some code") and setInterval("some code") are legal, if + // not recommended. We don't do that ourselves, but user code might. + // This allows such code to work when the mock clock is installed. f = function() { // eslint-disable-next-line no-eval return eval(funcToCall);