Properly skip Set tests in browsers that don't really support it

This commit is contained in:
Gregg Van Hove
2016-09-27 15:36:01 -07:00
parent 05097b3e42
commit bad9c63bf7
3 changed files with 26 additions and 8 deletions

View File

@@ -20,4 +20,23 @@
return /Firefox\/([0-9]{0,})/.exec(userAgent);
});
function hasFunctioningSets() {
if (typeof Set !== 'undefined') { return false; }
try {
var s = new Set([4]);
if (s.size !== 1) { return false; }
if (s.values().next().value !== 4) { return false; }
return true;
} catch(e) {
return false;
}
}
env.requireFunctioningSets = function() {
if (!hasFunctioningSets()) {
pending("Browser has incomplete or missing support for Sets");
}
};
})(jasmine.getEnv());