| Index: test/mjsunit/wasm/memory.js
|
| diff --git a/test/mjsunit/wasm/memory.js b/test/mjsunit/wasm/memory.js
|
| index a90d44c41ad8607c166d853ea69be316f7e7f8b4..e86825bd27c7000a88c047e5b392d1e9e386b377 100644
|
| --- a/test/mjsunit/wasm/memory.js
|
| +++ b/test/mjsunit/wasm/memory.js
|
| @@ -8,6 +8,13 @@
|
|
|
| var outOfUint32RangeValue = 1e12;
|
|
|
| +function assertMemoryIsValid(memory) {
|
| + assertSame(WebAssembly.Memory.prototype, memory.__proto__);
|
| + assertSame(WebAssembly.Memory, memory.constructor);
|
| + assertTrue(memory instanceof Object);
|
| + assertTrue(memory instanceof WebAssembly.Memory);
|
| +}
|
| +
|
| (function TestConstructor() {
|
| assertTrue(WebAssembly.Memory instanceof Function);
|
| assertSame(WebAssembly.Memory, WebAssembly.Memory.prototype.constructor);
|
| @@ -28,18 +35,53 @@ var outOfUint32RangeValue = 1e12;
|
| assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 9}), RangeError);
|
|
|
| let memory = new WebAssembly.Memory({initial: 1});
|
| - assertSame(WebAssembly.Memory.prototype, memory.__proto__);
|
| - assertSame(WebAssembly.Memory, memory.constructor);
|
| - assertTrue(memory instanceof Object);
|
| - assertTrue(memory instanceof WebAssembly.Memory);
|
| + assertMemoryIsValid(memory);
|
| })();
|
|
|
| (function TestConstructorWithMaximum() {
|
| let memory = new WebAssembly.Memory({initial: 1, maximum: 10});
|
| - assertSame(WebAssembly.Memory.prototype, memory.__proto__);
|
| - assertSame(WebAssembly.Memory, memory.constructor);
|
| - assertTrue(memory instanceof Object);
|
| - assertTrue(memory instanceof WebAssembly.Memory);
|
| + assertMemoryIsValid(memory);
|
| +})();
|
| +
|
| +(function TestInitialIsUndefined() {
|
| + // New memory with initial = undefined, which means initial = 0.
|
| + let memory = new WebAssembly.Memory({initial: undefined});
|
| + assertMemoryIsValid(memory);
|
| +})();
|
| +
|
| +(function TestMaximumIsUndefined() {
|
| + // New memory with maximum = undefined, which means maximum = 0.
|
| + let memory = new WebAssembly.Memory({initial: 0, maximum: undefined});
|
| + assertMemoryIsValid(memory);
|
| +})();
|
| +
|
| +(function TestMaximumIsReadOnce() {
|
| + var a = true;
|
| + var desc = {initial: 10};
|
| + Object.defineProperty(desc, 'maximum', {get: function() {
|
| + if (a) {
|
| + a = false;
|
| + return 16;
|
| + }
|
| + else {
|
| + // Change the return value on the second call so it throws.
|
| + return -1;
|
| + }
|
| + }});
|
| + let memory = new WebAssembly.Memory(desc);
|
| + assertMemoryIsValid(memory);
|
| +})();
|
| +
|
| +(function TestMaximumDoesHasProperty() {
|
| + var hasPropertyWasCalled = false;
|
| + var desc = {initial: 10};
|
| + var proxy = new Proxy({maximum: 16}, {
|
| + has: function(target, name) { hasPropertyWasCalled = true; }
|
| + });
|
| + Object.setPrototypeOf(desc, proxy);
|
| + let memory = new WebAssembly.Memory(desc);
|
| + assertMemoryIsValid(memory);
|
| + assertTrue(hasPropertyWasCalled);
|
| })();
|
|
|
| (function TestBuffer() {
|
|
|