diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f57ff799..1c3945e9 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1988,8 +1988,8 @@ getJasmineRequireObj().matchersUtil = function(j$) { // Objects with different constructors are not equivalent, but `Object`s // or `Array`s from different frames are. var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && - isFunction(bCtor) && bCtor instanceof bCtor)) { + if (aCtor !== bCtor && !(isObjectConstructor(aCtor) && + isObjectConstructor(bCtor))) { return false; } } @@ -2041,14 +2041,22 @@ getJasmineRequireObj().matchersUtil = function(j$) { return extraKeys; } + } + + function has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + } - function has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } + function isFunction(obj) { + return typeof obj === 'function'; + } - function isFunction(obj) { - return typeof obj === 'function'; - } + function isObjectConstructor(ctor) { + // aCtor instanceof aCtor is true for the Object and Function + // constructors (since a constructor is-a Function and a function is-a + // Object). We don't just compare ctor === Object because the constructor + // might come from a different frame with different globals. + return isFunction(ctor) && ctor instanceof ctor; } };