☕️ Classic, reliable, trusted test framework for Node.js and the browser
refactored global leak testing
TJ Holowaychuk7b2a200baf59
diff --git a/lib/runner.js b/lib/runner.jsindex 614101c1..fff711a9 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -113,12 +113,7 @@ Runner.prototype.globals = function(arr){Runner.prototype.checkGlobals = function(test){if (this.ignoreLeaks) return;- var leaks = utils.filter(utils.keys(global), function(key){- var matched = utils.filter(this._globals, function(allowed){- return allowed == key || key.lastIndexOf(allowed.split('*')[0], 0) == 0;- });- return matched.length == 0 && (!global.navigator || 'onerror' !== key);- }, this);+ var leaks = filterLeaks(this._globals);this._globals = this._globals.concat(leaks);@@ -460,3 +455,20 @@ Runner.prototype.run = function(fn){return this;};++/**+ * Filter leaks with the given globals flagged as `ok`.+ *+ * @param {Array} ok+ * @return {Array}+ * @api private+ */++function filterLeaks(ok) {+ return utils.filter(utils.keys(global), function(key){+ var matched = utils.filter(ok, function(ok){+ return ok == key || 0 == key.indexOf(ok.split('*')[0]);+ });+ return matched.length == 0 && (!global.navigator || 'onerror' !== key);+ }, this);+}\ No newline at end of file