| Index: test/mjsunit/wasm/names.js
|
| diff --git a/test/mjsunit/wasm/names.js b/test/mjsunit/wasm/names.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8b635e67713b284695189635e199c446f9e67310
|
| --- /dev/null
|
| +++ b/test/mjsunit/wasm/names.js
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2017 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');
|
| +load('test/mjsunit/wasm/wasm-module-builder.js');
|
| +
|
| +function toBytes(string) {
|
| + var a = new Array(string.length + 1);
|
| + a[0] = string.length;
|
| + for (i = 0; i < string.length; i++) {
|
| + a[i + 1] = string.charCodeAt(i);
|
| + }
|
| + return a;
|
| +}
|
| +
|
| +(function TestEmptyNamesSection() {
|
| + print('TestEmptyNamesSection...');
|
| + var builder = new WasmModuleBuilder();
|
| +
|
| + builder.addExplicitSection([kUnknownSectionCode, 6, ...toBytes('name'), 0]);
|
| +
|
| + var buffer = builder.toBuffer();
|
| + assertTrue(WebAssembly.validate(buffer));
|
| + assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module);
|
| +})();
|
| +
|
| +(function TestTruncatedNamesSection() {
|
| + print('TestTruncatedNamesSection...');
|
| + var builder = new WasmModuleBuilder();
|
| +
|
| + builder.addExplicitSection([kUnknownSectionCode, 6, ...toBytes('name'), 1]);
|
| +
|
| + var buffer = builder.toBuffer();
|
| + assertTrue(WebAssembly.validate(buffer));
|
| + assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module);
|
| +})();
|
| +
|
| +(function TestBrokenNamesSection() {
|
| + print('TestBrokenNamesSection...');
|
| + var builder = new WasmModuleBuilder();
|
| +
|
| + builder.addExplicitSection(
|
| + [kUnknownSectionCode, 7, ...toBytes('name'), 1, 100]);
|
| +
|
| + var buffer = builder.toBuffer();
|
| + assertTrue(WebAssembly.validate(buffer));
|
| + assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module);
|
| +})();
|
|
|