From 085a237fe9afc2c1bea720bc180f27581296e3a3 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Tue, 18 Jan 2022 00:44:36 +0000 Subject: [PATCH] New attempt to prevent rogue iframe hiding Former-commit-id: 02db3ca825e59142ca010479d3ee741b83fb7b35 [formerly aba5699efaddb05832bbd2761df756e8d87f81c1] [formerly d133737bbd4841e2a9484c09beffcc3c6201eaee] [formerly 533e5bbeb4f58ee30493c8471c3c7d680999f300 [formerly 48bd548fadc00a610b4d9fe46af453ad3347c4ae [formerly 01b605c5274ab2b8fc5419955ba2dfe5fe615b68]]] Former-commit-id: cd09ac4a888b994f1c82ba98cf327b2fcbc6cb2f [formerly bb6deceae13c9755e590126884d98b92625ae78e [formerly 6cffde041e2589005c80498230d94b8de7d8adf2]] Former-commit-id: 415c4d92f2a6abecb2a089fd733f7e7d58e91363 [formerly 34202d1a7a71d0a084d1ae0faf9f458084b6fc8b] Former-commit-id: c246d8373b0f4aa54007867e88a739766927e702 --- www/js/app.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 635a8503..f887a5e4 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -3669,20 +3669,19 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett // hidden). Note that testing appstate.target is probably redundant for UWP because it will always // be iframe even if an external window is loaded... (but we probably need to do so for other cases) if (appstate.target === 'iframe') articleContainer.style.display = 'none'; - articleContainer.onload = function() { - articleLoadedSW(thisDirEntry); - }; + // articleContainer.onload = function() { + // articleLoadedSW(thisDirEntry); + // }; // New windows do not respect the onload event because they've been pre-populated, // so we have to simulate this event (note potential for race condition if timeout is too short) // NB The UWP app cannot control the opened window, so it can only be controlled by the Service Worker - if (/UWP/.test(params.appType)) { - setTimeout(function () { - articleContainer.style.display = 'block'; - }, 800); - setTimeout(function () { - $("#searchingArticles").hide(); - }, 2000); - } else { + setTimeout(function () { + if (appstate.target === 'iframe') articleContainer.style.display = 'block'; + }, 800); + setTimeout(function () { + $("#searchingArticles").hide(); + }, 2000); + if (!/UWP/.test(params.appType)) { setTimeout(function () { if (!loaded) articleLoadedSW(thisDirEntry); }, 400); @@ -3721,7 +3720,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett } else { messagePort.postMessage(message); } - } + }; // Let's read the content in the ZIM file if (/^(?:file:|chrome-extension)/i.test(window.location.protocol)) { // For Electron apps or Chrome extension, we have to access the cache app-side instead of SW-side