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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js

Issue 2780693003: [wasm] response-based compile APIs (Closed)
Patch Set: . Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved.
yhirano 2017/04/07 07:39:47 2017
Mircea Trofin 2017/04/07 15:33:08 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 function TestStreamedCompile() {
7 return fetch('incrementer.wasm')
8 .then(WebAssembly.compile)
9 .then(m => new WebAssembly.Instance(m))
10 .then(i => assert_equals(5, i.exports.increment(4)));
11 }
12
13 function TestShortFormStreamedCompile() {
14 return WebAssembly.compile(fetch('incrementer.wasm'))
15 .then(m => new WebAssembly.Instance(m))
16 .then(i => assert_equals(5, i.exports.increment(4)));
17 }
18
19 function NegativeTestStreamedCompilePromise() {
20 return WebAssembly.compile(new Promise((resolve, reject)=>{resolve(5);}))
21 .then(assert_unreached,
22 e => assert_true(e instanceof TypeError));
23 }
24
25 function BlankResponse() {
26 return WebAssembly.compile(new Response())
27 .then(assert_unreached,
28 e => assert_true(e instanceof TypeError));
29 }
30
31 function FromArrayBuffer() {
32 return fetch('incrementer.wasm')
33 .then(r => r.arrayBuffer())
34 .then(arr => new Response(arr))
35 .then(WebAssembly.compile)
36 .then(m => new WebAssembly.Instance(m))
37 .then(i => assert_equals(6, i.exports.increment(5)));
38 }
39
40 function FromInvalidArrayBuffer() {
41 var arr = new ArrayBuffer(10);
42 var view = new Uint8Array(arr);
43 for (var i = 0; i < view.length; ++i) view[i] = i;
44
45 return WebAssembly.compile(new Response(arr))
46 .then(assert_unreached,
47 e => assert_true(e instanceof Error));
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698