From 9d51e534da480751a91a20ab51d81d739d9b3025 Mon Sep 17 00:00:00 2001 From: Gilles Dubuc Date: Wed, 16 Apr 2014 13:58:18 +0200 Subject: [PATCH] Fix bug when exiting Media Viewer while image is loading Which would cause the image to never appear, even when reopening Media Viewer. The source of the issue was an uncaught exception in ThumbnailWidth. Unfortunately this cannot be covered by E2E because the image loads too fast in that context, and cucumber/selenium doesn't have time to catch the placeholder. Change-Id: I9386f6e857a7974166ddb5eeb7ea731d943eddcf Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/450 --- resources/mmv/mmv.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js index fb38bb54a..eba3dd9ad 100755 --- a/resources/mmv/mmv.js +++ b/resources/mmv/mmv.js @@ -499,6 +499,12 @@ this.thumbnailPreloadQueue = this.pushLightboxImagesIntoQueue( function( lightboxImage ) { return function() { + // viewer.ui.canvas.getLightboxImageWidths needs the viewer to be open + // because it needs to read the size of visible elements + if ( !viewer.isOpen ) { + return; + } + return viewer.fetchThumbnailForLightboxImage( lightboxImage, viewer.ui.canvas.getLightboxImageWidths( lightboxImage ).real