OLD | NEW |
(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 function test_instantiateInWorker() { |
| 15 fetch('incrementer.wasm') |
| 16 .then(response => { |
| 17 if (!response.ok) throw new Error(response.statusText); |
| 18 return response.arrayBuffer(); |
| 19 }) |
| 20 .then(data => { |
| 21 var mod = new WebAssembly.Module(data); |
| 22 var worker = new Worker("wasm_serialization_worker.js"); |
| 23 worker.postMessage(mod); |
| 24 worker.onmessage = function(event) { |
| 25 respondToTestHarness(event.data); |
| 26 } |
| 27 }) |
| 28 .catch(error => respondToTestHarness(error.message)); |
| 29 } |
OLD | NEW |