diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/wasm/webapi/esm-integration | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/wasm/webapi/esm-integration')
51 files changed, 382 insertions, 0 deletions
diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html new file mode 100644 index 0000000000..a35adbe8eb --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<title>Check execution of WebAssembly start function</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + const test_load = async_test( + "Importing a WebAssembly module should execute the start function."); + + window.log = []; + window.addEventListener("error", ev => { + log.push(ev.message); + }); + + window.addEventListener("load", test_load.step_func_done(ev => { + assert_array_equals(log, ["executed"]); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/execute-start.wasm" onerror="unreachable()""></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html new file mode 100644 index 0000000000..16a9c59787 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>Exported names from a WebAssembly module</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +import * as mod from "./resources/exported-names.wasm"; +assert_array_equals(Object.getOwnPropertyNames(mod).sort(), + ["func", "glob", "mem", "tab"]); +assert_true(mod.func instanceof Function); +assert_true(mod.mem instanceof WebAssembly.Memory); +assert_true(mod.glob instanceof WebAssembly.Global); +assert_true(mod.tab instanceof WebAssembly.Table); +assert_throws_js(TypeError, () => { mod.func = 2; }); +done(); +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html new file mode 100644 index 0000000000..0e447dbee5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>Handling of importing invalid WebAssembly modules</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + window.log = []; + + window.addEventListener("error", ev => log.push(ev.error)); + + const test_load = async_test( + "Test that imports of invalid WebAssembly modules leads to WebAssembly.CompileError on window."); + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log.length, 2); + assert_equals(log[0].constructor, WebAssembly.CompileError); + assert_equals(log[1].constructor, WebAssembly.CompileError); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/invalid-bytecode.wasm" onerror="unreachable()"></script> +<script type="module" src="./resources/invalid-module.wasm" onerror="unreachable()"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html new file mode 100644 index 0000000000..f45e06ece5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html @@ -0,0 +1,38 @@ +<!doctype html> +<title>Cyclic linking between JavaScript and WebAssembly (JS higher)</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + const test_load = async_test( + "Check cyclic linking between JavaScript and WebAssembly where JavaScript is higher in the module graph."); + + window.log = []; + window.addEventListener("error", ev => { + test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError)); + log.push(ev.message); + }); + + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log.length, 10); + assert_equals(log[1], 1); + assert_equals(log[3], 2); + assert_equals(log[5], 3); + assert_equals(log[7], 4); + assert_equals(log[9], 5); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/js-wasm-cycle-value.js" + onerror="unreachable()" onload="log.push(1)"></script> +<script type="module" src="./resources/js-wasm-cycle-global.js" + onerror="unreachable()" onload="log.push(2)"></script> +<script type="module" src="./resources/js-wasm-cycle-memory.js" + onerror="unreachable()" onload="log.push(3)"></script> +<script type="module" src="./resources/js-wasm-cycle-table.js" + onerror="unreachable()" onload="log.push(4)"></script> +<script type="module" src="./resources/js-wasm-cycle-function-error.js" + onerror="unreachable()" onload="log.push(5)"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html new file mode 100644 index 0000000000..38b0d3203c --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>Check bindings in JavaScript and WebAssembly cycle (JS higher)</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +import { f } from "./resources/js-wasm-cycle.js"; +assert_equals(f(), 24); +done(); +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html new file mode 100644 index 0000000000..0e447dbee5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>Handling of importing invalid WebAssembly modules</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + window.log = []; + + window.addEventListener("error", ev => log.push(ev.error)); + + const test_load = async_test( + "Test that imports of invalid WebAssembly modules leads to WebAssembly.CompileError on window."); + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log.length, 2); + assert_equals(log[0].constructor, WebAssembly.CompileError); + assert_equals(log[1].constructor, WebAssembly.CompileError); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/invalid-bytecode.wasm" onerror="unreachable()"></script> +<script type="module" src="./resources/invalid-module.wasm" onerror="unreachable()"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js new file mode 100644 index 0000000000..e0dcf493f8 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js @@ -0,0 +1 @@ +export { f } from "./resources/resolve-export.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html new file mode 100644 index 0000000000..1468822102 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<title>Check ResolveExport on invalid re-export from WebAssembly</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + const test_load = async_test( + "Re-export of missing Wasm export should result in SyntaxError."); + + window.log = []; + window.addEventListener("error", ev => { + test_load.step(() => assert_equals(ev.error.constructor, SyntaxError)); + log.push(ev.message); + }); + + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log[1], 1); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resolve-export.js" + onerror="unreachable()" onload="log.push(1)"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm Binary files differnew file mode 100644 index 0000000000..ecfdda1f9a --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm Binary files differnew file mode 100644 index 0000000000..ebffad193c --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm Binary files differnew file mode 100644 index 0000000000..1ae8b721f3 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm Binary files differnew file mode 100644 index 0000000000..dd711f0953 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js new file mode 100644 index 0000000000..06cb8a0ad9 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js @@ -0,0 +1,2 @@ +export const func = 42; +import { f } from "./js-wasm-cycle-function-error.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm Binary files differnew file mode 100644 index 0000000000..b89d94dde7 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js new file mode 100644 index 0000000000..1f375b8ce1 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js @@ -0,0 +1,2 @@ +export const glob = new WebAssembly.Global({ value: "i32" }, 42); +import { f } from "./js-wasm-cycle-global.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm Binary files differnew file mode 100644 index 0000000000..2a9017f87b --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js new file mode 100644 index 0000000000..92e37a86ac --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js @@ -0,0 +1,2 @@ +export const mem = new WebAssembly.Memory({ initial: 10 }); +import { f } from "./js-wasm-cycle-memory.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm Binary files differnew file mode 100644 index 0000000000..e699a9b3c4 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js new file mode 100644 index 0000000000..5d6794489f --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js @@ -0,0 +1,2 @@ +export const tab = new WebAssembly.Table({ element: "anyfunc" }); +import { f } from "./js-wasm-cycle-table.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm Binary files differnew file mode 100644 index 0000000000..ec4883e652 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js new file mode 100644 index 0000000000..f7b0d62080 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js @@ -0,0 +1,2 @@ +export const val = 42; +import { f } from "./js-wasm-cycle-value.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm Binary files differnew file mode 100644 index 0000000000..083409e260 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js new file mode 100644 index 0000000000..8ee579e2ad --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js @@ -0,0 +1,13 @@ +function f() { return 42; } +export { f }; + +import { mem, tab, glob, func } from "./js-wasm-cycle.wasm"; +assert_true(glob instanceof WebAssembly.Global); +assert_equals(glob.valueOf(), 1); +assert_true(mem instanceof WebAssembly.Memory); +assert_true(tab instanceof WebAssembly.Table); +assert_true(func instanceof Function); + +f = () => { return 24 }; + +assert_equals(func(), 42); diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm Binary files differnew file mode 100644 index 0000000000..77a3b86ab6 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js new file mode 100644 index 0000000000..0c4f5ed519 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js @@ -0,0 +1 @@ +export function logExec() { log.push("executed"); } diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm Binary files differnew file mode 100644 index 0000000000..d8fc92d022 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm Binary files differnew file mode 100644 index 0000000000..f9f0cf2799 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm Binary files differnew file mode 100644 index 0000000000..0ee948f96f --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm Binary files differnew file mode 100644 index 0000000000..c27bcb068d --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm Binary files differnew file mode 100644 index 0000000000..652ff14310 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js new file mode 100644 index 0000000000..78982c32dc --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js @@ -0,0 +1 @@ +export let f = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm Binary files differnew file mode 100644 index 0000000000..2f23c58520 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js new file mode 100644 index 0000000000..4258cd2d7d --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js @@ -0,0 +1 @@ +export let g = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm Binary files differnew file mode 100644 index 0000000000..2f8bd77940 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js new file mode 100644 index 0000000000..4cee889838 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js @@ -0,0 +1 @@ +export let m = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm Binary files differnew file mode 100644 index 0000000000..d9474047cd --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js new file mode 100644 index 0000000000..ca823646cb --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js @@ -0,0 +1 @@ +export let t = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm Binary files differnew file mode 100644 index 0000000000..8ccc8be7f2 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js new file mode 100644 index 0000000000..161edab4f6 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js @@ -0,0 +1,15 @@ +import * as mod from "./wasm-js-cycle.wasm"; + +let jsGlob = new WebAssembly.Global({ value: "i32", mutable: true }, 42); +let jsMem = new WebAssembly.Memory({ initial: 10 }); +let jsTab = new WebAssembly.Table({ initial: 10, element: "anyfunc" }); +let jsFunc = () => { return 42; }; + +export { jsGlob, jsMem, jsTab, jsFunc }; + +export function mutateBindings() { + jsGlob = 0; + jsMem = 0; + jsTab = 0; + jsFunc = 0; +} diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm Binary files differnew file mode 100644 index 0000000000..b700377b27 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js new file mode 100644 index 0000000000..277bb4c1ea --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js @@ -0,0 +1 @@ +export function pm(x) { postMessage(x); } diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-source-phase.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-source-phase.js new file mode 100644 index 0000000000..c7a4f0d437 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-source-phase.js @@ -0,0 +1,3 @@ +import source modSource from "./worker.wasm"; +assert_true(modSource instanceof WebAssembly.Module); +assert_true(await import.source("./worker.wasm") === modSource); diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js new file mode 100644 index 0000000000..1163e477fd --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js @@ -0,0 +1,2 @@ +import * as mod from "./worker.wasm"; +assert_true(await import("./worker.wasm") === mod); diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm Binary files differnew file mode 100644 index 0000000000..e942dc54ac --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/source-phase.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/source-phase.tentative.html new file mode 100644 index 0000000000..eb415a4c6f --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/source-phase.tentative.html @@ -0,0 +1,35 @@ +<!doctype html> +<title>Source phase imports</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); + +import source exportedNamesSource from "./resources/exported-names.wasm"; + +assert_true(exportedNamesSource instanceof WebAssembly.Module); +const AbstractModuleSource = Object.getPrototypeOf(WebAssembly.Module); +assert_equals(AbstractModuleSource.name, "AbstractModuleSource"); +assert_true(exportedNamesSource instanceof AbstractModuleSource); + +assert_array_equals(WebAssembly.Module.exports(exportedNamesSource).sort(), + ["func", "glob", "mem", "tab"]); + +const wasmImportFromWasmSource = await import.source("./resources/wasm-import-from-wasm.wasm"); + +assert_true(wasmImportFromWasmSource instanceof WebAssembly.Module); + +let logged = false; +const instance = await WebAssembly.instantiate(wasmImportFromWasmSource, { + "./wasm-export-to-wasm.wasm": { + log () { + logged = true; + } + } +}); +instance.exports.logExec(); +assert_true(logged); + +done(); +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html new file mode 100644 index 0000000000..3761a22f21 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Check import and export between WebAssembly modules</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +window.log = []; +import { logExec } from "./resources/wasm-import-from-wasm.wasm"; +logExec(); +assert_equals(log.length, 1); +assert_equals(log[0], "executed"); +done(); +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html new file mode 100644 index 0000000000..243cfd46e4 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html @@ -0,0 +1,34 @@ +<!doctype html> +<title>Errors for imports of WebAssembly modules</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + const test_load = async_test( + "Invalid imports for WebAssembly modules should error."); + + window.log = []; + window.addEventListener("error", ev => { + test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError)); + log.push(ev.message); + }); + + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log[1], 1); + assert_equals(log[3], 2); + assert_equals(log[5], 3); + assert_equals(log[7], 4); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/wasm-import-func.wasm" + onerror="unreachable()" onload="log.push(1)"></script> +<script type="module" src="./resources/wasm-import-memory.wasm" + onerror="unreachable()" onload="log.push(2)"></script> +<script type="module" src="./resources/wasm-import-table.wasm" + onerror="unreachable()" onload="log.push(3)"></script> +<script type="module" src="./resources/wasm-import-global.wasm" + onerror="unreachable()" onload="log.push(4)"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html new file mode 100644 index 0000000000..298d4d40b0 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>Check bindings in JavaScript and WebAssembly cycle (Wasm higher)</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +import * as wasm from "./resources/wasm-js-cycle.wasm"; +import * as js from "./resources/wasm-js-cycle.js"; + +js.mutateBindings(); + +assert_true(wasm.wasmGlob instanceof WebAssembly.Global); +assert_equals(wasm.wasmGlob.valueOf(), 24); + +assert_true(wasm.wasmFunc instanceof Function); +assert_equals(wasm.wasmFunc(), 43); + +assert_equals(wasm.incrementGlob(), 43); + +const buf = new Int32Array(wasm.wasmMem.buffer); +assert_equals(buf[0], 0); +assert_equals(wasm.mutateMem(), 42); +assert_equals(buf[0], 42); + +assert_equals(wasm.wasmTab.get(0), null); +const ref = wasm.mutateTab(); +assert_true(ref instanceof Function); +assert_equals(wasm.wasmTab.get(0), ref); + +done(); +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html new file mode 100644 index 0000000000..6c43e72b09 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>Errors for linking WebAssembly module scripts</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + setup({allow_uncaught_exception: true}); + + const test_load = async_test( + "Link errors for imports between WebAssembly modules should be reported."); + + window.log = []; + window.addEventListener("error", ev => { + test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError)); + log.push(ev.message); + }); + + window.addEventListener("load", test_load.step_func_done(ev => { + assert_equals(log.length, 2); + assert_equals(log[1], 1); + })); + + function unreachable() { log.push("unexpected"); } +</script> +<script type="module" src="./resources/wasm-import-error-from-wasm.wasm" + onerror="unreachable()" onload="log.push(1)"></script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html new file mode 100644 index 0000000000..739f2d3f28 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<title>Testing import of WebAssembly from JavaScript worker</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +const worker = new Worker("resources/worker.js", { type: "module" }); +worker.onmessage = (msg) => { + assert_equals(msg.data, 42); + done(); +} +</script> diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html new file mode 100644 index 0000000000..6145dd04ff --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<title>Testing WebAssembly worker</title> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script type=module> +setup({ single_test: true }); +const worker = new Worker("resources/worker.wasm", { type: "module" }); +worker.onmessage = (msg) => { + assert_equals(msg, 42); + done(); +} +worker.onerror = () => { + assert_unreached("worker got an error"); +} +</script> |