Correctly pretty print objects from other contexts (e.g. iframes) and which do not override toString

Fixes #1087
This commit is contained in:
Fulvio Valente
2016-04-11 17:08:37 +01:00
parent f6da084642
commit 2710bdfc5e
2 changed files with 16 additions and 1 deletions
+9
View File
@@ -187,6 +187,15 @@ describe("jasmineUnderTest.pp", function () {
};
expect(jasmineUnderTest.pp(obj)).toEqual("my toString");
// Simulate object from another global context (e.g. an iframe or Web Worker) that does not actually have a custom
// toString despite obj.toString !== Object.prototype.toString
var objFromOtherContext = {
foo: 'bar',
toString: function () { return Object.prototype.toString.call(this); }
};
expect(jasmineUnderTest.pp(objFromOtherContext)).toEqual("Object({ foo: 'bar', toString: Function })");
});
it("should handle objects with null prototype", function() {