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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // 'WebAssembly.Module' constructor function | 120 // 'WebAssembly.Module' constructor function |
121 let Module = WebAssembly.Module; | 121 let Module = WebAssembly.Module; |
122 assertEq(Module, moduleDesc.value); | 122 assertEq(Module, moduleDesc.value); |
123 assertEq(Module.length, 1); | 123 assertEq(Module.length, 1); |
124 assertEq(Module.name, "Module"); | 124 assertEq(Module.name, "Module"); |
125 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid
den/); | 125 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid
den/); |
126 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument
s/); | 126 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument
s/); |
127 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must
be an ArrayBuffer or typed array object"); | 127 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must
be an ArrayBuffer or typed array object"); |
128 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar
rayBuffer or typed array object"); | 128 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar
rayBuffer or typed array object"); |
129 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A
rrayBuffer or typed array object"); | 129 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A
rrayBuffer or typed array object"); |
130 //TODO assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /fai
led to match magic number/); | 130 assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to
match magic number/); |
131 //TODO assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /fa
iled to match magic number/); | 131 assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to
match magic number/); |
132 assertEq(new Module(emptyModuleBinary) instanceof Module, true); | 132 assertEq(new Module(emptyModuleBinary) instanceof Module, true); |
133 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); | 133 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); |
134 | 134 |
135 // 'WebAssembly.Module.prototype' data property | 135 // 'WebAssembly.Module.prototype' data property |
136 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); | 136 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); |
137 assertEq(typeof moduleProtoDesc.value, "object"); | 137 assertEq(typeof moduleProtoDesc.value, "object"); |
138 assertEq(moduleProtoDesc.writable, false); | 138 assertEq(moduleProtoDesc.writable, false); |
139 assertEq(moduleProtoDesc.enumerable, false); | 139 assertEq(moduleProtoDesc.enumerable, false); |
140 assertEq(moduleProtoDesc.configurable, false); | 140 assertEq(moduleProtoDesc.configurable, false); |
141 | 141 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 assertEq(instanceDesc.configurable, true); | 245 assertEq(instanceDesc.configurable, true); |
246 | 246 |
247 // 'WebAssembly.Instance' constructor function | 247 // 'WebAssembly.Instance' constructor function |
248 let Instance = WebAssembly.Instance; | 248 let Instance = WebAssembly.Instance; |
249 assertEq(Instance, instanceDesc.value); | 249 assertEq(Instance, instanceDesc.value); |
250 assertEq(Instance.length, 1); | 250 assertEq(Instance.length, 1); |
251 assertEq(Instance.name, "Instance"); | 251 assertEq(Instance.name, "Instance"); |
252 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb
idden/); | 252 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb
idden/); |
253 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W
ebAssembly.Module"); | 253 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W
ebAssembly.Module"); |
254 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a
WebAssembly.Module"); | 254 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a
WebAssembly.Module"); |
255 //TODO assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "sec
ond argument must be an object"); | 255 assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "second arg
ument must be an object"); |
256 //TODO assertEq(new Instance(emptyModule) instanceof Instance, true); | 256 assertEq(new Instance(emptyModule) instanceof Instance, true); |
257 //TODO assertEq(new Instance(emptyModule, {}) instanceof Instance, true); | 257 assertEq(new Instance(emptyModule, {}) instanceof Instance, true); |
258 | 258 |
259 // 'WebAssembly.Instance.prototype' data property | 259 // 'WebAssembly.Instance.prototype' data property |
260 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); | 260 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); |
261 assertEq(typeof instanceProtoDesc.value, "object"); | 261 assertEq(typeof instanceProtoDesc.value, "object"); |
262 assertEq(instanceProtoDesc.writable, false); | 262 assertEq(instanceProtoDesc.writable, false); |
263 assertEq(instanceProtoDesc.enumerable, false); | 263 assertEq(instanceProtoDesc.enumerable, false); |
264 assertEq(instanceProtoDesc.configurable, false); | 264 assertEq(instanceProtoDesc.configurable, false); |
265 | 265 |
266 // 'WebAssembly.Instance.prototype' object | 266 // 'WebAssembly.Instance.prototype' object |
267 let instanceProto = Instance.prototype; | 267 let instanceProto = Instance.prototype; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 assertEq(result.instance instanceof Instance, true); | 597 assertEq(result.instance instanceof Instance, true); |
598 } | 598 } |
599 } | 599 } |
600 assertInstantiateSuccess(emptyModule); | 600 assertInstantiateSuccess(emptyModule); |
601 assertInstantiateSuccess(emptyModuleBinary); | 601 assertInstantiateSuccess(emptyModuleBinary); |
602 assertInstantiateSuccess(emptyModuleBinary.buffer); | 602 assertInstantiateSuccess(emptyModuleBinary.buffer); |
603 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); | 603 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); |
604 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 604 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
605 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 605 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
606 } | 606 } |
OLD | NEW |