Protect against a FF bug: Exceptions don't always have a message property even though they were instantiated with one. Using Error#toString alleviates this

This commit is contained in:
Dan Hansen and Davis W. Frank
2013-03-01 10:43:09 -08:00
parent b7af6abca5
commit b22bf9a031
3 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -1717,7 +1717,7 @@ jasmine.Spec.prototype.getFullName = function() {
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending"; jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
jasmine.Spec.isPendingSpecException = function(e) { jasmine.Spec.isPendingSpecException = function(e) {
return e.message.indexOf(jasmine.Spec.pendingSpecExceptionMessage) === 0; return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
};jasmine.Suite = function(attrs) { };jasmine.Suite = function(attrs) {
this.env = attrs.env; this.env = attrs.env;
this.id = attrs.id; this.id = attrs.id;
+7
View File
@@ -6,6 +6,13 @@ describe("Spec", function() {
expect(jasmine.Spec.isPendingSpecException(e)).toBe(true); expect(jasmine.Spec.isPendingSpecException(e)).toBe(true);
}); });
it("#isPendingSpecException returns true for a pending spec exception (protect against FF bug)", function() {
var e = new Error(jasmine.Spec.pendingSpecExceptionMessage);
delete e.message;
expect(jasmine.Spec.isPendingSpecException(e)).toBe(true);
});
it("#isPendingSpecException returns true for a pending spec exception", function() { it("#isPendingSpecException returns true for a pending spec exception", function() {
var e = new Error("foo"); var e = new Error("foo");
+1 -1
View File
@@ -114,5 +114,5 @@ jasmine.Spec.prototype.getFullName = function() {
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending"; jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
jasmine.Spec.isPendingSpecException = function(e) { jasmine.Spec.isPendingSpecException = function(e) {
return e.message.indexOf(jasmine.Spec.pendingSpecExceptionMessage) === 0; return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
}; };