| 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 assertEq(compileDesc.enumerable, false); | 540 assertEq(compileDesc.enumerable, false); |
| 541 assertEq(compileDesc.configurable, true); | 541 assertEq(compileDesc.configurable, true); |
| 542 | 542 |
| 543 // 'WebAssembly.compile' function | 543 // 'WebAssembly.compile' function |
| 544 let compile = WebAssembly.compile; | 544 let compile = WebAssembly.compile; |
| 545 assertEq(compile, compileDesc.value); | 545 assertEq(compile, compileDesc.value); |
| 546 assertEq(compile.length, 1); | 546 assertEq(compile.length, 1); |
| 547 assertEq(compile.name, "compile"); | 547 assertEq(compile.name, "compile"); |
| 548 function assertCompileError(args, err, msg) { | 548 function assertCompileError(args, err, msg) { |
| 549 var error = null; | 549 var error = null; |
| 550 try { | 550 compile(...args).catch(e => error = e); |
| 551 compile(...args).catch(e => error = e); | |
| 552 } catch (e) { | |
| 553 // TODO: error shouldn't be thrown, but should be globbed onto the promise. | |
| 554 error = e; | |
| 555 } | |
| 556 drainJobQueue(); | 551 drainJobQueue(); |
| 557 assertEq(error instanceof err, true); | 552 assertEq(error instanceof err, true); |
| 558 assertEq(Boolean(error.stack.match("js-api.js")), true); | 553 assertEq(Boolean(error.stack.match("js-api.js")), true); |
| 559 //TODO assertEq(Boolean(error.message.match(msg)), true); | 554 //TODO assertEq(Boolean(error.message.match(msg)), true); |
| 560 } | 555 } |
| 561 assertCompileError([], TypeError, /requires more than 0 arguments/); | 556 assertCompileError([], TypeError, /requires more than 0 arguments/); |
| 562 assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffe
r or typed array object/); | 557 assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffe
r or typed array object/); |
| 563 assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typ
ed array object/); | 558 assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typ
ed array object/); |
| 564 assertCompileError([{}], TypeError, /first argument must be an ArrayBuffer or ty
ped array object/); | 559 assertCompileError([{}], TypeError, /first argument must be an ArrayBuffer or ty
ped array object/); |
| 565 assertCompileError([new Uint8Array()], CompileError, /BufferSource argument is e
mpty/); | 560 assertCompileError([new Uint8Array()], CompileError, /BufferSource argument is e
mpty/); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 var result = null; | 620 var result = null; |
| 626 instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e)); | 621 instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e)); |
| 627 drainJobQueue(); | 622 drainJobQueue(); |
| 628 assertEq(result instanceof Instance, true); | 623 assertEq(result instanceof Instance, true); |
| 629 } | 624 } |
| 630 assertInstantiateSuccess(emptyModuleBinary); | 625 assertInstantiateSuccess(emptyModuleBinary); |
| 631 assertInstantiateSuccess(emptyModuleBinary.buffer); | 626 assertInstantiateSuccess(emptyModuleBinary.buffer); |
| 632 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 627 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
| 633 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 628 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
| 634 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); | 629 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); |
| OLD | NEW |