| 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 assertEq(set.call(tbl1, 0, null), undefined); | 501 assertEq(set.call(tbl1, 0, null), undefined); |
| 502 assertEq(set.call(tbl1, 1, null), undefined); | 502 assertEq(set.call(tbl1, 1, null), undefined); |
| 503 | 503 |
| 504 // 'WebAssembly.Table.prototype.grow' data property | 504 // 'WebAssembly.Table.prototype.grow' data property |
| 505 let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow'); | 505 let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow'); |
| 506 assertEq(typeof tblGrowDesc.value, "function"); | 506 assertEq(typeof tblGrowDesc.value, "function"); |
| 507 assertEq(tblGrowDesc.enumerable, false); | 507 assertEq(tblGrowDesc.enumerable, false); |
| 508 assertEq(tblGrowDesc.configurable, true); | 508 assertEq(tblGrowDesc.configurable, true); |
| 509 | 509 |
| 510 // 'WebAssembly.Table.prototype.grow' method | 510 // 'WebAssembly.Table.prototype.grow' method |
| 511 if (false) { // TODO: Table.grow | |
| 512 let tblGrow = tblGrowDesc.value; | 511 let tblGrow = tblGrowDesc.value; |
| 513 assertEq(tblGrow.length, 1); | 512 assertEq(tblGrow.length, 1); |
| 514 assertErrorMessage(() => tblGrow.call(), TypeError, /called on incompatible unde
fined/); | 513 assertErrorMessage(() => tblGrow.call(), TypeError, /called on incompatible unde
fined/); |
| 515 assertErrorMessage(() => tblGrow.call({}), TypeError, /called on incompatible Ob
ject/); | 514 assertErrorMessage(() => tblGrow.call({}), TypeError, /called on incompatible Ob
ject/); |
| 516 assertErrorMessage(() => tblGrow.call(tbl1, -1), RangeError, /bad Table grow del
ta/); | 515 assertErrorMessage(() => tblGrow.call(tbl1, -1), RangeError, /bad Table grow del
ta/); |
| 517 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); | 516 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); |
| 518 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); | 517 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); |
| 519 assertEq(tbl.length, 1); | 518 assertEq(tbl.length, 1); |
| 520 assertEq(tbl.grow(0), 1); | 519 assertEq(tbl.grow(0), 1); |
| 521 assertEq(tbl.length, 1); | 520 assertEq(tbl.length, 1); |
| 522 assertEq(tbl.grow(1), 1); | 521 assertEq(tbl.grow(1), 1); |
| 523 assertEq(tbl.length, 2); | 522 assertEq(tbl.length, 2); |
| 524 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); | 523 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); |
| 525 } | |
| 526 | 524 |
| 527 // 'WebAssembly.validate' function | 525 // 'WebAssembly.validate' function |
| 528 assertErrorMessage(() => WebAssembly.validate(), TypeError); | 526 assertErrorMessage(() => WebAssembly.validate(), TypeError); |
| 529 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); | 527 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); |
| 530 assertEq(WebAssembly.validate(emptyModuleBinary), true); | 528 assertEq(WebAssembly.validate(emptyModuleBinary), true); |
| 531 // TODO: other ways for validate to return false. | 529 // TODO: other ways for validate to return false. |
| 532 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); | 530 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); |
| 533 assertEq(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport), false); | 531 assertEq(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport), false); |
| 534 | 532 |
| 535 // 'WebAssembly.compile' data property | 533 // 'WebAssembly.compile' data property |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 var result = null; | 626 var result = null; |
| 629 instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e)); | 627 instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e)); |
| 630 drainJobQueue(); | 628 drainJobQueue(); |
| 631 assertEq(result instanceof Instance, true); | 629 assertEq(result instanceof Instance, true); |
| 632 } | 630 } |
| 633 assertInstantiateSuccess(emptyModuleBinary); | 631 assertInstantiateSuccess(emptyModuleBinary); |
| 634 assertInstantiateSuccess(emptyModuleBinary.buffer); | 632 assertInstantiateSuccess(emptyModuleBinary.buffer); |
| 635 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 633 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
| 636 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 634 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
| 637 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); | 635 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); |
| OLD | NEW |