From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/modules/dynamic-import-script.js | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/src/jit-test/tests/modules/dynamic-import-script.js (limited to 'js/src/jit-test/tests/modules/dynamic-import-script.js') diff --git a/js/src/jit-test/tests/modules/dynamic-import-script.js b/js/src/jit-test/tests/modules/dynamic-import-script.js new file mode 100644 index 0000000000..e6986a42ec --- /dev/null +++ b/js/src/jit-test/tests/modules/dynamic-import-script.js @@ -0,0 +1,45 @@ +function testImport(path, name, value) { + let result = null; + let error = null; + let promise = import(path); + promise.then((ns) => { + result = ns; + }).catch((e) => { + error = e; + }); + + drainJobQueue(); + assertEq(error, null); + assertEq(result[name], value); +} + +// Resolved via module load path. +testImport("module1.js", "a", 1); + +// Relative path resolved relative to this script. +testImport("../../modules/module1a.js", "a", 2); + +// Import inside function. +function f() { + testImport("../../modules/module2.js", "b", 2); +} +f(); + +// Import inside eval. +eval(`testImport("../../modules/module3.js", "c", 3)`); + +// Import inside indirect eval. +const indirect = eval; +const defineTestFunc = testImport.toString(); +indirect(defineTestFunc + `testImport("../../modules/module3.js");`); + +// Import inside dynamic function. +Function(defineTestFunc + `testImport("../../modules/module3.js");`)(); + +// Import in eval in promise handler. +let ran = false; +Promise + .resolve(`import("../../modules/module3.js").then(() => { ran = true; })`) + .then(eval) +drainJobQueue(); +assertEq(ran, true); -- cgit v1.2.3