Commit 59b7d6a0 authored by Andy Wingo's avatar Andy Wingo Committed by V8 LUCI CQ

[stringref] Add test for wasm-to-js calls

Bug: v8:12868
Change-Id: I8d789457c725708e06f482d362d17c16a802a1f3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3644950Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Andy Wingo <wingo@igalia.com>
Cr-Commit-Position: refs/heads/main@{#80603}
parent 1f215c20
......@@ -59,6 +59,24 @@ function assertInvalid(fn, message) {
assertArrayEquals([null, 'foo'], instance.exports.swap('foo', null));
})();
(function TestCallout() {
let kSig_w_w = makeSig([kWasmStringRef], [kWasmStringRef]);
let builder = new WasmModuleBuilder();
builder.addImport("env", "transformer", kSig_w_w)
builder.addFunction("transform", kSig_w_w)
.exportFunc()
.addBody([
kExprLocalGet, 0,
kExprCallFunction, 0
]);
let instance = builder.instantiate(
{ env: { transformer: x=>x.toUpperCase() } });
assertEquals('FOO', instance.exports.transform('foo'));
})();
(function TestViewsUnsupported() {
let kSig_x_v = makeSig([], [kWasmStringViewWtf8]);
let kSig_y_v = makeSig([], [kWasmStringViewWtf16]);
......@@ -214,5 +232,4 @@ function assertInvalid(fn, message) {
assertEquals('bar', instance.exports.get_stringref());
})();
// TODO(wingo): Test calls from wasm to JS.
// TODO(wingo): Test stringrefs in tables.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment