From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/wasm/utf8.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 js/src/jit-test/tests/wasm/utf8.js (limited to 'js/src/jit-test/tests/wasm/utf8.js') diff --git a/js/src/jit-test/tests/wasm/utf8.js b/js/src/jit-test/tests/wasm/utf8.js new file mode 100644 index 0000000000..fdda7ab0ca --- /dev/null +++ b/js/src/jit-test/tests/wasm/utf8.js @@ -0,0 +1,36 @@ +/* +(module + (func (param i32) (result i32) + (i32.add (local.get 0) (local.get 0))) + (export "hello" (func 0))) +*/ + +var txt = +`00 61 73 6d 01 00 00 00 01 06 01 60 01 7f 01 7f + 03 02 01 00 07 09 01 05 68 65 6c 6c 6f 00 00 0a + 09 01 07 00 20 00 20 00 6a 0b` + +var bin = new Uint8Array(txt.split(" ").map((x) => parseInt(x, 16))); +var mod = new WebAssembly.Module(bin); +var ins = new WebAssembly.Instance(mod); + +assertEq(ins.exports.hello(37), 2*37); + +assertEq(bin[25], 0x65); // the 'e' in 'hello' +bin[25] = 0x85; // bad UTF-8 + +assertEq(WebAssembly.validate(bin), false); + +assertThrowsInstanceOf(() => new WebAssembly.Module(bin), WebAssembly.CompileError); + +assertThrowsInstanceOf(() => wasmEvalText(`(module (import "\u2603" "" (func))) `, {}), TypeError); + +{ + let i1 = wasmEvalText(` (module (func (export "\u2603")))`); + assertThrowsInstanceOf(() => wasmEvalText(`(module (import "" "\u2603" (func (result i32))))`, + { "": { "\u2603": i1.exports['\u2603'] } }), + WebAssembly.LinkError); + assertThrowsInstanceOf(() => wasmEvalText(`(module (import "\u2603" "" (func (result i32))))`, + { "\u2603": { "": i1.exports['\u2603'] } }), + WebAssembly.LinkError); +} -- cgit v1.2.3