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

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: Updated after V8 side landed 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)
24 instanceof WebAssembly.Module);
25 compileFailsWithError(buffs.large, RangeError);
26 }
27
28 function TestPromiseCompile() {
29 return WebAssembly.compile(createTestBuffers(limit).large)
30 .then(m => assert_true(m instanceof WebAssembly.Module));
31 }
32
33 function TestWorkerCompileAndInstantiate() {
34 var worker = new Worker("wasm-limits-worker.js");
35 return new Promise((resolve, reject) => {
36 worker.postMessage(createTestBuffers(limit).large);
37 worker.onmessage = function(event) {
38 resolve(event.data);
39 }
40 })
41 .then(ans => assert_true(ans),
42 assert_unreached);
43 }
44
45 function TestPromiseCompileSyncInstantiate() {
46 return WebAssembly.compile(createTestBuffers(limit).large)
47 .then (m => new WebAssembly.Instance(m))
48 .then(assert_unreached,
49 e => assert_true(e instanceof RangeError));
50 }
51
52 function TestPromiseCompileAsyncInstantiateFromBuffer() {
53 return WebAssembly.instantiate(createTestBuffers(limit).large)
54 .then(i => assert_true(i.instance instanceof WebAssembly.Instance),
55 assert_unreached);
56 }
57
58 function TestPromiseCompileAsyncInstantiateFromModule() {
59 return WebAssembly.compile(createTestBuffers(limit).large)
60 .then(m => {
61 assert_true(m instanceof WebAssembly.Module);
62 return WebAssembly.instantiate(m).
63 then(i => assert_true(i instanceof WebAssembly.Instance),
64 assert_unreached);
65 },
66 assert_unreached);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698