From 4f49288f31d5889eba25b054bd4011f4eea1973f Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Tue, 16 May 2017 14:36:35 -0700 Subject: [PATCH] Built distribution - Fixes #1327 - Fixes jasmine/gulp-jasmine-browser#48 --- lib/jasmine-core/jasmine.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 0a635bf5..2439ef3a 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -854,6 +854,10 @@ getJasmineRequireObj().Env = function(j$) { reporter.suiteStarted(suite.result); }, nodeComplete: function(suite, result) { + if (suite !== currentSuite()) { + throw new Error('Tried to complete the wrong suite'); + } + if (!suite.markedPending) { clearResourcesForRunnable(suite.id); } @@ -1601,11 +1605,22 @@ getJasmineRequireObj().clearStack = function(j$) { head = {}, tail = head; + var taskRunning = false; channel.port1.onmessage = function() { head = head.next; var task = head.task; delete head.task; - task(); + + if (taskRunning) { + global.setTimeout(task, 0); + } else { + try { + taskRunning = true; + task(); + } finally { + taskRunning = false; + } + } }; return function clearStack(fn) { @@ -3828,6 +3843,11 @@ getJasmineRequireObj().QueueRunner = function(j$) { } QueueRunner.prototype.execute = function() { + var self = this; + this.handleFinalError = function(error) { + self.onException(error); + }; + this.globalErrors.pushListener(this.handleFinalError); this.run(this.queueableFns, 0); }; @@ -3847,7 +3867,10 @@ getJasmineRequireObj().QueueRunner = function(j$) { } } - this.clearStack(this.onComplete); + this.clearStack(function() { + self.globalErrors.popListener(self.handleFinalError); + self.onComplete(); + }); function attemptSync(queueableFn) { try {