| <!DOCTYPE html><!-- webkit-test-runner [ jscOptions=--useSharedArrayBuffer=true ] --> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <script src="../../resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| description("Test cloning a shared WebAssembly.Memory that was declared with a maximum of zero. Such a memory has no shared contents at all, which the memory cost computation has to tolerate."); |
| |
| if (typeof WebAssembly !== 'undefined') { |
| zeroI32 = new WebAssembly.Memory({ initial: 0, maximum: 0, shared: true }); |
| shouldBe(`zeroI32.buffer.byteLength`, `0`); |
| cloneI32 = structuredClone(zeroI32); |
| shouldBeTrue(`cloneI32 instanceof WebAssembly.Memory`); |
| shouldBe(`cloneI32.buffer.byteLength`, `0`); |
| shouldBe(`cloneI32.grow(0)`, `0`); |
| |
| zeroI64 = new WebAssembly.Memory({ address: "i64", initial: 0n, maximum: 0n, shared: true }); |
| cloneI64 = structuredClone(zeroI64); |
| shouldBeTrue(`cloneI64 instanceof WebAssembly.Memory`); |
| shouldBe(`cloneI64.buffer.byteLength`, `0`); |
| shouldBe(`cloneI64.grow(0n)`, `0n`); |
| } |
| |
| </script> |
| </body> |
| </html> |