Skip to content

Commit

Permalink
Merge pull request #2312 from AnalyticalGraphicsInc/fixMiddleClickInS…
Browse files Browse the repository at this point in the history
…pecs

Ignore any events that bubble up to the document while testing.
  • Loading branch information
bagnell committed Dec 8, 2014
2 parents 8749f60 + f1586a6 commit 2092e79
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Specs/Core/ScreenSpaceEventHandlerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@ defineSuite([
return cloningSpy;
}

var eventsToStop = 'pointerdown pointerup pointermove mousedown mouseup mousemove touchstart touchend touchmove dblclick wheel mousewheel DOMMouseScroll'.split(' ');

function stop(event) {
event.stopPropagation();
event.preventDefault();
}

beforeEach(function() {
// ignore events that bubble up to the document.
// this prevents triggering the browser's "middle click to scroll" behavior
eventsToStop.forEach(function(e) {
document.addEventListener(e, stop, false);
});

element = document.createElement('div');
element.style.position = 'absolute';
element.style.top = '0';
Expand All @@ -74,6 +87,10 @@ defineSuite([
afterEach(function() {
document.body.removeChild(element);
handler = !handler.isDestroyed() && handler.destroy();

eventsToStop.forEach(function(e) {
document.removeEventListener(e, stop, false);
});
});

describe('setInputAction', function() {
Expand Down

0 comments on commit 2092e79

Please sign in to comment.