Don't use window
This commit is contained in:
@@ -138,6 +138,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
||||
/**
|
||||
* Maximum number of array elements to display when pretty printing objects.
|
||||
* This will also limit the number of keys and values displayed for an object.
|
||||
* Elements past this number will be ellipised.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
|
||||
*/
|
||||
@@ -1611,7 +1612,9 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().clearStack = function(j$) {
|
||||
function messageChannelImpl(global) {
|
||||
var maxInlineCallCount = 10;
|
||||
|
||||
function messageChannelImpl(global, setTimeout) {
|
||||
var channel = new global.MessageChannel(),
|
||||
head = {},
|
||||
tail = head;
|
||||
@@ -1634,25 +1637,43 @@ getJasmineRequireObj().clearStack = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
var currentCallCount = 0;
|
||||
return function clearStack(fn) {
|
||||
tail = tail.next = { task: fn };
|
||||
channel.port2.postMessage(0);
|
||||
currentCallCount++;
|
||||
|
||||
if (currentCallCount < maxInlineCallCount) {
|
||||
tail = tail.next = { task: fn };
|
||||
channel.port2.postMessage(0);
|
||||
} else {
|
||||
setTimeout(fn);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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)) {
|
||||
var realSetImmediate = global.setImmediate;
|
||||
return function(fn) {
|
||||
realSetImmediate(fn);
|
||||
currentCallCount++;
|
||||
|
||||
if (currentCallCount < maxInlineCallCount) {
|
||||
realSetImmediate(fn);
|
||||
} else {
|
||||
currentCallCount = 0;
|
||||
|
||||
setTimeoutImpl(fn);
|
||||
}
|
||||
};
|
||||
} else if (!j$.util.isUndefined(global.MessageChannel)) {
|
||||
return messageChannelImpl(global);
|
||||
return messageChannelImpl(global, setTimeoutImpl);
|
||||
} else {
|
||||
var realSetTimeout = global.setTimeout;
|
||||
return function clearStack(fn) {
|
||||
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
||||
};
|
||||
return setTimeoutImpl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -954,7 +954,7 @@ describe("Env integration", function() {
|
||||
describe("with a mock clock", function() {
|
||||
beforeEach(function() {
|
||||
this.originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
|
||||
this.realSetTimeout = window.setTimeout;
|
||||
this.realSetTimeout = setTimeout;
|
||||
jasmine.clock().install();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user