Update web-platform-tests to revision 386d27678c48bf468b8d374e2ba718e32185a5b7

This commit is contained in:
WPT Sync Bot 2019-04-11 22:38:06 -04:00
parent c24420ddbe
commit dd79cdc697
32 changed files with 336 additions and 167 deletions

View file

@ -1,3 +1,15 @@
/**
* `t` should be a function that takes at least three arguments:
*
* - the name of the test;
* - the expected error (to be passed to `assert_throws` or similar);
* - a function that takes a `WasmModuleBuilder` and initializes it;
* - (optionally) an options object.
*
* The function is expected to create a test that checks if instantiating a
* module with the result of the `WasmModuleBuilder` and the options object
* (if any) yields the correct error.
*/
function test_bad_imports(t) {
for (const value of [null, true, "", Symbol(), 1, 0.1, NaN]) {
t(`Non-object imports argument: ${format_value(value)}`,
@ -15,7 +27,7 @@ function test_bad_imports(t) {
builder => {
builder.addImport("module", "fn", kSig_v_v);
},
value);
imports);
}
t(`Missing imports argument`,

View file

@ -64,9 +64,9 @@ promise_test(t => {
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.compile(buffer));
}, "Empty buffer");
test(() => {
promise_test(t => {
const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0]));
assert_throws(new WebAssembly.CompileError(), () => WebAssembly.compile(buffer));
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.compile(buffer));
}, "Invalid code");
promise_test(() => {

View file

@ -76,6 +76,64 @@ for (const [name, fn] of instanceTestFactory) {
}, `${name}: Module argument`);
}
promise_test(() => {
const builder = new WasmModuleBuilder();
builder.addImportedGlobal("module", "global", kWasmI32);
const buffer = builder.toBuffer();
const order = [];
const imports = {
get module() {
order.push("module getter");
return {
get global() {
order.push("global getter");
return 0;
},
}
},
};
const expected = [
"module getter",
"global getter",
];
const p = WebAssembly.instantiate(buffer, imports);
assert_array_equals(order, []);
return p.then(result => {
assert_WebAssemblyInstantiatedSource(result);
assert_array_equals(order, expected);
});
}, "Synchronous options handling: Buffer argument");
promise_test(() => {
const builder = new WasmModuleBuilder();
builder.addImportedGlobal("module", "global", kWasmI32);
const buffer = builder.toBuffer();
const module = new WebAssembly.Module(buffer);
const order = [];
const imports = {
get module() {
order.push("module getter");
return {
get global() {
order.push("global getter");
return 0;
},
}
},
};
const expected = [
"module getter",
"global getter",
];
const p = WebAssembly.instantiate(module, imports);
assert_array_equals(order, expected);
return p.then(instance => assert_Instance(instance, {}));
}, "Synchronous options handling: Module argument");
promise_test(t => {
const buffer = new Uint8Array();
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.instantiate(buffer));