Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02c18a3596 | ||
|
|
0c6397d802 | ||
|
|
eb4671452e | ||
|
|
b38decf050 |
@@ -1600,7 +1600,9 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().clearStack = function(j$) {
|
getJasmineRequireObj().clearStack = function(j$) {
|
||||||
function messageChannelImpl(global) {
|
var maxInlineCallCount = 10;
|
||||||
|
|
||||||
|
function messageChannelImpl(global, setTimeout) {
|
||||||
var channel = new global.MessageChannel(),
|
var channel = new global.MessageChannel(),
|
||||||
head = {},
|
head = {},
|
||||||
tail = head;
|
tail = head;
|
||||||
@@ -1623,25 +1625,44 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var currentCallCount = 0;
|
||||||
return function clearStack(fn) {
|
return function clearStack(fn) {
|
||||||
tail = tail.next = { task: fn };
|
currentCallCount++;
|
||||||
channel.port2.postMessage(0);
|
|
||||||
|
if (currentCallCount < maxInlineCallCount) {
|
||||||
|
tail = tail.next = { task: fn };
|
||||||
|
channel.port2.postMessage(0);
|
||||||
|
} else {
|
||||||
|
currentCallCount = 0;
|
||||||
|
setTimeout(fn);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClearStack(global) {
|
function getClearStack(global) {
|
||||||
|
var currentCallCount = 0;
|
||||||
|
var realSetTimeout = global.setTimeout;
|
||||||
|
var setTimeoutImpl = function clearStack(fn) {
|
||||||
|
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
||||||
|
};
|
||||||
|
|
||||||
if (j$.isFunction_(global.setImmediate)) {
|
if (j$.isFunction_(global.setImmediate)) {
|
||||||
var realSetImmediate = global.setImmediate;
|
var realSetImmediate = global.setImmediate;
|
||||||
return function(fn) {
|
return function(fn) {
|
||||||
realSetImmediate(fn);
|
currentCallCount++;
|
||||||
|
|
||||||
|
if (currentCallCount < maxInlineCallCount) {
|
||||||
|
realSetImmediate(fn);
|
||||||
|
} else {
|
||||||
|
currentCallCount = 0;
|
||||||
|
|
||||||
|
setTimeoutImpl(fn);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} else if (!j$.util.isUndefined(global.MessageChannel)) {
|
} else if (!j$.util.isUndefined(global.MessageChannel)) {
|
||||||
return messageChannelImpl(global);
|
return messageChannelImpl(global, setTimeoutImpl);
|
||||||
} else {
|
} else {
|
||||||
var realSetTimeout = global.setTimeout;
|
return setTimeoutImpl;
|
||||||
return function clearStack(fn) {
|
|
||||||
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4976,5 +4997,5 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().version = function() {
|
getJasmineRequireObj().version = function() {
|
||||||
return '2.6.3';
|
return '2.6.4';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
#
|
#
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Core
|
module Core
|
||||||
VERSION = "2.6.3"
|
VERSION = "2.6.4"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jasmine-core",
|
"name": "jasmine-core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "2.6.3",
|
"version": "2.6.4",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/jasmine/jasmine.git"
|
"url": "https://github.com/jasmine/jasmine.git"
|
||||||
|
|||||||
17
release_notes/2.6.4.md
Normal file
17
release_notes/2.6.4.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Jasmine 2.6.4 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This is a patch release to fix some regressions and performance problems in the 2.6.0 release
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Break into a `setTimeout` every once in a while allowing the CPU to run other things that used the real `setTimeout`
|
||||||
|
- Fixes [#1327](https://github.com/jasmine/jasmine/issues/1327)
|
||||||
|
- See [#1334](https://github.com/jasmine/jasmine/issues/1334)
|
||||||
|
- Fixes [jasmine/gulp-jasmine-browser#48](https://github.com/jasmine/gulp-jasmine-browser/issues/48)
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
@@ -21,6 +21,34 @@ describe("ClearStack", function() {
|
|||||||
expect(setImmediate).toHaveBeenCalled();
|
expect(setImmediate).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses setTimeout instead of setImmediate every 10 calls to make sure we release the CPU", function() {
|
||||||
|
var setImmediate = jasmine.createSpy('setImmediate'),
|
||||||
|
setTimeout = jasmine.createSpy('setTimeout'),
|
||||||
|
global = { setImmediate: setImmediate, setTimeout: setTimeout },
|
||||||
|
clearStack = jasmineUnderTest.getClearStack(global);
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
|
||||||
|
expect(setImmediate).toHaveBeenCalled();
|
||||||
|
expect(setTimeout).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
expect(setImmediate.calls.count()).toEqual(9);
|
||||||
|
expect(setTimeout.calls.count()).toEqual(1);
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
expect(setImmediate.calls.count()).toEqual(10);
|
||||||
|
expect(setTimeout.calls.count()).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("uses MessageChannels when available", function() {
|
it("uses MessageChannels when available", function() {
|
||||||
var fakeChannel = {
|
var fakeChannel = {
|
||||||
port1: {},
|
port1: {},
|
||||||
@@ -37,6 +65,41 @@ describe("ClearStack", function() {
|
|||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses setTimeout instead of MessageChannel every 10 calls to make sure we release the CPU", function() {
|
||||||
|
var fakeChannel = {
|
||||||
|
port1: {},
|
||||||
|
port2: {
|
||||||
|
postMessage: jasmine.createSpy('postMessage').and.callFake(function() {
|
||||||
|
fakeChannel.port1.onmessage();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setTimeout = jasmine.createSpy('setTimeout'),
|
||||||
|
global = { MessageChannel: function() { return fakeChannel; }, setTimeout: setTimeout },
|
||||||
|
clearStack = jasmineUnderTest.getClearStack(global);
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
clearStack(function() { });
|
||||||
|
|
||||||
|
expect(fakeChannel.port2.postMessage).toHaveBeenCalled();
|
||||||
|
expect(setTimeout).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
expect(fakeChannel.port2.postMessage.calls.count()).toEqual(9);
|
||||||
|
expect(setTimeout.calls.count()).toEqual(1);
|
||||||
|
|
||||||
|
clearStack(function() { });
|
||||||
|
expect(fakeChannel.port2.postMessage.calls.count()).toEqual(10);
|
||||||
|
expect(setTimeout.calls.count()).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("calls setTimeout when onmessage is called recursively", function() {
|
it("calls setTimeout when onmessage is called recursively", function() {
|
||||||
var fakeChannel = {
|
var fakeChannel = {
|
||||||
port1: {},
|
port1: {},
|
||||||
|
|||||||
@@ -952,16 +952,15 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("with a mock clock", function() {
|
describe("with a mock clock", function() {
|
||||||
var originalTimeout;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
|
this.originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
|
this.realSetTimeout = setTimeout;
|
||||||
jasmine.clock().install();
|
jasmine.clock().install();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
jasmine.clock().uninstall();
|
jasmine.clock().uninstall();
|
||||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.originalTimeout;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
||||||
@@ -1080,7 +1079,8 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
||||||
var env = new jasmineUnderTest.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']),
|
||||||
|
realSetTimeout = this.realSetTimeout;
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite beforeAll times out', [
|
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite beforeAll times out', [
|
||||||
@@ -1110,6 +1110,11 @@ describe("Env integration", function() {
|
|||||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
|
|
||||||
env.describe('suite', function() {
|
env.describe('suite', function() {
|
||||||
|
env.afterAll(function() {
|
||||||
|
realSetTimeout(function() {
|
||||||
|
jasmine.clock().tick(10);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
env.describe('beforeAll', function() {
|
env.describe('beforeAll', function() {
|
||||||
env.beforeAll(function(innerDone) {
|
env.beforeAll(function(innerDone) {
|
||||||
jasmine.clock().tick(5001);
|
jasmine.clock().tick(5001);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
getJasmineRequireObj().clearStack = function(j$) {
|
getJasmineRequireObj().clearStack = function(j$) {
|
||||||
function messageChannelImpl(global) {
|
var maxInlineCallCount = 10;
|
||||||
|
|
||||||
|
function messageChannelImpl(global, setTimeout) {
|
||||||
var channel = new global.MessageChannel(),
|
var channel = new global.MessageChannel(),
|
||||||
head = {},
|
head = {},
|
||||||
tail = head;
|
tail = head;
|
||||||
@@ -22,25 +24,44 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var currentCallCount = 0;
|
||||||
return function clearStack(fn) {
|
return function clearStack(fn) {
|
||||||
tail = tail.next = { task: fn };
|
currentCallCount++;
|
||||||
channel.port2.postMessage(0);
|
|
||||||
|
if (currentCallCount < maxInlineCallCount) {
|
||||||
|
tail = tail.next = { task: fn };
|
||||||
|
channel.port2.postMessage(0);
|
||||||
|
} else {
|
||||||
|
currentCallCount = 0;
|
||||||
|
setTimeout(fn);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClearStack(global) {
|
function getClearStack(global) {
|
||||||
|
var currentCallCount = 0;
|
||||||
|
var realSetTimeout = global.setTimeout;
|
||||||
|
var setTimeoutImpl = function clearStack(fn) {
|
||||||
|
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
||||||
|
};
|
||||||
|
|
||||||
if (j$.isFunction_(global.setImmediate)) {
|
if (j$.isFunction_(global.setImmediate)) {
|
||||||
var realSetImmediate = global.setImmediate;
|
var realSetImmediate = global.setImmediate;
|
||||||
return function(fn) {
|
return function(fn) {
|
||||||
realSetImmediate(fn);
|
currentCallCount++;
|
||||||
|
|
||||||
|
if (currentCallCount < maxInlineCallCount) {
|
||||||
|
realSetImmediate(fn);
|
||||||
|
} else {
|
||||||
|
currentCallCount = 0;
|
||||||
|
|
||||||
|
setTimeoutImpl(fn);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} else if (!j$.util.isUndefined(global.MessageChannel)) {
|
} else if (!j$.util.isUndefined(global.MessageChannel)) {
|
||||||
return messageChannelImpl(global);
|
return messageChannelImpl(global, setTimeoutImpl);
|
||||||
} else {
|
} else {
|
||||||
var realSetTimeout = global.setTimeout;
|
return setTimeoutImpl;
|
||||||
return function clearStack(fn) {
|
|
||||||
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user