mirror of
https://github.com/servo/servo.git
synced 2025-09-05 20:48:22 +01:00
Update web-platform-tests to revision 386d27678c48bf468b8d374e2ba718e32185a5b7
This commit is contained in:
parent
c24420ddbe
commit
dd79cdc697
32 changed files with 336 additions and 167 deletions
|
@ -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`,
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue