IE7 fixes
This commit is contained in:
parent
1b1c2b1998
commit
85d3b2d14b
@ -28,7 +28,8 @@ describe("jasmine.pp", function () {
|
||||
it("should stringify objects properly", function() {
|
||||
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
|
||||
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
||||
expect(jasmine.pp({foo: function () { }, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
||||
expect(jasmine.pp({foo: function () {
|
||||
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
||||
});
|
||||
|
||||
it("should indicate circular object references", function() {
|
||||
@ -39,8 +40,18 @@ describe("jasmine.pp", function () {
|
||||
|
||||
it("should indicate getters on objects as such", function() {
|
||||
var sampleValue = {id: 1};
|
||||
sampleValue.__defineGetter__('calculatedValue', function() { throw new Error("don't call me!"); });
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
|
||||
if (sampleValue.__defineGetter__) {
|
||||
//not supported in IE!
|
||||
sampleValue.__defineGetter__('calculatedValue', function() {
|
||||
throw new Error("don't call me!");
|
||||
});
|
||||
}
|
||||
if (sampleValue.__defineGetter__) {
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
|
||||
}
|
||||
else {
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1 }");
|
||||
}
|
||||
});
|
||||
|
||||
it("should stringify HTML nodes properly", function() {
|
||||
|
@ -56,7 +56,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||
for (var property in obj) {
|
||||
if (property == '__Jasmine_been_here_before__') continue;
|
||||
fn(property, obj.__lookupGetter__(property) != null);
|
||||
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
|
||||
}
|
||||
};
|
||||
|
||||
|
22
src/base.js
22
src/base.js
@ -29,7 +29,14 @@ jasmine.UPDATE_INTERVAL = 250;
|
||||
jasmine.bindOriginal_ = function(base, name) {
|
||||
var original = base[name];
|
||||
return function() {
|
||||
return original.apply(base, arguments);
|
||||
if (original.apply) {
|
||||
return original.apply(base, arguments);
|
||||
} else {
|
||||
//IE support
|
||||
if (base == window) {
|
||||
return window[name].apply(window, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -71,10 +78,10 @@ jasmine.getEnv = function() {
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return value &&
|
||||
typeof value === 'object' &&
|
||||
typeof value.length === 'number' &&
|
||||
typeof value.splice === 'function' &&
|
||||
!(value.propertyIsEnumerable('length'));
|
||||
typeof value === 'object' &&
|
||||
typeof value.length === 'number' &&
|
||||
typeof value.splice === 'function' &&
|
||||
!(value.propertyIsEnumerable('length'));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -168,7 +175,8 @@ jasmine.Spy = function(name) {
|
||||
/**
|
||||
* The acutal function this spy stubs.
|
||||
*/
|
||||
this.plan = function() {};
|
||||
this.plan = function() {
|
||||
};
|
||||
/**
|
||||
* Tracking of the most recent call to the spy.
|
||||
* @example
|
||||
@ -303,7 +311,7 @@ jasmine.createSpy = function(name) {
|
||||
|
||||
var spy = new jasmine.Spy(name);
|
||||
|
||||
for(var prop in spy) {
|
||||
for (var prop in spy) {
|
||||
spyObj[prop] = spy[prop];
|
||||
}
|
||||
|
||||
|
@ -140,19 +140,36 @@ jasmine.Clock = {
|
||||
};
|
||||
jasmine.Clock.installed = jasmine.Clock.real;
|
||||
|
||||
//else for IE support
|
||||
window.setTimeout = function(funcToCall, millis) {
|
||||
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
|
||||
if (jasmine.Clock.installed.setTimeout.apply) {
|
||||
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
|
||||
}
|
||||
};
|
||||
|
||||
window.setInterval = function(funcToCall, millis) {
|
||||
return jasmine.Clock.installed.setInterval.apply(this, arguments);
|
||||
if (jasmine.Clock.installed.setInterval.apply) {
|
||||
return jasmine.Clock.installed.setInterval.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.setInterval(funcToCall, millis);
|
||||
}
|
||||
};
|
||||
|
||||
window.clearTimeout = function(timeoutKey) {
|
||||
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
|
||||
if (jasmine.Clock.installed.clearTimeout.apply) {
|
||||
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.clearTimeout(timeoutKey);
|
||||
}
|
||||
};
|
||||
|
||||
window.clearInterval = function(timeoutKey) {
|
||||
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
|
||||
if (jasmine.Clock.installed.clearTimeout.apply) {
|
||||
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.clearInterval(timeoutKey);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user