v8/test/mjsunit/wasm/stringrefs-invalid.js
Adam Klein 76ae4f56df [cleanup] Remove Wasm exception-handling runtime flag
It's been enabled by default since Chromium M95.

Also removes duplicate setup code for WebAssembly.Tag JS API
from WasmJs::InstallConditionalFeatures, since we're guaranteed
to set it up via the non-conditional WasmJs::Install.

Bug: v8:8091
Change-Id: Ic500feb655ad4fc0703ed226504847ca6d940537
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3996810
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84074}
2022-11-04 22:50:50 +00:00

40 lines
1.6 KiB
JavaScript

// Copyright 2022 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: --experimental-wasm-gc
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
function assertInvalid(fn, message) {
let builder = new WasmModuleBuilder();
fn(builder);
assertThrows(() => builder.toModule(), WebAssembly.CompileError, message);
}
assertInvalid(
builder => builder.addLiteralStringRef("foo"),
/unexpected section <StringRef> \(enable with --experimental-wasm-stringref\)/);
let enableMessage = 'enable with --experimental-wasm-stringref'
for (let [name, code] of [['string', kStringRefCode],
['stringview_wtf8', kStringViewWtf8Code],
['stringview_wtf16', kStringViewWtf16Code],
['stringview_iter', kStringViewIterCode]]) {
let message = new RegExp(`invalid value type '${name}ref', ${enableMessage}`);
let default_init = [kExprRefNull, code];
assertInvalid(b => b.addType(makeSig([code], [])), message);
assertInvalid(b => b.addStruct([makeField(code, true)]), message);
assertInvalid(b => b.addArray(code, true), message);
assertInvalid(b => b.addType(makeSig([], [code])), message);
assertInvalid(b => b.addGlobal(code, true, default_init), message);
assertInvalid(b => b.addTable(code, 0), message);
assertInvalid(b => b.addPassiveElementSegment([default_init], code), message);
assertInvalid(b => b.addTag(makeSig([code], [])), message);
assertInvalid(
b => b.addFunction(undefined, kSig_v_v).addLocals(code, 1).addBody([]),
message);
}