mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 16:16:08 +03:00
Catch rejected Promise on failed fullscreen request
Add a `catch()` rejection of request for fullscreen (standard Fullscreen API implementation), as well as fullscreen exit. For now there is no actual handling, but we send a message to the internal error channel. Motivation: The fullscreen request was causing certain tests to fail when run with newer versions of QUnit (starting in 2.5.0), which now fails tests that have unhandled Promise rejections (as we did here). The exit case is not currently covered by tests, but works the same way (also returns a promise). See: https://fullscreen.spec.whatwg.org/#ref-for-dom-element-requestfullscreen%E2%91%A0
This commit is contained in:
parent
ad1179b9db
commit
c7df7be7f1
@ -67,10 +67,14 @@
|
||||
return document.fullscreenElement;
|
||||
};
|
||||
fullScreenApi.requestFullScreen = function( element ) {
|
||||
return element.requestFullscreen();
|
||||
return element.requestFullscreen().catch(function (msg) {
|
||||
$.console.error('Fullscreen request failed: ', msg);
|
||||
});
|
||||
};
|
||||
fullScreenApi.exitFullScreen = function() {
|
||||
document.exitFullscreen();
|
||||
document.exitFullscreen().catch(function (msg) {
|
||||
$.console.error('Error while exiting fullscreen: ', msg);
|
||||
});
|
||||
};
|
||||
fullScreenApi.fullScreenEventName = "fullscreenchange";
|
||||
fullScreenApi.fullScreenErrorEventName = "fullscreenerror";
|
||||
|
@ -224,7 +224,7 @@
|
||||
});
|
||||
|
||||
QUnit.test('FullScreen', function(assert) {
|
||||
var done = assert.async();
|
||||
const done = assert.async();
|
||||
if (!OpenSeadragon.supportsFullScreen) {
|
||||
assert.expect(0);
|
||||
done();
|
||||
@ -234,7 +234,7 @@
|
||||
viewer.addHandler("open", function () {
|
||||
assert.ok(!OpenSeadragon.isFullScreen(), 'Started out not fullscreen');
|
||||
|
||||
var checkEnteringPreFullScreen = function(event) {
|
||||
const checkEnteringPreFullScreen = function(event) {
|
||||
viewer.removeHandler('pre-full-screen', checkEnteringPreFullScreen);
|
||||
assert.ok(event.fullScreen, 'Switching to fullscreen');
|
||||
assert.ok(!OpenSeadragon.isFullScreen(), 'Not yet fullscreen');
|
||||
@ -242,7 +242,7 @@
|
||||
|
||||
// The fullscreen mode is always denied during tests so we are
|
||||
// exiting directly.
|
||||
var checkExitingFullScreen = function(event) {
|
||||
const checkExitingFullScreen = function(event) {
|
||||
viewer.removeHandler('full-screen', checkExitingFullScreen);
|
||||
assert.ok(!event.fullScreen, 'Exiting fullscreen');
|
||||
assert.ok(!OpenSeadragon.isFullScreen(), 'Disabled fullscreen');
|
||||
|
Loading…
Reference in New Issue
Block a user