From 9e69fa94912e7308c5c0201664e2c3c7c0066082 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 14 Jun 2022 23:00:27 +0100 Subject: [PATCH] refactor(tests): Rename blockly.mjs to bootstrap_done.mjs; simplify Since blockly.mjs is no longer returning just the exports object from core/blockly.js (see PR #5995), it might be better named after its actual purpose: to wait for bootstrapping to be done. Remove all the code that was used to pass the blockly.js exports object along from the bootstrap callback to the blockly.mjs export, since there's no reason to go to a lot of trouble to set a local variable named Blockly to the same value as a global variable named Blockly. (Something like this may be needed again in future, but certainly in a different form.) --- tests/bootstrap.js | 8 +++----- tests/{blockly.mjs => bootstrap_done.mjs} | 15 ++++++--------- tests/generators/index.html | 5 +++-- tests/mocha/index.html | 2 +- tests/multi_playground.html | 3 ++- tests/playground.html | 3 ++- tests/playgrounds/advanced_playground.html | 4 ++-- 7 files changed, 19 insertions(+), 21 deletions(-) rename tests/{blockly.mjs => bootstrap_done.mjs} (73%) diff --git a/tests/bootstrap.js b/tests/bootstrap.js index efa690616..6dc537c44 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -13,8 +13,8 @@ * uncompressed mode. * * You must use a \n'); } else { diff --git a/tests/blockly.mjs b/tests/bootstrap_done.mjs similarity index 73% rename from tests/blockly.mjs rename to tests/bootstrap_done.mjs index e447cd3c2..a4ee8818b 100644 --- a/tests/blockly.mjs +++ b/tests/bootstrap_done.mjs @@ -20,20 +20,17 @@ * * See tests/playground.html for example usage. */ - -let Blockly; - if (window.BlocklyLoader) { - // Uncompiled mode. Use top-level await + // Uncompressed mode. Use top-level await // (https://v8.dev/features/top-level-await) to block loading of // this module until goog.bootstrap()ping of Blockly is finished. await window.BlocklyLoader.done; - Blockly = globalThis.Blockly; + // Note that this module previously did an export default of the + // value returned by the BlocklyLoader.done promise. This was + // changed in PR #5995 because library blocks and generators cannot + // be accessed via that the core/blockly.js exports object. } else if (window.Blockly) { - // Compiled mode. Retrieve the pre-installed Blockly global. - Blockly = globalThis.Blockly; + // Compiled mode. Nothing more to do. } else { throw new Error('neither window.Blockly nor window.BlocklyLoader found'); } - -export default Blockly; diff --git a/tests/generators/index.html b/tests/generators/index.html index 49a9d5f9d..69badeed1 100644 --- a/tests/generators/index.html +++ b/tests/generators/index.html @@ -206,8 +206,9 @@ function changeIndex() { } diff --git a/tests/mocha/index.html b/tests/mocha/index.html index e63dc1f6a..10fe5ed45 100644 --- a/tests/mocha/index.html +++ b/tests/mocha/index.html @@ -180,7 +180,7 @@