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 function instantiateInWorker() { |
| 6 // the file incrementer.wasm is copied from |
| 7 // //v8/test/mjsunit/wasm. This is because currently we cannot |
| 8 // reference files outside the LayoutTests folder. When wasm format |
| 9 // changes require that file to be updated, there is a test on the |
| 10 // v8 side (same folder), ensure-wasm-binaries-up-to-date.js, which |
| 11 // fails and will require incrementer.wasm to be updated on that side. |
| 12 return fetch('incrementer.wasm') |
| 13 .then(response => { |
| 14 if (!response.ok) throw new Error(response.statusText); |
| 15 return response.arrayBuffer(); |
| 16 }) |
| 17 .then(data => { |
| 18 var mod = new WebAssembly.Module(data); |
| 19 var worker = new Worker("wasm_serialization_worker.js"); |
| 20 return new Promise((resolve, reject) => { |
| 21 worker.postMessage(mod); |
| 22 worker.onmessage = function(event) { |
| 23 resolve(event.data); |
| 24 } |
| 25 }); |
| 26 }) |
| 27 .then(data => assert_equals(data, 43)) |
| 28 .catch(error => assert_unreached(error)); |
| 29 } |
OLD | NEW |