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

Unified Diff: chrome/test/data/wasm/wasm_tests.js

Issue 2255673003: [wasm] Support wasm module structured cloning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android/windows Created 4 years, 4 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: chrome/test/data/wasm/wasm_tests.js
diff --git a/chrome/test/data/wasm/wasm_tests.js b/chrome/test/data/wasm/wasm_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..e3b191ada9edbe745828fe1aad6f177ce109ed51
--- /dev/null
+++ b/chrome/test/data/wasm/wasm_tests.js
@@ -0,0 +1,39 @@
+// Copyright 2016 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.
+
+// Utility function. Use this to return data back to the C++ test.
+function respondToTestHarness(data) {
+ if (!window.domAutomationController) {
+ console.log("ERROR: no automation controller available");
+ return;
+ }
+ window.domAutomationController.send(data);
+}
+
+var xhrReadyState_DONE = 4;
jsbell 2016/08/18 16:48:02 You can rely on XMLHttpRequest.DONE being defined
Mircea Trofin 2016/08/18 17:34:08 Oh! Nice! why the "but"? Would we run these tests
jsbell 2016/08/18 18:13:14 Just that if you replace XHR with fetch() you don'
Mircea Trofin 2016/08/18 23:02:59 Done.
+
+// Compile a module here, but instantiate it in a worker.
+// Tests serialization/deserialization.
+// The file incrementer.wasm is fetched from //v8/test/mjsunit/wasm. The
+// C test needs to setup the server to include that path.
+function test_instantiateInWorker() {
+ var req = new XMLHttpRequest();
jsbell 2016/08/18 16:48:02 ... can you use fetch() here instead of XHR since
Mircea Trofin 2016/08/18 17:34:08 Acknowledged.
Mircea Trofin 2016/08/18 23:02:59 Done.
+ req.addEventListener('load', function(e) {
+ if (req.readyState === xhrReadyState_DONE) {
+ var data = req.response;
+ var mod = new WebAssembly.Module(data);
+ var worker = new Worker("wasm_serialization_worker.js");
+ worker.postMessage(mod);
+ worker.onmessage = function(event) {
+ respondToTestHarness(event.data);
+ }
+ }
+ });
+ req.addEventListener('error', function(e) {
+ respondToTestHarness('error: ' + e);
+ });
+ req.open('GET', 'incrementer.wasm', true);
+ req.responseType = 'arraybuffer';
+ req.send();
+}

Powered by Google App Engine
This is Rietveld 408576698