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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 // Utility function. Use this to return data back to the C++ test.
6 function respondToTestHarness(data) {
7 if (!window.domAutomationController) {
8 console.log("ERROR: no automation controller available");
9 return;
10 }
11 window.domAutomationController.send(data);
12 }
13
14 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.
15
16 // Compile a module here, but instantiate it in a worker.
17 // Tests serialization/deserialization.
18 // The file incrementer.wasm is fetched from //v8/test/mjsunit/wasm. The
19 // C test needs to setup the server to include that path.
20 function test_instantiateInWorker() {
21 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.
22 req.addEventListener('load', function(e) {
23 if (req.readyState === xhrReadyState_DONE) {
24 var data = req.response;
25 var mod = new WebAssembly.Module(data);
26 var worker = new Worker("wasm_serialization_worker.js");
27 worker.postMessage(mod);
28 worker.onmessage = function(event) {
29 respondToTestHarness(event.data);
30 }
31 }
32 });
33 req.addEventListener('error', function(e) {
34 respondToTestHarness('error: ' + e);
35 });
36 req.open('GET', 'incrementer.wasm', true);
37 req.responseType = 'arraybuffer';
38 req.send();
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698