summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/esm-integration
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/wasm/webapi/esm-integration')
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-source-phase.js7
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/script-src-allows-wasm.tentative.html21
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/script-src-blocks-wasm.tentative.html21
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/source-phase.tentative.html2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/worker-import-source-phase.tentative.html13
5 files changed, 63 insertions, 1 deletions
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
index c7a4f0d437..e1c2703899 100644
--- 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
@@ -1,3 +1,10 @@
import source modSource from "./worker.wasm";
+import { pm } from "./worker-helper.js";
assert_true(modSource instanceof WebAssembly.Module);
assert_true(await import.source("./worker.wasm") === modSource);
+
+await WebAssembly.instantiate(modSource, {
+ "./worker-helper.js": {
+ "pm": pm
+ }
+}); \ No newline at end of file
diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-allows-wasm.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-allows-wasm.tentative.html
new file mode 100644
index 0000000000..07faf9a5a1
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-allows-wasm.tentative.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<title>script-src allows Wasm execution</title>
+<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">
+<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 be allowed by script-src CSP.");
+
+ window.log = [];
+ document.addEventListener("securitypolicyviolation", (e) => {
+ window.log.push(e.violatedDirective);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_array_equals(log, ["executed"]);
+ }));
+</script>
+<script type="module" src="./resources/execute-start.wasm"></script>
diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-blocks-wasm.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-blocks-wasm.tentative.html
new file mode 100644
index 0000000000..c1232730ea
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/script-src-blocks-wasm.tentative.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<title>script-src blocks Wasm execution</title>
+<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline';">
+<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 be guarded by script-src CSP.");
+
+ window.log = [];
+ document.addEventListener("securitypolicyviolation", (e) => {
+ window.log.push(e.violatedDirective);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_array_equals(log, ["script-src-elem"]);
+ }));
+</script>
+<script type="module" src="./resources/execute-start.wasm"></script>
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
index eb415a4c6f..870b16bd0a 100644
--- 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
@@ -13,7 +13,7 @@ const AbstractModuleSource = Object.getPrototypeOf(WebAssembly.Module);
assert_equals(AbstractModuleSource.name, "AbstractModuleSource");
assert_true(exportedNamesSource instanceof AbstractModuleSource);
-assert_array_equals(WebAssembly.Module.exports(exportedNamesSource).sort(),
+assert_array_equals(WebAssembly.Module.exports(exportedNamesSource).map(({ name }) => name).sort(),
["func", "glob", "mem", "tab"]);
const wasmImportFromWasmSource = await import.source("./resources/wasm-import-from-wasm.wasm");
diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import-source-phase.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import-source-phase.tentative.html
new file mode 100644
index 0000000000..e193f3efc6
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import-source-phase.tentative.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title>Testing import of WebAssembly source phase 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-source-phase.js", { type: "module" });
+worker.onmessage = (msg) => {
+ assert_equals(msg.data, 42);
+ done();
+}
+</script>