Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: test/mjsunit/wasm/js-api.js

Issue 2627763002: [wasm] JS APIs & memory (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/instantiate-module-basic.js ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 return new Int8Array(builder.toBuffer()); 41 return new Int8Array(builder.toBuffer());
42 })(); 42 })();
43 43
44 let moduleBinaryImporting2Memories = (() => { 44 let moduleBinaryImporting2Memories = (() => {
45 var builder = new WasmModuleBuilder(); 45 var builder = new WasmModuleBuilder();
46 builder.addImportedMemory("", "memory1"); 46 builder.addImportedMemory("", "memory1");
47 builder.addImportedMemory("", "memory2"); 47 builder.addImportedMemory("", "memory2");
48 return new Int8Array(builder.toBuffer()); 48 return new Int8Array(builder.toBuffer());
49 })(); 49 })();
50 50
51 let moduleBinaryWithMemSectionAndMemImport = (() => {
52 var builder = new WasmModuleBuilder();
53 builder.addMemory(1, 1, false);
54 builder.addImportedMemory("", "memory1");
55 return new Int8Array(builder.toBuffer());
56 })();
57
51 // 'WebAssembly' data property on global object 58 // 'WebAssembly' data property on global object
52 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); 59 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly');
53 assertEq(typeof wasmDesc.value, "object"); 60 assertEq(typeof wasmDesc.value, "object");
54 assertEq(wasmDesc.writable, true); 61 assertEq(wasmDesc.writable, true);
55 assertEq(wasmDesc.enumerable, false); 62 assertEq(wasmDesc.enumerable, false);
56 assertEq(wasmDesc.configurable, true); 63 assertEq(wasmDesc.configurable, true);
57 64
58 // 'WebAssembly' object 65 // 'WebAssembly' object
59 assertEq(WebAssembly, wasmDesc.value); 66 assertEq(WebAssembly, wasmDesc.value);
60 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); 67 //TODO assertEq(String(WebAssembly), "[object WebAssembly]");
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 assertEq(tbl.length, 2); 491 assertEq(tbl.length, 2);
485 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); 492 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/);
486 } 493 }
487 494
488 // 'WebAssembly.validate' function 495 // 'WebAssembly.validate' function
489 assertErrorMessage(() => WebAssembly.validate(), TypeError); 496 assertErrorMessage(() => WebAssembly.validate(), TypeError);
490 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError); 497 assertErrorMessage(() => WebAssembly.validate("hi"), TypeError);
491 assertEq(WebAssembly.validate(emptyModuleBinary), true); 498 assertEq(WebAssembly.validate(emptyModuleBinary), true);
492 // TODO: other ways for validate to return false. 499 // TODO: other ways for validate to return false.
493 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false); 500 assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false);
501 assertEq(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport), false);
494 502
495 // 'WebAssembly.compile' data property 503 // 'WebAssembly.compile' data property
496 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); 504 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile');
497 assertEq(typeof compileDesc.value, "function"); 505 assertEq(typeof compileDesc.value, "function");
498 assertEq(compileDesc.writable, true); 506 assertEq(compileDesc.writable, true);
499 assertEq(compileDesc.enumerable, false); 507 assertEq(compileDesc.enumerable, false);
500 assertEq(compileDesc.configurable, true); 508 assertEq(compileDesc.configurable, true);
501 509
502 // 'WebAssembly.compile' function 510 // 'WebAssembly.compile' function
503 let compile = WebAssembly.compile; 511 let compile = WebAssembly.compile;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 assertEq(result.instance instanceof Instance, true); 585 assertEq(result.instance instanceof Instance, true);
578 } 586 }
579 } 587 }
580 assertInstantiateSuccess(emptyModule); 588 assertInstantiateSuccess(emptyModule);
581 assertInstantiateSuccess(emptyModuleBinary); 589 assertInstantiateSuccess(emptyModuleBinary);
582 assertInstantiateSuccess(emptyModuleBinary.buffer); 590 assertInstantiateSuccess(emptyModuleBinary.buffer);
583 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); 591 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}});
584 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); 592 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}});
585 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); 593 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}});
586 } 594 }
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/instantiate-module-basic.js ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698