Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js b/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9481b4ec44414b4834abff484c7784f5af835bd7 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js |
| @@ -0,0 +1,48 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| + |
| +function TestStreamedCompile() { |
| + return fetch('incrementer.wasm') |
| + .then(WebAssembly.compile) |
| + .then(m => new WebAssembly.Instance(m)) |
| + .then(i => assert_equals(5, i.exports.increment(4))); |
| +} |
| + |
| +function TestShortFormStreamedCompile() { |
| + return WebAssembly.compile(fetch('incrementer.wasm')) |
| + .then(m => new WebAssembly.Instance(m)) |
| + .then(i => assert_equals(5, i.exports.increment(4))); |
| +} |
| + |
| +function NegativeTestStreamedCompilePromise() { |
| + return WebAssembly.compile(new Promise((resolve, reject)=>{resolve(5);})) |
| + .then(assert_unreached, |
| + e => assert_true(e instanceof TypeError)); |
| +} |
| + |
| +function BlankResponse() { |
| + return WebAssembly.compile(new Response()) |
| + .then(assert_unreached, |
| + e => assert_true(e instanceof TypeError)); |
| +} |
| + |
| +function FromArrayBuffer() { |
| + return fetch('incrementer.wasm') |
| + .then(r => r.arrayBuffer()) |
| + .then(arr => new Response(arr)) |
| + .then(WebAssembly.compile) |
| + .then(m => new WebAssembly.Instance(m)) |
| + .then(i => assert_equals(6, i.exports.increment(5))); |
| +} |
| + |
| +function FromInvalidArrayBuffer() { |
| + var arr = new ArrayBuffer(10); |
| + var view = new Uint8Array(arr); |
| + for (var i = 0; i < view.length; ++i) view[i] = i; |
| + |
| + return WebAssembly.compile(new Response(arr)) |
| + .then(assert_unreached, |
| + e => assert_true(e instanceof Error)); |
| +} |