Deprecate the eval forms of setTimeout and setInterval
This commit is contained in:
@@ -3521,6 +3521,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
// setTimeout("some code") and setInterval("some code") are legal, if
|
// setTimeout("some code") and setInterval("some code") are legal, if
|
||||||
// not recommended. We don't do that ourselves, but user code might.
|
// not recommended. We don't do that ourselves, but user code might.
|
||||||
// This allows such code to work when the mock clock is installed.
|
// This allows such code to work when the mock clock is installed.
|
||||||
|
j$.getEnv().deprecated(
|
||||||
|
"The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string."
|
||||||
|
);
|
||||||
f = function() {
|
f = function() {
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
return eval(funcToCall);
|
return eval(funcToCall);
|
||||||
|
|||||||
@@ -15,8 +15,14 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
it('schedules a string for later execution', function() {
|
it('schedules a string for later execution', function() {
|
||||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
strfn = 'horrible = true;';
|
strfn = 'horrible = true;';
|
||||||
|
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||||
|
|
||||||
scheduler.scheduleFunction(strfn, 0);
|
scheduler.scheduleFunction(strfn, 0);
|
||||||
|
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
|
||||||
|
'The eval form of setTimeout and setInterval is deprecated and will ' +
|
||||||
|
"stop working in a future version of Jasmine's mock clock. Pass a " +
|
||||||
|
'function instead of a string.'
|
||||||
|
);
|
||||||
|
|
||||||
scheduler.tick(0);
|
scheduler.tick(0);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
// setTimeout("some code") and setInterval("some code") are legal, if
|
// setTimeout("some code") and setInterval("some code") are legal, if
|
||||||
// not recommended. We don't do that ourselves, but user code might.
|
// not recommended. We don't do that ourselves, but user code might.
|
||||||
// This allows such code to work when the mock clock is installed.
|
// This allows such code to work when the mock clock is installed.
|
||||||
|
j$.getEnv().deprecated(
|
||||||
|
"The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string."
|
||||||
|
);
|
||||||
f = function() {
|
f = function() {
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
return eval(funcToCall);
|
return eval(funcToCall);
|
||||||
|
|||||||
Reference in New Issue
Block a user