Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix test race condition with DOMContentLoaded
Browse files Browse the repository at this point in the history
Test tap could somtimes fire before the event handlers were added
  • Loading branch information
dfreedm committed Sep 11, 2013
1 parent 8a859ac commit c91f99c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/tap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
suite('Tap', function() {
test('Up and Down', function(done) {
prepare(target, 'tap', done);
target.dispatchEvent(new PointerEvent('pointerdown', {isPrimary: true, buttons: 1, pointerId: 1, bubbles: true}));
target.dispatchEvent(new PointerEvent('pointerup', {isPrimary: true, buttons: 1, pointerId: 1, bubbles: true}));
var fireTap = function() {
target.dispatchEvent(new PointerEvent('pointerdown', {isPrimary: true, buttons: 1, pointerId: 1, bubbles: true}));
target.dispatchEvent(new PointerEvent('pointerup', {isPrimary: true, buttons: 1, pointerId: 1, bubbles: true}));
}
// handle case where DOMContentLoaded has already fired
if (document.readyState === 'complete') {
fireTap();
} else {
document.addEventListener('DOMContentLoaded', fireTap);
}
});
});

0 comments on commit c91f99c

Please sign in to comment.