Chromium Code Reviews| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 assertEq(Module, moduleDesc.value); | 135 assertEq(Module, moduleDesc.value); |
| 136 assertEq(Module.length, 1); | 136 assertEq(Module.length, 1); |
| 137 assertEq(Module.name, "Module"); | 137 assertEq(Module.name, "Module"); |
| 138 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid den/); | 138 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid den/); |
| 139 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument s/); | 139 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument s/); |
| 140 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must be an ArrayBuffer or typed array object"); | 140 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must be an ArrayBuffer or typed array object"); |
| 141 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar rayBuffer or typed array object"); | 141 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar rayBuffer or typed array object"); |
| 142 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A rrayBuffer or typed array object"); | 142 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A rrayBuffer or typed array object"); |
| 143 assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to match magic number/); | 143 assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to match magic number/); |
| 144 assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to match magic number/); | 144 assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to match magic number/); |
| 145 assertErrorMessage( | |
| 146 () => new Module(importingModuleBinary, {'': {f: () => {}}}), TypeError, | |
| 147 /TODO error message/); | |
| 145 assertEq(new Module(emptyModuleBinary) instanceof Module, true); | 148 assertEq(new Module(emptyModuleBinary) instanceof Module, true); |
| 146 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); | 149 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); |
| 147 | 150 |
| 148 // 'WebAssembly.Module.prototype' data property | 151 // 'WebAssembly.Module.prototype' data property |
| 149 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); | 152 let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); |
| 150 assertEq(typeof moduleProtoDesc.value, "object"); | 153 assertEq(typeof moduleProtoDesc.value, "object"); |
| 151 assertEq(moduleProtoDesc.writable, false); | 154 assertEq(moduleProtoDesc.writable, false); |
| 152 assertEq(moduleProtoDesc.enumerable, false); | 155 assertEq(moduleProtoDesc.enumerable, false); |
| 153 assertEq(moduleProtoDesc.configurable, false); | 156 assertEq(moduleProtoDesc.configurable, false); |
| 154 | 157 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 assertInstantiateError([1], TypeError, /first argument must be a BufferSource/); | 605 assertInstantiateError([1], TypeError, /first argument must be a BufferSource/); |
| 603 assertInstantiateError([{}], TypeError, /first argument must be a BufferSource/) ; | 606 assertInstantiateError([{}], TypeError, /first argument must be a BufferSource/) ; |
| 604 assertInstantiateError([new Uint8Array()], CompileError, /failed to match magic number/); | 607 assertInstantiateError([new Uint8Array()], CompileError, /failed to match magic number/); |
| 605 assertInstantiateError([new ArrayBuffer()], CompileError, /failed to match magic number/); | 608 assertInstantiateError([new ArrayBuffer()], CompileError, /failed to match magic number/); |
| 606 assertInstantiateError([new Uint8Array("hi!")], CompileError, /failed to match m agic number/); | 609 assertInstantiateError([new Uint8Array("hi!")], CompileError, /failed to match m agic number/); |
| 607 assertInstantiateError([new ArrayBuffer("hi!")], CompileError, /failed to match magic number/); | 610 assertInstantiateError([new ArrayBuffer("hi!")], CompileError, /failed to match magic number/); |
| 608 assertInstantiateError([importingModule], TypeError, /second argument must be an object/); | 611 assertInstantiateError([importingModule], TypeError, /second argument must be an object/); |
| 609 assertInstantiateError([importingModule, null], TypeError, /second argument must be an object/); | 612 assertInstantiateError([importingModule, null], TypeError, /second argument must be an object/); |
| 610 assertInstantiateError([importingModuleBinary, null], TypeError, /second argumen t must be an object/); | 613 assertInstantiateError([importingModuleBinary, null], TypeError, /second argumen t must be an object/); |
| 611 assertInstantiateError([emptyModule, null], TypeError, /first argument must be a BufferSource/); | 614 assertInstantiateError([emptyModule, null], TypeError, /first argument must be a BufferSource/); |
| 612 assertInstantiateError([importingModule, {"":{f:()=>{}}}], TypeError, /first arg ument must be a BufferSource/); | |
| 613 assertInstantiateError([importingModuleBinary, null], TypeError, /TODO: error me ssages?/); | 615 assertInstantiateError([importingModuleBinary, null], TypeError, /TODO: error me ssages?/); |
| 614 assertInstantiateError([importingModuleBinary, undefined], TypeError, /TODO: err or messages?/); | 616 assertInstantiateError([importingModuleBinary, undefined], TypeError, /TODO: err or messages?/); |
| 615 assertInstantiateError([importingModuleBinary, {}], LinkError, /TODO: error mess ages?/); | 617 assertInstantiateError([importingModuleBinary, {}], LinkError, /TODO: error mess ages?/); |
| 616 assertInstantiateError([importingModuleBinary, {"":{g:()=>{}}}], LinkError, /TOD O: error messages?/); | 618 assertInstantiateError([importingModuleBinary, {"":{g:()=>{}}}], LinkError, /TOD O: error messages?/); |
| 617 assertInstantiateError([importingModuleBinary, {t:{f:()=>{}}}], LinkError, /TODO : error messages?/); | 619 assertInstantiateError([importingModuleBinary, {t:{f:()=>{}}}], LinkError, /TODO : error messages?/); |
| 618 assertInstantiateError([memoryImportingModuleBinary, null], TypeError, /TODO: er ror messages?/); | 620 assertInstantiateError([memoryImportingModuleBinary, null], TypeError, /TODO: er ror messages?/); |
| 619 assertInstantiateError([memoryImportingModuleBinary, undefined], TypeError, /TOD O: error messages?/); | 621 assertInstantiateError([memoryImportingModuleBinary, undefined], TypeError, /TOD O: error messages?/); |
| 620 assertInstantiateError([memoryImportingModuleBinary, {}], LinkError, /TODO: erro r messages?/); | 622 assertInstantiateError([memoryImportingModuleBinary, {}], LinkError, /TODO: erro r messages?/); |
| 621 assertInstantiateError([memoryImportingModuleBinary, {"mod": {"my_memory": scrat ch_memory}}], LinkError, /TODO: error messages?/); | 623 assertInstantiateError([memoryImportingModuleBinary, {"mod": {"my_memory": scrat ch_memory}}], LinkError, /TODO: error messages?/); |
| 622 assertInstantiateError([memoryImportingModuleBinary, {"": {"memory": scratch_mem ory}}], LinkError, /TODO: error messages?/); | 624 assertInstantiateError([memoryImportingModuleBinary, {"": {"memory": scratch_mem ory}}], LinkError, /TODO: error messages?/); |
| 623 | 625 |
| 624 function assertInstantiateSuccess(module_bytes, imports) { | 626 function assertInstantiateSuccess(module_or_bytes, imports) { |
| 625 var result = null; | 627 var result = null; |
| 626 instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e)); | 628 instantiate(module_or_bytes, imports) |
| 629 .then(r => result = r) | |
| 630 .catch(e => print(e)); | |
| 627 drainJobQueue(); | 631 drainJobQueue(); |
| 628 assertEq(result instanceof Instance, true); | 632 if (module_or_bytes instanceof Module) { |
| 633 assertEq(result instanceof Instance, true); | |
| 634 } else { | |
| 635 assertEq(result.module instanceof Module, true); | |
|
rossberg
2017/01/20 09:56:54
Nit: Using assertTrue would make this less redunda
Mircea Trofin
2017/01/20 16:29:53
Done, and fixed everywhere else, too.
| |
| 636 assertEq(result.instance instanceof Instance, true); | |
| 637 } | |
| 629 } | 638 } |
| 639 assertInstantiateSuccess(emptyModule); | |
| 630 assertInstantiateSuccess(emptyModuleBinary); | 640 assertInstantiateSuccess(emptyModuleBinary); |
| 631 assertInstantiateSuccess(emptyModuleBinary.buffer); | 641 assertInstantiateSuccess(emptyModuleBinary.buffer); |
| 642 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); | |
| 632 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 643 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
| 633 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 644 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
| 634 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch _memory}}); | 645 assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch _memory}}); |
| OLD | NEW |