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 23 matching lines...) Expand all Loading... |
34 .exportAs("f"); | 34 .exportAs("f"); |
35 return new Int8Array(builder.toBuffer()); | 35 return new Int8Array(builder.toBuffer()); |
36 })(); | 36 })(); |
37 | 37 |
38 let importingModuleBinary = (() => { | 38 let importingModuleBinary = (() => { |
39 var builder = new WasmModuleBuilder(); | 39 var builder = new WasmModuleBuilder(); |
40 builder.addImport("", "f", kSig_i_v); | 40 builder.addImport("", "f", kSig_i_v); |
41 return new Int8Array(builder.toBuffer()); | 41 return new Int8Array(builder.toBuffer()); |
42 })(); | 42 })(); |
43 | 43 |
| 44 let moduleBinaryImporting2Memories = (() => { |
| 45 var builder = new WasmModuleBuilder(); |
| 46 builder.addImportedMemory("", "memory1"); |
| 47 builder.addImportedMemory("", "memory2"); |
| 48 return new Int8Array(builder.toBuffer()); |
| 49 })(); |
| 50 |
44 // 'WebAssembly' data property on global object | 51 // 'WebAssembly' data property on global object |
45 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); | 52 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); |
46 assertEq(typeof wasmDesc.value, "object"); | 53 assertEq(typeof wasmDesc.value, "object"); |
47 assertEq(wasmDesc.writable, true); | 54 assertEq(wasmDesc.writable, true); |
48 assertEq(wasmDesc.enumerable, false); | 55 assertEq(wasmDesc.enumerable, false); |
49 assertEq(wasmDesc.configurable, true); | 56 assertEq(wasmDesc.configurable, true); |
50 | 57 |
51 // 'WebAssembly' object | 58 // 'WebAssembly' object |
52 assertEq(WebAssembly, wasmDesc.value); | 59 assertEq(WebAssembly, wasmDesc.value); |
53 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); | 60 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); | 478 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); |
472 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); | 479 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); |
473 assertEq(tbl.length, 1); | 480 assertEq(tbl.length, 1); |
474 assertEq(tbl.grow(0), 1); | 481 assertEq(tbl.grow(0), 1); |
475 assertEq(tbl.length, 1); | 482 assertEq(tbl.length, 1); |
476 assertEq(tbl.grow(1), 1); | 483 assertEq(tbl.grow(1), 1); |
477 assertEq(tbl.length, 2); | 484 assertEq(tbl.length, 2); |
478 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); | 485 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); |
479 } | 486 } |
480 | 487 |
| 488 // 'WebAssembly.validate' function |
| 489 assertErrorMessage(() => WebAssembly.validate(), TypeError); |
| 490 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); |
| 491 assertEq(WebAssembly.validate(emptyModuleBinary), true); |
| 492 // TODO: other ways for validate to return false. |
| 493 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); |
| 494 |
481 // 'WebAssembly.compile' data property | 495 // 'WebAssembly.compile' data property |
482 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); | 496 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); |
483 assertEq(typeof compileDesc.value, "function"); | 497 assertEq(typeof compileDesc.value, "function"); |
484 assertEq(compileDesc.writable, true); | 498 assertEq(compileDesc.writable, true); |
485 assertEq(compileDesc.enumerable, false); | 499 assertEq(compileDesc.enumerable, false); |
486 assertEq(compileDesc.configurable, true); | 500 assertEq(compileDesc.configurable, true); |
487 | 501 |
488 // 'WebAssembly.compile' function | 502 // 'WebAssembly.compile' function |
489 let compile = WebAssembly.compile; | 503 let compile = WebAssembly.compile; |
490 assertEq(compile, compileDesc.value); | 504 assertEq(compile, compileDesc.value); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 assertEq(result.instance instanceof Instance, true); | 577 assertEq(result.instance instanceof Instance, true); |
564 } | 578 } |
565 } | 579 } |
566 assertInstantiateSuccess(emptyModule); | 580 assertInstantiateSuccess(emptyModule); |
567 assertInstantiateSuccess(emptyModuleBinary); | 581 assertInstantiateSuccess(emptyModuleBinary); |
568 assertInstantiateSuccess(emptyModuleBinary.buffer); | 582 assertInstantiateSuccess(emptyModuleBinary.buffer); |
569 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); | 583 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); |
570 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 584 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
571 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 585 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
572 } | 586 } |
OLD | NEW |