OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm --allow-natives-syntax | 5 // Flags: --expose-wasm --allow-natives-syntax |
6 | 6 |
7 if ((typeof drainJobQueue) != "function") { | 7 if ((typeof drainJobQueue) != "function") { |
8 drainJobQueue = () => { %RunMicrotasks() }; | 8 drainJobQueue = () => { %RunMicrotasks() }; |
9 } | 9 } |
10 | 10 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 assertErrorMessage(() => memGrow.call({}), TypeError, | 447 assertErrorMessage(() => memGrow.call({}), TypeError, |
448 /called on incompatible Object/); | 448 /called on incompatible Object/); |
449 assertErrorMessage(() => memGrow.call(mem1, -1), RangeError, | 449 assertErrorMessage(() => memGrow.call(mem1, -1), RangeError, |
450 /bad Memory grow delta/); | 450 /bad Memory grow delta/); |
451 assertErrorMessage(() => memGrow.call(mem1, Math.pow(2,32)), RangeError, | 451 assertErrorMessage(() => memGrow.call(mem1, Math.pow(2,32)), RangeError, |
452 /bad Memory grow delta/); | 452 /bad Memory grow delta/); |
453 var mem = new Memory({initial:1, maximum:2}); | 453 var mem = new Memory({initial:1, maximum:2}); |
454 var buf = mem.buffer; | 454 var buf = mem.buffer; |
455 assertEq(buf.byteLength, kPageSize); | 455 assertEq(buf.byteLength, kPageSize); |
456 assertEq(mem.grow(0), 1); | 456 assertEq(mem.grow(0), 1); |
457 // TODO(gdeepti): Pending spec clarification | 457 assertTrue(buf !== mem.buffer); |
458 // assertTrue(buf !== mem.buffer); | 458 assertEq(buf.byteLength, 0); |
459 // assertEq(buf.byteLength, 0); | |
460 buf = mem.buffer; | 459 buf = mem.buffer; |
461 assertEq(buf.byteLength, kPageSize); | 460 assertEq(buf.byteLength, kPageSize); |
462 assertEq(mem.grow(1), 1); | 461 assertEq(mem.grow(1), 1); |
463 // TODO(gdeepti): assertTrue(buf !== mem.buffer); | 462 assertTrue(buf !== mem.buffer); |
464 // TODO(gdeepti): assertEq(buf.byteLength, 0); | 463 assertEq(buf.byteLength, 0); |
465 buf = mem.buffer; | 464 buf = mem.buffer; |
466 assertEq(buf.byteLength, 2 * kPageSize); | 465 assertEq(buf.byteLength, 2 * kPageSize); |
467 assertErrorMessage(() => mem.grow(1), Error, /failed to grow memory/); | 466 assertErrorMessage(() => mem.grow(1), Error, /failed to grow memory/); |
468 assertEq(buf, mem.buffer); | 467 assertEq(buf, mem.buffer); |
469 | 468 |
470 // 'WebAssembly.Table' data property | 469 // 'WebAssembly.Table' data property |
471 let tableDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Table'); | 470 let tableDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Table'); |
472 assertEq(typeof tableDesc.value, "function"); | 471 assertEq(typeof tableDesc.value, "function"); |
473 assertTrue(tableDesc.writable); | 472 assertTrue(tableDesc.writable); |
474 assertFalse(tableDesc.enumerable); | 473 assertFalse(tableDesc.enumerable); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 assertTrue(result.instance instanceof Instance); | 696 assertTrue(result.instance instanceof Instance); |
698 } | 697 } |
699 } | 698 } |
700 assertInstantiateSuccess(emptyModule); | 699 assertInstantiateSuccess(emptyModule); |
701 assertInstantiateSuccess(emptyModuleBinary); | 700 assertInstantiateSuccess(emptyModuleBinary); |
702 assertInstantiateSuccess(emptyModuleBinary.buffer); | 701 assertInstantiateSuccess(emptyModuleBinary.buffer); |
703 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); | 702 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); |
704 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 703 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
705 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 704 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
706 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); | 705 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); |
OLD | NEW |