From dd8d3f9788d24745a2bcdd3f9d2f42a84dc58bd6 Mon Sep 17 00:00:00 2001 From: "Davis W. Frank" Date: Sat, 20 Apr 2013 08:27:38 -0700 Subject: [PATCH] Fix [#48420035] --- lib/jasmine-core/jasmine.js | 8 ++++---- spec/core/ClockSpec.js | 20 ++++++++++++++++++++ src/core/Clock.js | 8 ++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index d78d003a..7b65c622 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -896,7 +896,7 @@ jasmine.Clock = function(global, delayedFunctionScheduler) { } return timer.setTimeout(fn, delay); } - return timer.setTimeout.apply(null, arguments); + return timer.setTimeout.apply(global, arguments); }; self.setInterval = function(fn, delay, params) { @@ -906,15 +906,15 @@ jasmine.Clock = function(global, delayedFunctionScheduler) { } return timer.setInterval(fn, delay); } - return timer.setInterval.apply(null, arguments); + return timer.setInterval.apply(global, arguments); }; self.clearTimeout = function(id) { - return timer.clearTimeout(id); + return timer.clearTimeout.call(global, id); }; self.clearInterval = function(id) { - return timer.clearInterval(id); + return timer.clearInterval.call(global, id); }; self.tick = function(millis) { diff --git a/spec/core/ClockSpec.js b/spec/core/ClockSpec.js index 84cbf0a3..618f5ad0 100644 --- a/spec/core/ClockSpec.js +++ b/spec/core/ClockSpec.js @@ -291,4 +291,24 @@ describe("Clock (acceptance)", function() { clock.tick(5); expect(delayedFn1).toHaveBeenCalled(); }); + + it("calls the global clearTimeout correctly when not installed", function () { + var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']), + global = originalJasmine.getGlobal(), + clock = new jasmine.Clock(global, delayedFunctionScheduler); + + expect(function() { + clock.clearTimeout(123) + }).not.toThrow(); + }); + + it("calls the global clearTimeout correctly when not installed", function () { + var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']), + global = originalJasmine.getGlobal(), + clock = new jasmine.Clock(global, delayedFunctionScheduler); + + expect(function() { + clock.clearInterval(123) + }).not.toThrow(); + }); }); diff --git a/src/core/Clock.js b/src/core/Clock.js index 2da053bf..0cbf76ce 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -33,7 +33,7 @@ jasmine.Clock = function(global, delayedFunctionScheduler) { } return timer.setTimeout(fn, delay); } - return timer.setTimeout.apply(null, arguments); + return timer.setTimeout.apply(global, arguments); }; self.setInterval = function(fn, delay, params) { @@ -43,15 +43,15 @@ jasmine.Clock = function(global, delayedFunctionScheduler) { } return timer.setInterval(fn, delay); } - return timer.setInterval.apply(null, arguments); + return timer.setInterval.apply(global, arguments); }; self.clearTimeout = function(id) { - return timer.clearTimeout(id); + return timer.clearTimeout.call(global, id); }; self.clearInterval = function(id) { - return timer.clearInterval(id); + return timer.clearInterval.call(global, id); }; self.tick = function(millis) {