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

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

Issue 2780693003: [wasm] response-based compile APIs (Closed)
Patch Set: simplify 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 side-by-side diff with in-line comments
Download patch
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..dc2ebcb86532ad1dbb04f87ec0da82025db6f6e5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_response_apis.js
@@ -0,0 +1,48 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// 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));
+}

Powered by Google App Engine
This is Rietveld 408576698