diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 717b5100..3425a17c 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -312,6 +312,7 @@ getJasmineRequireObj().Env = function(j$) { var catchExceptions = true; + var realSetTimeout = global.setTimeout; this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler()); this.spies_ = []; @@ -413,11 +414,11 @@ getJasmineRequireObj().Env = function(j$) { var maximumSpecCallbackDepth = 100; var currentSpecCallbackDepth = 0; - function encourageGarbageCollection(fn) { + function clearStack(fn) { currentSpecCallbackDepth++; if (currentSpecCallbackDepth > maximumSpecCallbackDepth) { currentSpecCallbackDepth = 0; - global.setTimeout(fn, 0); + realSetTimeout(fn, 0); } else { fn(); } @@ -425,7 +426,7 @@ getJasmineRequireObj().Env = function(j$) { var queueRunnerFactory = function(options) { options.catchException = self.catchException; - options.encourageGC = options.encourageGarbageCollection || encourageGarbageCollection; + options.clearStack = options.clearStack || clearStack; new j$.QueueRunner(options).run(options.fns, 0); }; @@ -1289,7 +1290,7 @@ getJasmineRequireObj().QueueRunner = function() { function QueueRunner(attrs) { this.fns = attrs.fns || []; this.onComplete = attrs.onComplete || function() {}; - this.encourageGC = attrs.encourageGC || function(fn) {fn();}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; } @@ -1300,7 +1301,7 @@ getJasmineRequireObj().QueueRunner = function() { QueueRunner.prototype.run = function(fns, index) { if (index >= fns.length) { - this.encourageGC(this.onComplete); + this.clearStack(this.onComplete); return; } @@ -1462,7 +1463,7 @@ getJasmineRequireObj().Suite = function() { this.onStart = attrs.onStart || function() {}; this.completeCallback = attrs.completeCallback || function() {}; this.resultCallback = attrs.resultCallback || function() {}; - this.encourageGC = attrs.encourageGC || function(fn) {fn();}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; this.beforeFns = []; this.afterFns = []; diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 666263e0..9dd90fba 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -118,15 +118,15 @@ describe("QueueRunner", function() { it("calls a provided garbage collection function with the complete callback when done", function() { var fn = jasmine.createSpy('fn'), completeCallback = jasmine.createSpy('completeCallback'), - encourageGC = jasmine.createSpy('encourageGC'), + clearStack = jasmine.createSpy('clearStack'), queueRunner = new j$.QueueRunner({ fns: [fn], - encourageGC: encourageGC, + clearStack: clearStack, onComplete: completeCallback }); queueRunner.execute(); - expect(encourageGC).toHaveBeenCalledWith(completeCallback); + expect(clearStack).toHaveBeenCalledWith(completeCallback); }); }); diff --git a/src/core/Env.js b/src/core/Env.js index b23c90fc..5ebfe5ff 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -7,6 +7,7 @@ getJasmineRequireObj().Env = function(j$) { var catchExceptions = true; + var realSetTimeout = global.setTimeout; this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler()); this.spies_ = []; @@ -108,11 +109,11 @@ getJasmineRequireObj().Env = function(j$) { var maximumSpecCallbackDepth = 100; var currentSpecCallbackDepth = 0; - function encourageGarbageCollection(fn) { + function clearStack(fn) { currentSpecCallbackDepth++; if (currentSpecCallbackDepth > maximumSpecCallbackDepth) { currentSpecCallbackDepth = 0; - global.setTimeout(fn, 0); + realSetTimeout(fn, 0); } else { fn(); } @@ -120,7 +121,7 @@ getJasmineRequireObj().Env = function(j$) { var queueRunnerFactory = function(options) { options.catchException = self.catchException; - options.encourageGC = options.encourageGarbageCollection || encourageGarbageCollection; + options.clearStack = options.clearStack || clearStack; new j$.QueueRunner(options).run(options.fns, 0); }; diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index da9cae34..1bd2d403 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -3,7 +3,7 @@ getJasmineRequireObj().QueueRunner = function() { function QueueRunner(attrs) { this.fns = attrs.fns || []; this.onComplete = attrs.onComplete || function() {}; - this.encourageGC = attrs.encourageGC || function(fn) {fn();}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; } @@ -14,7 +14,7 @@ getJasmineRequireObj().QueueRunner = function() { QueueRunner.prototype.run = function(fns, index) { if (index >= fns.length) { - this.encourageGC(this.onComplete); + this.clearStack(this.onComplete); return; } diff --git a/src/core/Suite.js b/src/core/Suite.js index 23d00703..3e09603b 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -7,7 +7,7 @@ getJasmineRequireObj().Suite = function() { this.onStart = attrs.onStart || function() {}; this.completeCallback = attrs.completeCallback || function() {}; this.resultCallback = attrs.resultCallback || function() {}; - this.encourageGC = attrs.encourageGC || function(fn) {fn();}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; this.beforeFns = []; this.afterFns = [];