LibWeb: Add test ensuring re-exported Wasm memories equal the import

If a memory is imported by a Wasm instance and re-exported, the export's
value should be the exact same WebAssembly.Memory object as the
WebAssembly.Memory object passed for the import.
This commit is contained in:
CountBleck 2025-08-18 21:32:52 -07:00 committed by Ali Mohammad Pur
commit 826eb68ecd
Notes: github-actions[bot] 2025-08-23 06:27:45 +00:00
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1 @@
Re-exported memory equals imported memory: true

View file

@ -0,0 +1,20 @@
<!doctype html>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
// (module
// (import "env" "memory" (memory $mem 1))
// (export "memory" (memory $mem))
// )
const WASM_URL =
"data:application/wasm;base64,AGFzbQEAAAACDwEDZW52Bm1lbW9yeQIAAQcKAQZtZW1vcnkCAA==";
const memory = new WebAssembly.Memory({ initial: 1 });
const {
instance: { exports },
} = await WebAssembly.instantiateStreaming(fetch(WASM_URL), { env: { memory } });
println(`Re-exported memory equals imported memory: ${memory === exports.memory}`);
done();
});
</script>