2017-12-02 03:51:13 +03:00
|
|
|
/* global QUnit, $, Util, testLog */
|
2013-06-27 00:54:37 +04:00
|
|
|
|
2013-02-14 22:21:07 +04:00
|
|
|
(function() {
|
2013-07-02 02:17:45 +04:00
|
|
|
var viewer;
|
2013-02-14 22:21:07 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.module('Basic', {
|
|
|
|
beforeEach: function () {
|
|
|
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-07-02 23:12:31 +04:00
|
|
|
testLog.reset();
|
|
|
|
|
2013-03-07 23:52:01 +04:00
|
|
|
viewer = OpenSeadragon({
|
2013-03-07 22:44:08 +04:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
2013-06-18 22:08:16 +04:00
|
|
|
springStiffness: 100 // Faster animation = faster tests
|
2013-03-07 22:44:08 +04:00
|
|
|
});
|
2013-07-02 02:17:45 +04:00
|
|
|
},
|
2017-12-02 03:51:13 +03:00
|
|
|
afterEach: function () {
|
2013-07-02 21:56:55 +04:00
|
|
|
if (viewer && viewer.close) {
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
viewer = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Open', function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
assert.ok(viewer, 'Viewer exists');
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
var openHandler = function(event) {
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.removeHandler('open', openHandler);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(true, 'Open event was sent');
|
|
|
|
assert.ok(event, 'Handler received event data');
|
|
|
|
assert.equal(event.eventSource, viewer, 'Sender of open event was viewer');
|
|
|
|
assert.ok(viewer.viewport, 'Viewport exists');
|
|
|
|
assert.ok(viewer.source, 'source exists');
|
|
|
|
assert.ok(viewer._updateRequestId, 'timer is on');
|
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
2013-03-07 22:44:08 +04:00
|
|
|
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
|
|
|
});
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Open Error Handling', function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
assert.ok(viewer, 'Viewer exists');
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
viewer.addHandler('open', function(event) {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(false, "The open event should not fire for failed opens");
|
|
|
|
done();
|
2013-03-07 22:44:08 +04:00
|
|
|
});
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
viewer.addHandler('open-failed', function(event) {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(true, "The open-failed event should be fired when the source 404s");
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2022-04-15 11:32:08 +03:00
|
|
|
assert.ok(testLog.error.contains('["HTTP 404 attempting to load TileSource: /test/data/not-a-real-file"]'),
|
|
|
|
"'open-failed' fired after AJAX error handler prints error to the console.'");
|
2013-07-02 23:12:31 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
viewer.open('/test/data/not-a-real-file');
|
2013-03-07 23:52:01 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Zoom', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler("open", function () {
|
|
|
|
var viewport = viewer.viewport;
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
2013-07-02 02:17:45 +04:00
|
|
|
|
|
|
|
var zoomHandler = function() {
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.removeHandler('animation-finish', zoomHandler);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.addHandler('animation-finish', zoomHandler);
|
2013-07-02 02:17:45 +04:00
|
|
|
viewport.zoomTo(2);
|
|
|
|
});
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-03-07 23:52:01 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Pan', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler("open", function () {
|
|
|
|
var viewport = viewer.viewport,
|
|
|
|
center = viewport.getCenter();
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
2013-07-02 02:17:45 +04:00
|
|
|
|
|
|
|
var panHandler = function() {
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.removeHandler('animation-finish', panHandler);
|
2013-07-02 02:17:45 +04:00
|
|
|
center = viewport.getCenter();
|
2017-12-05 04:31:14 +03:00
|
|
|
Util.assessNumericValue(assert, center.x, 0.1, 0.00001, 'panned horizontally');
|
|
|
|
Util.assessNumericValue(assert, center.y, 0.1, 0.00001, 'panned vertically');
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
|
|
|
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.addHandler('animation-finish', panHandler);
|
2013-07-02 02:17:45 +04:00
|
|
|
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
|
|
|
|
});
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-03-07 23:52:01 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Home', function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
// Test beforeEach:
|
2013-07-02 02:17:45 +04:00
|
|
|
function opener() {
|
|
|
|
var viewport = viewer.viewport;
|
|
|
|
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
|
|
|
|
viewport.zoomTo(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stage1() {
|
|
|
|
var viewport = viewer.viewport,
|
|
|
|
center = viewport.getCenter();
|
|
|
|
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.removeHandler('animation-finish', stage1);
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned');
|
|
|
|
assert.notEqual(viewport.getZoom(), 1, 'We start out zoomed');
|
2013-07-02 02:17:45 +04:00
|
|
|
|
|
|
|
var homeHandler = function() {
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.removeHandler('animation-finish', homeHandler);
|
2013-07-02 02:17:45 +04:00
|
|
|
center = viewport.getCenter();
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned');
|
|
|
|
assert.equal(viewport.getZoom(), 1, 'We end up unzoomed');
|
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
2013-03-22 00:44:22 +04:00
|
|
|
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.addHandler('animation-finish', homeHandler);
|
2014-08-19 03:32:21 +04:00
|
|
|
viewer.viewport.goHome(true);
|
2013-07-02 02:17:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
viewer.addHandler("open", opener);
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.addHandler("animation-finish", stage1);
|
2013-03-22 00:44:22 +04:00
|
|
|
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-03-22 00:44:22 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Click', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler("open", function () {
|
|
|
|
var viewport = viewer.viewport,
|
2013-06-27 00:54:37 +04:00
|
|
|
center = viewport.getCenter();
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
|
|
|
assert.equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
2013-03-22 00:44:22 +04:00
|
|
|
|
2013-07-02 02:17:45 +04:00
|
|
|
var clickHandler = function() {
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.removeHandler('animation-finish', clickHandler);
|
2013-07-02 02:17:45 +04:00
|
|
|
center = viewport.getCenter();
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly');
|
|
|
|
assert.equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
2013-03-22 00:44:22 +04:00
|
|
|
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.addHandler('animation-finish', clickHandler);
|
2013-08-30 00:01:07 +04:00
|
|
|
Util.simulateViewerClickWithDrag( {
|
|
|
|
viewer: viewer,
|
|
|
|
widthFactor: 0.25,
|
|
|
|
heightFactor: 0.25,
|
|
|
|
dragCount: 0,
|
|
|
|
dragDx: 0,
|
|
|
|
dragDy: 0
|
|
|
|
} );
|
|
|
|
} );
|
2013-07-02 02:17:45 +04:00
|
|
|
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-03-22 00:44:22 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('FullPage', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler("open", function () {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!viewer.isFullPage(), 'Started out not fullpage');
|
|
|
|
assert.ok(!$(viewer.element).hasClass('fullpage'),
|
2013-07-02 02:17:45 +04:00
|
|
|
'No fullpage class on div');
|
|
|
|
|
2013-11-02 01:37:19 +04:00
|
|
|
var checkEnteringPreFullPage = function(event) {
|
|
|
|
viewer.removeHandler('pre-full-page', checkEnteringPreFullPage);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(event.fullPage, 'Switching to fullpage');
|
|
|
|
assert.ok(!viewer.isFullPage(), 'Not yet fullpage');
|
2013-11-02 01:37:19 +04:00
|
|
|
};
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2013-11-02 01:37:19 +04:00
|
|
|
var checkEnteringFullPage = function(event) {
|
|
|
|
viewer.removeHandler('full-page', checkEnteringFullPage);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(event.fullPage, 'Switched to fullpage');
|
|
|
|
assert.ok(viewer.isFullPage(), 'Enabled fullpage');
|
|
|
|
assert.ok($(viewer.element).hasClass('fullpage'),
|
2013-11-02 01:37:19 +04:00
|
|
|
'Fullpage class added to div');
|
|
|
|
|
|
|
|
var checkExitingPreFullPage = function(event) {
|
|
|
|
viewer.removeHandler('pre-full-page', checkExitingPreFullPage);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!event.fullPage, 'Exiting fullpage');
|
|
|
|
assert.ok(viewer.isFullPage(), 'Still fullpage');
|
2013-11-02 01:37:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
var checkExitingFullPage = function(event) {
|
|
|
|
viewer.removeHandler('full-page', checkExitingFullPage);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!event.fullPage, 'Exiting fullpage');
|
|
|
|
assert.ok(!viewer.isFullPage(), 'Disabled fullpage');
|
|
|
|
assert.ok(!$(viewer.element).hasClass('fullpage'),
|
2013-11-02 01:37:19 +04:00
|
|
|
'Fullpage class removed from div');
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2013-11-02 01:37:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler("pre-full-page", checkExitingPreFullPage);
|
|
|
|
viewer.addHandler("full-page", checkExitingFullPage);
|
|
|
|
viewer.setFullPage(false);
|
|
|
|
};
|
|
|
|
viewer.addHandler("pre-full-page", checkEnteringPreFullPage);
|
|
|
|
viewer.addHandler("full-page", checkEnteringFullPage);
|
|
|
|
viewer.setFullPage(true);
|
2013-07-02 02:17:45 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-05-14 06:35:27 +04:00
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('FullScreen', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-11-03 05:01:04 +04:00
|
|
|
if (!OpenSeadragon.supportsFullScreen) {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.expect(0);
|
|
|
|
done();
|
2013-11-03 05:01:04 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewer.addHandler("open", function () {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Started out not fullscreen');
|
2013-11-03 05:01:04 +04:00
|
|
|
|
|
|
|
var checkEnteringPreFullScreen = function(event) {
|
|
|
|
viewer.removeHandler('pre-full-screen', checkEnteringPreFullScreen);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(event.fullScreen, 'Switching to fullscreen');
|
|
|
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Not yet fullscreen');
|
2013-11-03 05:01:04 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// The fullscreen mode is always denied during tests so we are
|
|
|
|
// exiting directly.
|
|
|
|
var checkExitingFullScreen = function(event) {
|
|
|
|
viewer.removeHandler('full-screen', checkExitingFullScreen);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!event.fullScreen, 'Exiting fullscreen');
|
|
|
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Disabled fullscreen');
|
|
|
|
done();
|
2013-11-03 05:01:04 +04:00
|
|
|
};
|
|
|
|
viewer.addHandler("pre-full-screen", checkEnteringPreFullScreen);
|
|
|
|
viewer.addHandler("full-screen", checkExitingFullScreen);
|
|
|
|
viewer.setFullScreen(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
|
|
|
});
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Close', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler("open", function () {
|
|
|
|
var closeHandler = function() {
|
|
|
|
viewer.removeHandler('close', closeHandler);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!viewer.source, 'no source');
|
|
|
|
assert.ok(true, 'Close event was sent');
|
2013-07-02 02:17:45 +04:00
|
|
|
setTimeout(function() {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(!viewer._updateRequestId, 'timer is off');
|
|
|
|
done();
|
2013-07-02 02:17:45 +04:00
|
|
|
}, 100);
|
|
|
|
};
|
2013-03-07 23:52:01 +04:00
|
|
|
|
2013-07-02 02:17:45 +04:00
|
|
|
viewer.addHandler('close', closeHandler);
|
|
|
|
viewer.close();
|
|
|
|
});
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
2013-03-07 23:52:01 +04:00
|
|
|
});
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('Destroy', function(assert) {
|
|
|
|
var done = assert.async();
|
2013-08-12 10:38:37 +04:00
|
|
|
viewer.addHandler("open", function () {
|
|
|
|
// Check that the DOM has been modified
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.notEqual(0, $('#example').children().length);
|
2013-08-12 10:38:37 +04:00
|
|
|
|
2013-08-13 04:33:12 +04:00
|
|
|
var closeCalled = false;
|
2013-08-12 10:38:37 +04:00
|
|
|
var closeHandler = function() {
|
|
|
|
viewer.removeHandler('close', closeHandler);
|
2013-08-13 04:33:12 +04:00
|
|
|
closeCalled = true;
|
2013-08-12 10:38:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('close', closeHandler);
|
|
|
|
viewer.destroy();
|
|
|
|
|
|
|
|
// Check that the DOM has been cleaned up
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.equal(0, $('#example').children().length);
|
|
|
|
assert.equal(null, viewer.canvas);
|
|
|
|
assert.equal(null, viewer.keyboardCommandArea);
|
|
|
|
assert.equal(null, viewer.container);
|
|
|
|
assert.equal(null, viewer.element);
|
|
|
|
assert.equal(true, closeCalled);
|
2014-06-18 21:35:23 +04:00
|
|
|
viewer = null;
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2013-08-12 10:38:37 +04:00
|
|
|
});
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
|
|
|
});
|
|
|
|
|
2015-02-27 22:07:42 +03:00
|
|
|
|
|
|
|
// The Wikipedia logo has CORS enabled
|
|
|
|
var corsImg = 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png';
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test( 'CrossOriginPolicyMissing', function (assert) {
|
|
|
|
var done = assert.async();
|
2015-02-27 01:57:31 +03:00
|
|
|
viewer.crossOriginPolicy = false;
|
2015-11-05 17:19:56 +03:00
|
|
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
2015-02-27 01:57:31 +03:00
|
|
|
viewer.open( {
|
|
|
|
type: 'legacy-image-pyramid',
|
|
|
|
levels: [ {
|
2015-02-27 22:07:42 +03:00
|
|
|
url: corsImg,
|
2015-02-27 01:57:31 +03:00
|
|
|
width: 135,
|
|
|
|
height: 155
|
|
|
|
} ]
|
|
|
|
} );
|
2016-11-03 00:35:23 +03:00
|
|
|
viewer.addOnceHandler('tile-drawn', function() {
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
2015-11-05 01:49:13 +03:00
|
|
|
"Canvas should be tainted.");
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2015-02-27 01:57:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test( 'CrossOriginPolicyAnonymous', function (assert) {
|
|
|
|
var done = assert.async();
|
2019-07-18 03:02:40 +03:00
|
|
|
|
|
|
|
viewer.crossOriginPolicy = 'Anonymous';
|
|
|
|
viewer.open( {
|
|
|
|
type: 'legacy-image-pyramid',
|
|
|
|
levels: [ {
|
|
|
|
url: corsImg,
|
|
|
|
width: 135,
|
|
|
|
height: 155
|
|
|
|
} ]
|
|
|
|
} );
|
|
|
|
viewer.addOnceHandler('tile-drawn', function() {
|
|
|
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
|
|
"Canvas should not be tainted.");
|
|
|
|
done();
|
2015-02-27 01:57:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test( 'CrossOriginPolicyOption', function (assert) {
|
|
|
|
var done = assert.async();
|
2019-07-18 03:02:40 +03:00
|
|
|
|
|
|
|
viewer.crossOriginPolicy = "Anonymous";
|
|
|
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
|
|
|
viewer.addTiledImage( {
|
|
|
|
tileSource: {
|
|
|
|
type: 'legacy-image-pyramid',
|
|
|
|
levels: [ {
|
|
|
|
url: corsImg,
|
|
|
|
width: 135,
|
|
|
|
height: 155
|
|
|
|
} ]
|
|
|
|
},
|
|
|
|
crossOriginPolicy : false
|
|
|
|
} );
|
|
|
|
viewer.addOnceHandler('tile-drawn', function() {
|
|
|
|
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
|
|
"Canvas should be tainted.");
|
|
|
|
done();
|
2016-07-28 18:35:43 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test( 'CrossOriginPolicyTileSource', function (assert) {
|
|
|
|
var done = assert.async();
|
2019-07-18 03:02:40 +03:00
|
|
|
|
|
|
|
viewer.crossOriginPolicy = false;
|
|
|
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
|
|
|
viewer.addTiledImage( {
|
|
|
|
tileSource: {
|
|
|
|
type: 'legacy-image-pyramid',
|
|
|
|
levels: [ {
|
|
|
|
url: corsImg,
|
|
|
|
width: 135,
|
|
|
|
height: 155
|
|
|
|
} ],
|
|
|
|
crossOriginPolicy : "Anonymous"
|
2016-07-28 18:35:43 +03:00
|
|
|
}
|
2019-07-18 03:02:40 +03:00
|
|
|
} );
|
|
|
|
viewer.addOnceHandler('tile-drawn', function() {
|
|
|
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
|
|
"Canvas should not be tainted.");
|
|
|
|
done();
|
2016-07-28 18:35:43 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
} );
|
2017-01-07 19:38:38 +03:00
|
|
|
|
2017-06-19 23:29:41 +03:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('SetDebugMode', function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
assert.ok(viewer, 'Viewer exists');
|
2017-06-19 23:29:41 +03:00
|
|
|
|
|
|
|
var checkImageTilesDebugState = function (expectedState) {
|
|
|
|
|
|
|
|
for (var i = 0; i < viewer.world.getItemCount(); i++) {
|
|
|
|
if(viewer.world.getItemAt(i).debugMode != expectedState) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
var openHandler = function(event) {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
|
|
|
|
//Ensure we start with debug mode turned off
|
|
|
|
viewer.setDebugMode(false);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(checkImageTilesDebugState(false), "All image tiles have debug mode turned off.");
|
|
|
|
assert.ok(!viewer.debugMode, "Viewer debug mode is turned off.");
|
2017-06-19 23:29:41 +03:00
|
|
|
|
|
|
|
//Turn debug mode on and check that the Viewer and all tiled images are in debug mode.
|
|
|
|
viewer.setDebugMode(true);
|
2017-12-02 03:51:13 +03:00
|
|
|
assert.ok(checkImageTilesDebugState(true), "All image tiles have debug mode turned on.");
|
|
|
|
assert.ok(viewer.debugMode, "Viewer debug mode is turned on.");
|
2017-06-19 23:29:41 +03:00
|
|
|
|
2017-12-02 03:51:13 +03:00
|
|
|
done();
|
2017-06-19 23:29:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
viewer.open('/test/data/testpattern.dzi');
|
|
|
|
});
|
|
|
|
|
2017-06-21 00:30:58 +03:00
|
|
|
//Version numbers are injected by the build process, so skip version tests if we are only running code coverage
|
|
|
|
if(!window.isCoverageTest ){
|
2017-12-02 03:51:13 +03:00
|
|
|
QUnit.test('version object', function(assert) {
|
|
|
|
assert.equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string");
|
|
|
|
assert.ok(OpenSeadragon.version.major >= 0, "major should be a positive number");
|
|
|
|
assert.ok(OpenSeadragon.version.minor >= 0, "minor should be a positive number");
|
|
|
|
assert.ok(OpenSeadragon.version.revision >= 0, "revision should be a positive number");
|
2017-06-21 00:30:58 +03:00
|
|
|
});
|
|
|
|
}
|
2013-02-14 22:21:07 +04:00
|
|
|
})();
|