From a1965aafeabd95ed7507a7a687a11d0674ee5011 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Sat, 11 Jun 2022 18:04:07 +0100 Subject: [PATCH] refactor(tests): Use bootstrap instead of uncompressed in generator tests This entails adding an additional check in bootstrap so as to load uncompressed when loading from a file: URL, since these are not localhost URLs - though in fact the generator tests run equally well in compressed mode, albeit against (for now) the previously-check-in build products rather than the live code. --- tests/bootstrap.js | 4 ++- tests/generators/index.html | 58 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/tests/bootstrap.js b/tests/bootstrap.js index 0310b32bf..32003eecf 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -39,12 +39,14 @@ const isIe = navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > -1; const localhosts = ['localhost', '127.0.0.1', '[::1]']; + const isLocalhost = localhosts.includes(location.hostname); + const isFileUrl = location.origin === 'file://'; // Default bootstrap options. const options = { // Decide whether to use compmiled mode or not. Please see issue // #5557 for more information. - loadCompressed: isIe || !localhosts.includes(location.hostname), + loadCompressed: isIe || !(isLocalhost || isFileUrl), // URL of the blockly repository. This is needed for a few reasons: // diff --git a/tests/generators/index.html b/tests/generators/index.html index 9e37f05b6..49a9d5f9d 100644 --- a/tests/generators/index.html +++ b/tests/generators/index.html @@ -3,41 +3,36 @@ Blockly Generator Tests - - - - - - - - - + + - +