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

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

Issue 2620263003: Implement Instance instances correctly; fix a few error cases (Closed)
Patch Set: Export flag 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/common/wasm/wasm-module-runner.cc ('k') | no next file » | 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // 'WebAssembly.Module' constructor function 127 // 'WebAssembly.Module' constructor function
128 let Module = WebAssembly.Module; 128 let Module = WebAssembly.Module;
129 assertEq(Module, moduleDesc.value); 129 assertEq(Module, moduleDesc.value);
130 assertEq(Module.length, 1); 130 assertEq(Module.length, 1);
131 assertEq(Module.name, "Module"); 131 assertEq(Module.name, "Module");
132 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid den/); 132 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid den/);
133 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument s/); 133 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument s/);
134 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must be an ArrayBuffer or typed array object"); 134 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must be an ArrayBuffer or typed array object");
135 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar rayBuffer or typed array object"); 135 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar rayBuffer or typed array object");
136 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A rrayBuffer or typed array object"); 136 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A rrayBuffer or typed array object");
137 //TODO assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /fai led to match magic number/); 137 assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to match magic number/);
138 //TODO assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /fa iled to match magic number/); 138 assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to match magic number/);
139 assertEq(new Module(emptyModuleBinary) instanceof Module, true); 139 assertEq(new Module(emptyModuleBinary) instanceof Module, true);
140 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); 140 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true);
141 141
142 // 'WebAssembly.Module.prototype' data property 142 // 'WebAssembly.Module.prototype' data property
143 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); 143 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype');
144 assertEq(typeof moduleProtoDesc.value, "object"); 144 assertEq(typeof moduleProtoDesc.value, "object");
145 assertEq(moduleProtoDesc.writable, false); 145 assertEq(moduleProtoDesc.writable, false);
146 assertEq(moduleProtoDesc.enumerable, false); 146 assertEq(moduleProtoDesc.enumerable, false);
147 assertEq(moduleProtoDesc.configurable, false); 147 assertEq(moduleProtoDesc.configurable, false);
148 148
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 assertEq(instanceDesc.configurable, true); 252 assertEq(instanceDesc.configurable, true);
253 253
254 // 'WebAssembly.Instance' constructor function 254 // 'WebAssembly.Instance' constructor function
255 let Instance = WebAssembly.Instance; 255 let Instance = WebAssembly.Instance;
256 assertEq(Instance, instanceDesc.value); 256 assertEq(Instance, instanceDesc.value);
257 assertEq(Instance.length, 1); 257 assertEq(Instance.length, 1);
258 assertEq(Instance.name, "Instance"); 258 assertEq(Instance.name, "Instance");
259 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb idden/); 259 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb idden/);
260 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W ebAssembly.Module"); 260 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W ebAssembly.Module");
261 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a WebAssembly.Module"); 261 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a WebAssembly.Module");
262 //TODO assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "sec ond argument must be an object"); 262 assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "second arg ument must be an object");
263 //TODO assertEq(new Instance(emptyModule) instanceof Instance, true); 263 assertEq(new Instance(emptyModule) instanceof Instance, true);
264 //TODO assertEq(new Instance(emptyModule, {}) instanceof Instance, true); 264 assertEq(new Instance(emptyModule, {}) instanceof Instance, true);
265 265
266 // 'WebAssembly.Instance.prototype' data property 266 // 'WebAssembly.Instance.prototype' data property
267 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); 267 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype');
268 assertEq(typeof instanceProtoDesc.value, "object"); 268 assertEq(typeof instanceProtoDesc.value, "object");
269 assertEq(instanceProtoDesc.writable, false); 269 assertEq(instanceProtoDesc.writable, false);
270 assertEq(instanceProtoDesc.enumerable, false); 270 assertEq(instanceProtoDesc.enumerable, false);
271 assertEq(instanceProtoDesc.configurable, false); 271 assertEq(instanceProtoDesc.configurable, false);
272 272
273 // 'WebAssembly.Instance.prototype' object 273 // 'WebAssembly.Instance.prototype' object
274 let instanceProto = Instance.prototype; 274 let instanceProto = Instance.prototype;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 assertEq(result.instance instanceof Instance, true); 605 assertEq(result.instance instanceof Instance, true);
606 } 606 }
607 } 607 }
608 assertInstantiateSuccess(emptyModule); 608 assertInstantiateSuccess(emptyModule);
609 assertInstantiateSuccess(emptyModuleBinary); 609 assertInstantiateSuccess(emptyModuleBinary);
610 assertInstantiateSuccess(emptyModuleBinary.buffer); 610 assertInstantiateSuccess(emptyModuleBinary.buffer);
611 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); 611 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}});
612 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); 612 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}});
613 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); 613 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}});
614 } 614 }
OLDNEW
« no previous file with comments | « test/common/wasm/wasm-module-runner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698