OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm --allow-natives-syntax | 5 // Flags: --expose-wasm --allow-natives-syntax |
6 | 6 |
7 if ((typeof drainJobQueue) != "function") { | 7 if ((typeof drainJobQueue) != "function") { |
8 drainJobQueue = () => { %RunMicrotasks() }; | 8 drainJobQueue = () => { %RunMicrotasks() }; |
9 } | 9 } |
10 | 10 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 'first argument must be a WebAssembly.Module'); | 285 'first argument must be a WebAssembly.Module'); |
286 assertErrorMessage( | 286 assertErrorMessage( |
287 () => moduleCustomSections(emptyModule), TypeError, | 287 () => moduleCustomSections(emptyModule), TypeError, |
288 'second argument must be a String'); | 288 'second argument must be a String'); |
289 assertErrorMessage( | 289 assertErrorMessage( |
290 () => moduleCustomSections(emptyModule, 3), TypeError, | 290 () => moduleCustomSections(emptyModule, 3), TypeError, |
291 'second argument must be a String'); | 291 'second argument must be a String'); |
292 | 292 |
293 let customSectionModuleBinary2 = (() => { | 293 let customSectionModuleBinary2 = (() => { |
294 let builder = new WasmModuleBuilder(); | 294 let builder = new WasmModuleBuilder(); |
295 builder.addExplicitSection([kUnknownSectionCode, 3, 1, 'x'.charCodeAt(0), 2]); | 295 builder.addCustomSection('x', [2]); |
296 builder.addExplicitSection([ | 296 builder.addCustomSection('foo', [66, 77]); |
297 kUnknownSectionCode, 6, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), | 297 builder.addCustomSection('foo', [91, 92, 93]); |
298 'o'.charCodeAt(0), 66, 77 | 298 builder.addCustomSection('fox', [99, 99, 99]); |
299 ]); | |
300 builder.addExplicitSection([ | |
301 kUnknownSectionCode, 7, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), | |
302 'o'.charCodeAt(0), 91, 92, 93 | |
303 ]); | |
304 builder.addExplicitSection([ | |
305 kUnknownSectionCode, 7, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), | |
306 'x'.charCodeAt(0), 99, 99, 99 | |
307 ]); | |
308 return new Int8Array(builder.toBuffer()); | 299 return new Int8Array(builder.toBuffer()); |
309 })(); | 300 })(); |
310 var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'x'); | 301 var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'x'); |
311 assertEq(arr instanceof Array, true); | 302 assertEq(arr instanceof Array, true); |
312 assertEq(arr.length, 1); | 303 assertEq(arr.length, 1); |
313 assertArrayBuffer(arr[0], [2]); | 304 assertArrayBuffer(arr[0], [2]); |
314 var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'foo'); | 305 var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'foo'); |
315 assertEq(arr instanceof Array, true); | 306 assertEq(arr instanceof Array, true); |
316 assertEq(arr.length, 2); | 307 assertEq(arr.length, 2); |
317 assertArrayBuffer(arr[0], [66, 77]); | 308 assertArrayBuffer(arr[0], [66, 77]); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 assertTrue(result.instance instanceof Instance); | 697 assertTrue(result.instance instanceof Instance); |
707 } | 698 } |
708 } | 699 } |
709 assertInstantiateSuccess(emptyModule); | 700 assertInstantiateSuccess(emptyModule); |
710 assertInstantiateSuccess(emptyModuleBinary); | 701 assertInstantiateSuccess(emptyModuleBinary); |
711 assertInstantiateSuccess(emptyModuleBinary.buffer); | 702 assertInstantiateSuccess(emptyModuleBinary.buffer); |
712 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); | 703 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); |
713 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 704 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
714 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 705 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
715 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); | 706 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch
_memory}}); |
OLD | NEW |