IE7 fixes

This commit is contained in:
ragaskar 2009-10-15 17:48:28 -07:00
parent 1b1c2b1998
commit 85d3b2d14b
4 changed files with 59 additions and 23 deletions

View File

@ -28,7 +28,8 @@ describe("jasmine.pp", function () {
it("should stringify objects properly", function() { it("should stringify objects properly", function() {
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }"); 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:'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() { it("should indicate circular object references", function() {
@ -39,8 +40,18 @@ describe("jasmine.pp", function () {
it("should indicate getters on objects as such", function() { it("should indicate getters on objects as such", function() {
var sampleValue = {id: 1}; var sampleValue = {id: 1};
sampleValue.__defineGetter__('calculatedValue', function() { throw new Error("don't call me!"); }); 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> }"); expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
}
else {
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1 }");
}
}); });
it("should stringify HTML nodes properly", function() { it("should stringify HTML nodes properly", function() {

View File

@ -56,7 +56,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) { for (var property in obj) {
if (property == '__Jasmine_been_here_before__') continue; if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__(property) != null); fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
} }
}; };

View File

@ -29,7 +29,14 @@ jasmine.UPDATE_INTERVAL = 250;
jasmine.bindOriginal_ = function(base, name) { jasmine.bindOriginal_ = function(base, name) {
var original = base[name]; var original = base[name];
return function() { return function() {
if (original.apply) {
return original.apply(base, arguments); return original.apply(base, arguments);
} else {
//IE support
if (base == window) {
return window[name].apply(window, arguments);
}
}
}; };
}; };
@ -168,7 +175,8 @@ jasmine.Spy = function(name) {
/** /**
* The acutal function this spy stubs. * The acutal function this spy stubs.
*/ */
this.plan = function() {}; this.plan = function() {
};
/** /**
* Tracking of the most recent call to the spy. * Tracking of the most recent call to the spy.
* @example * @example
@ -303,7 +311,7 @@ jasmine.createSpy = function(name) {
var spy = new jasmine.Spy(name); var spy = new jasmine.Spy(name);
for(var prop in spy) { for (var prop in spy) {
spyObj[prop] = spy[prop]; spyObj[prop] = spy[prop];
} }

View File

@ -140,19 +140,36 @@ jasmine.Clock = {
}; };
jasmine.Clock.installed = jasmine.Clock.real; jasmine.Clock.installed = jasmine.Clock.real;
//else for IE support
window.setTimeout = function(funcToCall, millis) { window.setTimeout = function(funcToCall, millis) {
if (jasmine.Clock.installed.setTimeout.apply) {
return jasmine.Clock.installed.setTimeout.apply(this, arguments); return jasmine.Clock.installed.setTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
}
}; };
window.setInterval = function(funcToCall, millis) { window.setInterval = function(funcToCall, millis) {
if (jasmine.Clock.installed.setInterval.apply) {
return jasmine.Clock.installed.setInterval.apply(this, arguments); return jasmine.Clock.installed.setInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.setInterval(funcToCall, millis);
}
}; };
window.clearTimeout = function(timeoutKey) { window.clearTimeout = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearTimeout.apply(this, arguments); return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearTimeout(timeoutKey);
}
}; };
window.clearInterval = function(timeoutKey) { window.clearInterval = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearInterval.apply(this, arguments); return jasmine.Clock.installed.clearInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearInterval(timeoutKey);
}
}; };