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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/wasm/wasm-limits-tests.js

Issue 2702953002: [wasm] Block compile/instantiate of large array buffers (Closed)
Patch Set: tests Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var limit = Math.pow(2, 12);
6
7 function TestBuffersAreCorrect() {
8 var buffs = createTestBuffers(limit);
9 assert_equals(buffs.small.byteLength, limit);
10 assert_equals(buffs.large.byteLength, limit + 1);
11 }
12
13 function compileFailsWithError(buffer, error_type) {
14 try {
15 new WebAssembly.Module(buffer);
16 } catch (e) {
17 assert_true(e instanceof error_type);
18 }
19 }
20
21 function TestSyncCompile() {
22 var buffs = createTestBuffers(limit);
23 assert_true(new WebAssembly.Module(buffs.small) instanceof WebAssembly.Module) ;
bradnelson 2017/02/18 22:16:22 >80
Mircea Trofin 2017/02/19 00:18:33 Done.
24 compileFailsWithError(buffs.large, RangeError);
25 }
26
27 function TestPromiseCompile() {
28 return WebAssembly.compile(createTestBuffers(limit).large)
29 .then(m => assert_true(m instanceof WebAssembly.Module));
30 }
31
32 function TestWorkerCompileAndInstantiate() {
33 var worker = new Worker("wasm-limits-worker.js");
34 return new Promise((resolve, reject) => {
35 worker.postMessage(createTestBuffers(limit).large);
36 worker.onmessage = function(event) {
37 resolve(event.data);
38 }
39 })
40 .then(ans => assert_true(ans),
41 assert_unreached);
42 }
43
44 function TestPromiseCompileSyncInstantiate() {
45 return WebAssembly.compile(createTestBuffers(limit).large)
46 .then (m => new WebAssembly.Instance(m))
47 .then(assert_unreached,
48 e => assert_true(e instanceof RangeError));
49 }
50
51 function TestPromiseCompileAsyncInstantiateFromBuffer() {
52 return WebAssembly.instantiate(createTestBuffers(limit).large)
53 .then(i => assert_true(i.instance instanceof WebAssembly.Instance),
54 assert_unreached);
55 }
56
57 function TestPromiseCompileAsyncInstantiateFromModule() {
58 return WebAssembly.compile(createTestBuffers(limit).large)
59 .then(m => {
60 assert_true(m instanceof WebAssembly.Module);
61 return WebAssembly.instantiate(m).
62 then(i => assert_true(i instanceof WebAssembly.Instance),
63 assert_unreached);
64 },
65 assert_unreached);
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698