LibWeb: Add a basic test for [EnforceRange]

This is a basic test - but does cover the two bugs in the previous
two commits.
This commit is contained in:
Shannon Booth 2024-03-29 17:48:51 +01:00 committed by Andreas Kling
parent 7abedd2fed
commit 9dc2b0bba3
Notes: sideshowbarker 2024-07-17 03:00:02 +09:00
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,3 @@
Made memory [object WebAssembly.Memory] with buffer [object ArrayBuffer] (byteLength 655360)
After growing buffer (byteLength 983040)
Got error: 'RangeError: Number '4294967296' is outside of allowed range of 0 to 4294967295'

View file

@ -0,0 +1,19 @@
<script src="../include.js"></script>
<script>
test(() => {
const memory = new WebAssembly.Memory({
initial: 10,
maximum: 100,
});
println(`Made memory ${memory} with buffer ${memory.buffer} (byteLength ${memory.buffer.byteLength})`);
memory.grow(5);
println(`After growing buffer (byteLength ${memory.buffer.byteLength})`);
try {
memory.grow(4294967296); // 1 over max value.
} catch (e) {
println(`Got error: '${e}'`);
}
});
</script>