diff --git a/test/harness/async_index.js b/test/harness/async_index.js index 5812f347fd..8a01b21211 100644 --- a/test/harness/async_index.js +++ b/test/harness/async_index.js @@ -52,6 +52,15 @@ const EXPECT_INVALID = false; /* DATA **********************************************************************/ +let hostrefs = {}; +let hostsym = Symbol("hostref"); +function hostref(s) { + if (! (s in hostrefs)) hostrefs[s] = {[hostsym]: s}; + return hostrefs[s]; +} +function eq_ref(x, y) { + return x === y ? 1 : 0; +} let externrefs = {}; let externsym = Symbol("externref"); function externref(s) { @@ -86,6 +95,8 @@ function reinitializeRegistry() { chain = chain.then(_ => { let spectest = { + hostref: hostref, + eq_ref: eq_ref, externref: externref, is_externref: is_externref, is_funcref: is_funcref, @@ -182,22 +193,22 @@ function assert_invalid_custom(bytes) { const assert_malformed_custom = assert_invalid_custom; -function instance(bytes, imports, valid = true) { +function instance(module, imports, valid = true) { const test = valid ? "Test that WebAssembly instantiation succeeds" : "Test that WebAssembly instantiation fails"; const loc = new Error().stack.toString().replace("Error", ""); - chain = Promise.all([imports, chain]) + chain = Promise.all([module, imports, chain]) .then(values => { - let imports = values[0] ? values[0] : registry; - return WebAssembly.instantiate(binary(bytes), imports); + let imports = values[1] ? values[1] : registry; + return WebAssembly.instantiate(values[0], imports); }) .then( - pair => { + inst => { uniqueTest(_ => { assert_true(valid, loc); }, test); - return pair.instance; + return inst; }, error => { uniqueTest(_ => { diff --git a/test/harness/sync_index.js b/test/harness/sync_index.js index 069c97dff2..5c4549be2e 100644 --- a/test/harness/sync_index.js +++ b/test/harness/sync_index.js @@ -66,6 +66,15 @@ const EXPECT_INVALID = false; /* DATA **********************************************************************/ +let hostrefs = {}; +let hostsym = Symbol("hostref"); +function hostref(s) { + if (! (s in hostrefs)) hostrefs[s] = {[hostsym]: s}; + return hostrefs[s]; +} +function eq_ref(x, y) { + return x === y ? 1 : 0; +} let externrefs = {}; let externsym = Symbol("externref"); function externref(s) { @@ -96,6 +105,8 @@ function reinitializeRegistry() { return; let spectest = { + hostref: hostref, + eq_ref: eq_ref, externref: externref, is_externref: is_externref, is_funcref: is_funcref, @@ -203,7 +214,7 @@ function assert_invalid_custom(bytes) { const assert_malformed_custom = assert_invalid_custom; -function instance(bytes, imports = registry, valid = true) { +function instance(mod, imports = registry, valid = true) { if (imports instanceof Result) { if (imports.isError()) return imports; @@ -212,10 +223,9 @@ function instance(bytes, imports = registry, valid = true) { let err = null; - let m, i; + let i; try { - let m = module(bytes); - i = new WebAssembly.Instance(m, imports); + i = new WebAssembly.Instance(mod, imports); } catch(e) { err = e; }