Skip to content

Commit

Permalink
Remove invalid optimization in checkGlobals().
Browse files Browse the repository at this point in the history
  • Loading branch information
noshir-patel committed Jan 13, 2014
1 parent ffaa38d commit 1d7c828
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/runner.js
Expand Up @@ -168,10 +168,6 @@ Runner.prototype.checkGlobals = function(test){
ok = ok.concat(test._allowedGlobals || []);
}

// check length - 2 ('errno' and 'location' globals)
if (isNode && 1 == ok.length - globals.length) return;
else if (2 == ok.length - globals.length) return;

if(this.prevGlobalsLength == globals.length) return;
this.prevGlobalsLength = globals.length;

Expand Down
15 changes: 15 additions & 0 deletions test/runner.js
Expand Up @@ -97,6 +97,21 @@ describe('Runner', function(){
runner.checkGlobals('im a test');
})

it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function(done) {
var doneCalled = false;
runner.globals('good');
global.bad = 1;
runner.on('fail', function(test, err) {
delete global.bad;
done();
doneCalled = true;
});
runner.checkGlobals('test');
if (!doneCalled) {
done(Error("Expected test failure did not occur."));
}
});

it ('should not fail when a new common global is introduced', function(){
// verify that the prop isn't enumerable
delete global.XMLHttpRequest;
Expand Down

0 comments on commit 1d7c828

Please sign in to comment.