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 30 matching lines...) Expand all Loading... |
41 return new Int8Array(builder.toBuffer()); | 41 return new Int8Array(builder.toBuffer()); |
42 })(); | 42 })(); |
43 | 43 |
44 let moduleBinaryImporting2Memories = (() => { | 44 let moduleBinaryImporting2Memories = (() => { |
45 var builder = new WasmModuleBuilder(); | 45 var builder = new WasmModuleBuilder(); |
46 builder.addImportedMemory("", "memory1"); | 46 builder.addImportedMemory("", "memory1"); |
47 builder.addImportedMemory("", "memory2"); | 47 builder.addImportedMemory("", "memory2"); |
48 return new Int8Array(builder.toBuffer()); | 48 return new Int8Array(builder.toBuffer()); |
49 })(); | 49 })(); |
50 | 50 |
| 51 let moduleBinaryWithMemSectionAndMemImport = (() => { |
| 52 var builder = new WasmModuleBuilder(); |
| 53 builder.addMemory(1, 1, false); |
| 54 builder.addImportedMemory("", "memory1"); |
| 55 return new Int8Array(builder.toBuffer()); |
| 56 })(); |
| 57 |
51 // 'WebAssembly' data property on global object | 58 // 'WebAssembly' data property on global object |
52 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); | 59 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); |
53 assertEq(typeof wasmDesc.value, "object"); | 60 assertEq(typeof wasmDesc.value, "object"); |
54 assertEq(wasmDesc.writable, true); | 61 assertEq(wasmDesc.writable, true); |
55 assertEq(wasmDesc.enumerable, false); | 62 assertEq(wasmDesc.enumerable, false); |
56 assertEq(wasmDesc.configurable, true); | 63 assertEq(wasmDesc.configurable, true); |
57 | 64 |
58 // 'WebAssembly' object | 65 // 'WebAssembly' object |
59 assertEq(WebAssembly, wasmDesc.value); | 66 assertEq(WebAssembly, wasmDesc.value); |
60 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); | 67 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 assertEq(tbl.length, 2); | 491 assertEq(tbl.length, 2); |
485 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); | 492 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); |
486 } | 493 } |
487 | 494 |
488 // 'WebAssembly.validate' function | 495 // 'WebAssembly.validate' function |
489 assertErrorMessage(() => WebAssembly.validate(), TypeError); | 496 assertErrorMessage(() => WebAssembly.validate(), TypeError); |
490 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); | 497 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); |
491 assertEq(WebAssembly.validate(emptyModuleBinary), true); | 498 assertEq(WebAssembly.validate(emptyModuleBinary), true); |
492 // TODO: other ways for validate to return false. | 499 // TODO: other ways for validate to return false. |
493 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); | 500 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); |
| 501 assertEq(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport), false); |
494 | 502 |
495 // 'WebAssembly.compile' data property | 503 // 'WebAssembly.compile' data property |
496 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); | 504 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); |
497 assertEq(typeof compileDesc.value, "function"); | 505 assertEq(typeof compileDesc.value, "function"); |
498 assertEq(compileDesc.writable, true); | 506 assertEq(compileDesc.writable, true); |
499 assertEq(compileDesc.enumerable, false); | 507 assertEq(compileDesc.enumerable, false); |
500 assertEq(compileDesc.configurable, true); | 508 assertEq(compileDesc.configurable, true); |
501 | 509 |
502 // 'WebAssembly.compile' function | 510 // 'WebAssembly.compile' function |
503 let compile = WebAssembly.compile; | 511 let compile = WebAssembly.compile; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 assertEq(result.instance instanceof Instance, true); | 585 assertEq(result.instance instanceof Instance, true); |
578 } | 586 } |
579 } | 587 } |
580 assertInstantiateSuccess(emptyModule); | 588 assertInstantiateSuccess(emptyModule); |
581 assertInstantiateSuccess(emptyModuleBinary); | 589 assertInstantiateSuccess(emptyModuleBinary); |
582 assertInstantiateSuccess(emptyModuleBinary.buffer); | 590 assertInstantiateSuccess(emptyModuleBinary.buffer); |
583 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); | 591 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); |
584 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 592 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
585 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 593 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
586 } | 594 } |
OLD | NEW |