[wasm] Reduce usage of old Wasm.* API in JS tests.
BUG= Review-Url: https://codereview.chromium.org/2417773004 Cr-Commit-Position: refs/heads/master@{#40282}
This commit is contained in:
parent
73460009a6
commit
283b31f57c
@ -19,7 +19,7 @@ function SimpleDataSegmentTest(offset) {
|
||||
builder.addDataSegment(offset, [9, 9, 9, 9]);
|
||||
|
||||
var buffer = builder.toBuffer(debug);
|
||||
var instance = Wasm.instantiateModule(buffer);
|
||||
var instance = new WebAssembly.Instance(new WebAssembly.Module(buffer));
|
||||
for (var i = offset - 20; i < offset + 20; i += 4) {
|
||||
if (i < 0) continue;
|
||||
var expected = (i == offset) ? 151587081 : 0;
|
||||
@ -44,7 +44,7 @@ function GlobalInitTest(offset) {
|
||||
builder.addDataSegment(g.index, [7, 7, 7, 7], true);
|
||||
|
||||
var buffer = builder.toBuffer(debug);
|
||||
var instance = Wasm.instantiateModule(buffer);
|
||||
var instance = new WebAssembly.Instance(new WebAssembly.Module(buffer));
|
||||
for (var i = offset - 20; i < offset + 20; i += 4) {
|
||||
if (i < 0) continue;
|
||||
var expected = i == offset ? 117901063 : 0;
|
||||
|
@ -106,7 +106,7 @@ var test_catch = (function () {
|
||||
}
|
||||
var kJSThrowLarge = builder.addImport("throw_large", sig_index);
|
||||
|
||||
// Helper function for throwing from Wasm.
|
||||
// Helper function for throwing from WebAssembly.
|
||||
var kWasmThrowFunction =
|
||||
builder.addFunction("throw", kSig_v_i)
|
||||
.addBody([
|
||||
|
@ -52,9 +52,6 @@ function CheckInstance(instance) {
|
||||
assertEquals(kReturnValue, main());
|
||||
}
|
||||
|
||||
// Deprecated experimental API.
|
||||
CheckInstance(Wasm.instantiateModule(buffer));
|
||||
|
||||
// Official API
|
||||
let module = new WebAssembly.Module(buffer);
|
||||
CheckInstance(new WebAssembly.Instance(module));
|
||||
|
@ -1,18 +0,0 @@
|
||||
// Copyright 2015 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --expose-wasm
|
||||
|
||||
function Foo() { }
|
||||
|
||||
assertThrows(function() { Wasm.verifyFunction(); })
|
||||
assertThrows(function() { Wasm.verifyFunction(0); })
|
||||
assertThrows(function() { Wasm.verifyFunction("s"); })
|
||||
assertThrows(function() { Wasm.verifyFunction(undefined); })
|
||||
assertThrows(function() { Wasm.verifyFunction(1.1); })
|
||||
assertThrows(function() { Wasm.verifyFunction(1/0); })
|
||||
assertThrows(function() { Wasm.verifyFunction(null); })
|
||||
assertThrows(function() { Wasm.verifyFunction(new Foo()); })
|
||||
assertThrows(function() { Wasm.verifyFunction(new ArrayBuffer(0)); })
|
||||
assertThrows(function() { Wasm.verifyFunction(new ArrayBuffer(140000)); })
|
@ -1,38 +0,0 @@
|
||||
// Copyright 2015 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --expose-wasm
|
||||
|
||||
load("test/mjsunit/wasm/wasm-constants.js");
|
||||
|
||||
try {
|
||||
var data = bytes(
|
||||
kWasmFunctionTypeForm, 0, kAstStmt, // signature
|
||||
kDeclNoLocals, // --
|
||||
kExprNop // body
|
||||
);
|
||||
|
||||
Wasm.verifyFunction(data);
|
||||
print("ok");
|
||||
} catch (e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
|
||||
var threw = false;
|
||||
try {
|
||||
var data = bytes(
|
||||
kWasmFunctionTypeForm, 0, 1, kAstI32, // signature
|
||||
kDeclNoLocals, // --
|
||||
kExprBlock, kAstStmt, kExprNop, kExprNop, kExprEnd // body
|
||||
);
|
||||
|
||||
Wasm.verifyFunction(data);
|
||||
print("not ok");
|
||||
} catch (e) {
|
||||
print("ok: " + e);
|
||||
threw = true;
|
||||
}
|
||||
|
||||
assertTrue(threw);
|
@ -6,13 +6,13 @@
|
||||
|
||||
function Foo() { }
|
||||
|
||||
assertThrows(function() { Wasm.verifyModule(); })
|
||||
assertThrows(function() { Wasm.verifyModule(0); })
|
||||
assertThrows(function() { Wasm.verifyModule("s"); })
|
||||
assertThrows(function() { Wasm.verifyModule(undefined); })
|
||||
assertThrows(function() { Wasm.verifyModule(1.1); })
|
||||
assertThrows(function() { Wasm.verifyModule(1/0); })
|
||||
assertThrows(function() { Wasm.verifyModule(null); })
|
||||
assertThrows(function() { Wasm.verifyModule(new Foo()); })
|
||||
assertThrows(function() { Wasm.verifyModule(new ArrayBuffer(0)); })
|
||||
assertThrows(function() { Wasm.verifyModule(new ArrayBuffer(7)); })
|
||||
assertThrows(function() { new WebAssembly.Module(); })
|
||||
assertThrows(function() { new WebAssembly.Module(0); })
|
||||
assertThrows(function() { new WebAssembly.Module("s"); })
|
||||
assertThrows(function() { new WebAssembly.Module(undefined); })
|
||||
assertThrows(function() { new WebAssembly.Module(1.1); })
|
||||
assertThrows(function() { new WebAssembly.Module(1/0); })
|
||||
assertThrows(function() { new WebAssembly.Module(null); })
|
||||
assertThrows(function() { new WebAssembly.Module(new Foo()); })
|
||||
assertThrows(function() { new WebAssembly.Module(new ArrayBuffer(0)); })
|
||||
assertThrows(function() { new WebAssembly.Module(new ArrayBuffer(7)); })
|
||||
|
@ -4,12 +4,19 @@
|
||||
|
||||
// Flags: --expose-wasm
|
||||
|
||||
assertFalse(undefined === Wasm);
|
||||
assertFalse(undefined == Wasm);
|
||||
assertEquals("function", typeof Wasm.verifyModule);
|
||||
assertEquals("function", typeof Wasm.verifyFunction);
|
||||
assertEquals("function", typeof Wasm.instantiateModule);
|
||||
assertFalse(undefined == Wasm.experimentalVersion);
|
||||
var oldApi = true;
|
||||
|
||||
if (oldApi) {
|
||||
assertFalse(undefined === Wasm);
|
||||
assertFalse(undefined == Wasm);
|
||||
assertEquals("function", typeof Wasm.verifyModule);
|
||||
assertEquals("function", typeof Wasm.verifyFunction);
|
||||
assertEquals("function", typeof Wasm.instantiateModule);
|
||||
assertFalse(undefined == Wasm.experimentalVersion);
|
||||
} else {
|
||||
assertTrue(undefined === Wasm);
|
||||
assertTrue(undefined == Wasm);
|
||||
}
|
||||
|
||||
assertEquals('object', typeof WebAssembly);
|
||||
assertEquals('function', typeof WebAssembly.Module);
|
||||
|
Loading…
Reference in New Issue
Block a user