Fixed comparison between URL objects

* Fixes #1866
This commit is contained in:
Steve Gravrock
2020-11-21 13:35:10 -08:00
parent 88de272c89
commit 89331bb1bb
8 changed files with 106 additions and 0 deletions

View File

@@ -161,6 +161,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
);
};
j$.isURL = function(obj) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.URL !== 'undefined' &&
obj.constructor === jasmineGlobal.URL
);
};
j$.isDataView = function(obj) {
return (
obj !== null &&

View File

@@ -475,6 +475,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
diffBuilder.recordMismatch();
return false;
}
} else if (j$.isURL(a) && j$.isURL(b)) {
// URLs have no enumrable properties, so the default object comparison
// would consider any two URLs to be equal.
return a.toString() === b.toString();
} else {
// Objects with different constructors are not equivalent, but `Object`s
// or `Array`s from different frames are.