| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --allow-natives-syntax | |
| 6 | |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); | |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); | |
| 9 | |
| 10 let buffer = (() => { | |
| 11 let builder = new WasmModuleBuilder(); | |
| 12 builder.addFunction("f", kSig_i_v) | |
| 13 .addBody([kExprI32Const, 42]) | |
| 14 .exportAs("f"); | |
| 15 return builder.toBuffer(); | |
| 16 })(); | |
| 17 | |
| 18 var module = new WebAssembly.Module(buffer); | |
| 19 var wrapper = Promise.resolve(module); | |
| 20 | |
| 21 assertPromiseResult( | |
| 22 WebAssembly.instantiate(wrapper), | |
| 23 assertUnreachable, | |
| 24 e => assertTrue(e instanceof TypeError)); | |
| 25 | |
| 26 assertPromiseResult(( | |
| 27 () => { | |
| 28 var old = %SetWasmCompileFromPromiseOverload(); | |
| 29 var ret = WebAssembly.instantiate(wrapper); | |
| 30 %ResetWasmOverloads(old); | |
| 31 return ret; | |
| 32 })(), | |
| 33 pair => { | |
| 34 assertTrue(pair.instance instanceof WebAssembly.Instance); | |
| 35 assertTrue(pair.module instanceof WebAssembly.Module) | |
| 36 }, | |
| 37 assertUnreachable); | |
| OLD | NEW |