Last active
December 16, 2015 15:59
-
-
Save cdent/5459753 to your computer and use it in GitHub Desktop.
demonstrate bug with jsdom and jsquery. 1382 value may need to be tweaked to tickle bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"version": "0.0.1", | |
"dependencies": { | |
"jsdom": "*", | |
"jquery": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'), | |
jquery = require('jquery'), | |
Emitter = require('events').EventEmitter; | |
function setupAction(id) { | |
var emitter = new Emitter(); | |
console.log('setting up', id); | |
return { | |
emitter: emitter, | |
act1: function() { | |
var window = jsdom.jsdom().createWindow(), | |
jQuery = jquery.create(window); | |
setTimeout(function() { | |
emitter.emit('output', id); | |
window.close(); | |
}, Math.floor(Math.random() * 10)); | |
}, | |
act2: function() { | |
setTimeout(function() { | |
emitter.emit('output', id); | |
}, Math.floor(Math.random() * 10)); | |
} | |
}; | |
} | |
var id = 1; | |
function build() { | |
var output = setupAction(id++); | |
output.emitter.on('output', function(data) { | |
console.log('got', data); | |
}); | |
output.act1(); | |
if (id < 1382) { | |
setTimeout(build, Math.floor(Math.random() * 1)); | |
} else { | |
return; | |
} | |
} | |
build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment