Commit 439f1f6f authored by Andreas Rossberg's avatar Andreas Rossberg Committed by Commit Bot

[wasm] Fix string conversion of customSections name

R=titzer@chromium.org

Bug: v8:5815
Change-Id: Ied267a431ed294f022628169e811069f2a4851b1
Reviewed-on: https://chromium-review.googlesource.com/599875
Commit-Queue: Andreas Rossberg <rossberg@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47133}
parent b77115a0
......@@ -235,17 +235,10 @@ void WebAssemblyModuleCustomSections(
auto maybe_module = GetFirstArgumentAsModule(args, &thrower);
if (thrower.error()) return;
if (args.Length() < 2) {
thrower.TypeError("Argument 1 must be a string");
return;
}
i::Handle<i::Object> name = Utils::OpenHandle(*args[1]);
if (!name->IsString()) {
thrower.TypeError("Argument 1 must be a string");
return;
}
i::MaybeHandle<i::Object> maybe_name =
i::Object::ToString(i_isolate, Utils::OpenHandle(*args[1]));
i::Handle<i::Object> name;
if (!maybe_name.ToHandle(&name)) return;
auto custom_sections =
i::wasm::GetCustomSections(i_isolate, maybe_module.ToHandleChecked(),
i::Handle<i::String>::cast(name), &thrower);
......
......@@ -307,12 +307,6 @@ assertEq(arr.length, 0);
assertErrorMessage(
() => moduleCustomSections(1), TypeError,
'first argument must be a WebAssembly.Module');
assertErrorMessage(
() => moduleCustomSections(emptyModule), TypeError,
'second argument must be a String');
assertErrorMessage(
() => moduleCustomSections(emptyModule, 3), TypeError,
'second argument must be a String');
let customSectionModuleBinary2 = (() => {
let builder = new WasmModuleBuilder();
......@@ -334,6 +328,15 @@ assertArrayBuffer(arr[1], [91, 92, 93]);
var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'bar');
assertEq(arr instanceof Array, true);
assertEq(arr.length, 0);
var o = {toString() { return "foo" }}
var arr = moduleCustomSections(new Module(customSectionModuleBinary2), o);
assertEq(arr instanceof Array, true);
assertEq(arr.length, 2);
assertArrayBuffer(arr[0], [66, 77]);
assertArrayBuffer(arr[1], [91, 92, 93]);
var o = {toString() { throw "boo!" }}
assertThrows(
() => moduleCustomSections(new Module(customSectionModuleBinary2), o));
// 'WebAssembly.Instance' data property
let instanceDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Instance');
......
......@@ -8,8 +8,6 @@
// Flags: --expose-wasm --allow-natives-syntax
const known_failures = {
"'WebAssembly.Module.customSections' method":
'https://bugs.chromium.org/p/v8/issues/detail?id=5815',
"'WebAssembly.Table.prototype.get' method":
'https://bugs.chromium.org/p/v8/issues/detail?id=5507',
"'WebAssembly.Table.prototype.set' method":
......
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