Merge "Back button doesn't close MediaViewer if the URL has a fragment with "/""

This commit is contained in:
jenkins-bot 2024-10-16 23:33:49 +00:00 committed by Gerrit Code Review
commit 525d333998
2 changed files with 20 additions and 2 deletions

View file

@ -706,8 +706,8 @@ class MultimediaViewer {
* Sets up the route handlers
*/
setupRouter() {
// handle empty hashes, and anchor links (page sections)
this.router.addRoute( /^[^/]*$/, () => {
// handle empty hashes, and anchor links (page sections, possibly including /)
this.router.addRoute( /.*$/, () => {
if ( this.isOpen ) {
comingFromHashChange = true;
document.title = this.createDocumentTitle( null );

View file

@ -450,6 +450,24 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
}
} );
QUnit.test( 'Viewer is closed then navigating to #foo/bar/baz (page section including slash)', function ( assert ) {
location.hash = '#/media/foo';
const viewer = getMultimediaViewer();
viewer.isOpen = true;
viewer.ui = undefined;
this.sandbox.stub( viewer, 'close' );
location.hash = '#foo/bar/baz';
// Wait for route event handler to execute
const done = assert.async();
setTimeout( () => {
assert.true( viewer.close.called, 'The viewer was closed' );
done();
}, 100 );
} );
QUnit.test( 'Refuse to load too-big thumbnails', ( assert ) => {
let expectedWidth;
const reuestedWidth = 1000;