Chromium Code Reviews| Index: chrome/test/data/wasm/wasm_serialization_worker.js |
| diff --git a/chrome/test/data/wasm/wasm_serialization_worker.js b/chrome/test/data/wasm/wasm_serialization_worker.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2281e7e682da54c0d9339ce1d4488b513a3276a5 |
| --- /dev/null |
| +++ b/chrome/test/data/wasm/wasm_serialization_worker.js |
| @@ -0,0 +1,24 @@ |
| +// 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. |
| + |
| +onmessage = function(e) { |
| + var compiled_module = e.data; |
| + var instance = new WebAssembly.Instance(compiled_module); |
| + if (typeof instance === "undefined") { |
|
jsbell
2016/08/18 16:48:02
nit: why not just `instance === undefined` ?
Mircea Trofin
2016/08/18 17:34:08
Acknowledged.
Mircea Trofin
2016/08/18 23:02:59
Done.
|
| + postMessage("error!"); |
| + return; |
| + } |
| + var entrypoint = instance.exports["increment"]; |
| + |
| + if (typeof entrypoint != "function") { |
|
jsbell
2016/08/18 16:48:02
nit: might as well be consistent and use !==
Mircea Trofin
2016/08/18 17:34:08
Acknowledged.
Mircea Trofin
2016/08/18 23:02:59
Done.
|
| + postMessage("error!"); |
| + return; |
| + } |
| + |
| + var ret = entrypoint(42); |
| + if (ret != 43) { |
| + postMessage("didn't get 43"); |
|
jsbell
2016/08/18 16:48:02
Do you want a return after this postMessage too, s
Mircea Trofin
2016/08/18 17:34:08
Acknowledged.
Mircea Trofin
2016/08/18 23:02:59
Actually, don't need to post that string, can just
|
| + } |
| + postMessage(ret); |
| +} |