Merge pull request #1960 from openseadragon/ms-firefox-test

Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler".…
This commit is contained in:
Ian Gilman 2021-03-18 11:21:15 -07:00 committed by GitHub
commit 58a90f7c39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 10 deletions

View File

@ -41,6 +41,7 @@ OPENSEADRAGON CHANGELOG
* Added setImageFormatsSupported function (#1954 @pandaxtc)
* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery)
* Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery)
* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1960 @msalsbery)
* ReferenceStrip: Fixed issue where its element was being removed from its parent element twice on destroy, causing an exception (#1958 @msalsbery)
* ReferenceStrip: Made its element focusable for keyboard navigation (#1958 @msalsbery)

View File

@ -833,22 +833,56 @@
// ----------
QUnit.test('Viewer: preventDefaultAction in dblClickHandler', function(assert) {
var done = assert.async();
var tracker = viewer.innerTracker;
var epsilon = 0.0000001;
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
simEvent = {},
offset = $canvas.offset();
var simulateEnter = function (x, y) {
simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y;
$canvas.simulate( 'mouseenter', simEvent );
};
var simulateLeave = function (x, y) {
simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y;
simEvent.relatedTarget = document.body;
$canvas.simulate( 'mouseleave', simEvent );
};
var simulateDown = function (x, y) {
simEvent.button = 0;
simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y;
$canvas.simulate( 'mousedown', simEvent );
};
var simulateUp = function (x, y) {
simEvent.button = 0;
simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y;
$canvas.simulate( 'mouseup', simEvent );
};
function simulateDblTap() {
var touches = [];
TouchUtil.reset();
touches.push(TouchUtil.start([0,0]));
TouchUtil.end( touches[0] );
touches.push(TouchUtil.start([0,0]));
TouchUtil.end( touches[1] );
simulateEnter(2, 2);
simulateDown(2, 2);
simulateUp(2, 2);
simulateDown(2, 2);
simulateUp(2, 2);
simulateLeave(-1, -1);
}
var onOpen = function() {
viewer.removeHandler('open', onOpen);
var origClickSetting = viewer.gestureSettingsMouse.clickToZoom;
var origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom;
viewer.gestureSettingsMouse.clickToZoom = false;
viewer.gestureSettingsMouse.dblClickToZoom = true;
var originalZoom = viewer.viewport.getZoom();
var onCanvasDblClick = function (event) {
@ -857,7 +891,6 @@
viewer.addHandler('canvas-double-click', onCanvasDblClick);
TouchUtil.initTracker(tracker);
simulateDblTap();
var zoom = viewer.viewport.getZoom();
@ -875,7 +908,9 @@
"Zoom on double tap should not be prevented");
TouchUtil.resetTracker(tracker);
viewer.gestureSettingsMouse.clickToZoom = origClickSetting;
viewer.gestureSettingsMouse.dblClickToZoom = origDblClickSetting;
viewer.close();
done();
};