mirror of
https://github.com/servo/servo.git
synced 2025-08-23 06:15:35 +01:00
Update web-platform-tests to revision d8b8e0b8efe993a37404d6c6fc75e16fdc16b7d8
This commit is contained in:
parent
abc0f50d20
commit
e07315e6af
221 changed files with 7334 additions and 774 deletions
24
tests/wpt/web-platform-tests/wasm/webapi/abort.any.js
Normal file
24
tests/wpt/web-platform-tests/wasm/webapi/abort.any.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const methods = [
|
||||
"compileStreaming",
|
||||
"instantiateStreaming",
|
||||
];
|
||||
|
||||
for (const method of methods) {
|
||||
promise_test(async t => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
controller.abort();
|
||||
const request = fetch('../incrementer.wasm', { signal });
|
||||
return promise_rejects(t, 'AbortError', WebAssembly[method](request),
|
||||
`${method} should reject`);
|
||||
}, `${method}() on an already-aborted request should reject with AbortError`);
|
||||
|
||||
promise_test(async t => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
const request = fetch('../incrementer.wasm', { signal });
|
||||
const promise = WebAssembly[method](request);
|
||||
controller.abort();
|
||||
return promise_rejects(t, 'AbortError', promise, `${method} should reject`);
|
||||
}, `${method}() synchronously followed by abort should reject with AbortError`);
|
||||
}
|
20
tests/wpt/web-platform-tests/wasm/webapi/body.any.js
Normal file
20
tests/wpt/web-platform-tests/wasm/webapi/body.any.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/wasm/jsapi/wasm-constants.js
|
||||
// META: script=/wasm/jsapi/wasm-module-builder.js
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
promise_test(t => {
|
||||
const buffer = new WasmModuleBuilder().toBuffer();
|
||||
const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
|
||||
argument.arrayBuffer();
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](argument));
|
||||
}, `${method} after consumption`);
|
||||
|
||||
promise_test(t => {
|
||||
const buffer = new WasmModuleBuilder().toBuffer();
|
||||
const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
|
||||
const promise = WebAssembly[method](argument);
|
||||
argument.arrayBuffer();
|
||||
return promise_rejects(t, new TypeError(), promise);
|
||||
}, `${method} before consumption`);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/wasm/jsapi/assertions.js
|
||||
|
||||
const contenttypes = [
|
||||
const invalidContentTypes = [
|
||||
"",
|
||||
"application/javascript",
|
||||
"application/octet-stream",
|
||||
|
@ -10,7 +11,7 @@ const contenttypes = [
|
|||
"application/wasm;charset=UTF-8",
|
||||
];
|
||||
|
||||
for (const contenttype of contenttypes) {
|
||||
for (const contenttype of invalidContentTypes) {
|
||||
promise_test(t => {
|
||||
const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`);
|
||||
return promise_rejects(t, new TypeError(), WebAssembly.compileStreaming(response));
|
||||
|
@ -21,3 +22,24 @@ for (const contenttype of contenttypes) {
|
|||
return promise_rejects(t, new TypeError(), WebAssembly.instantiateStreaming(response));
|
||||
}, `Response with Content-Type ${format_value(contenttype)}: instantiateStreaming`);
|
||||
}
|
||||
|
||||
const validContentTypes = [
|
||||
"application/wasm",
|
||||
"APPLICATION/wasm",
|
||||
"APPLICATION/WASM",
|
||||
];
|
||||
|
||||
for (const contenttype of validContentTypes) {
|
||||
promise_test(async t => {
|
||||
const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`);
|
||||
const module = await WebAssembly.compileStreaming(response);
|
||||
assert_equals(Object.getPrototypeOf(module), WebAssembly.Module.prototype,
|
||||
"prototype");
|
||||
}, `Response with Content-Type ${format_value(contenttype)}: compileStreaming`);
|
||||
|
||||
promise_test(async t => {
|
||||
const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`);
|
||||
const result = await WebAssembly.instantiateStreaming(response);
|
||||
assert_WebAssemblyInstantiatedSource(result);
|
||||
}, `Response with Content-Type ${format_value(contenttype)}: instantiateStreaming`);
|
||||
}
|
||||
|
|
20
tests/wpt/web-platform-tests/wasm/webapi/empty-body.any.js
Normal file
20
tests/wpt/web-platform-tests/wasm/webapi/empty-body.any.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
// META: global=window,worker
|
||||
|
||||
const invalidArguments = [
|
||||
[() => new Response(undefined, { headers: { "Content-Type": "application/wasm" } }), "no body"],
|
||||
[() => new Response("", { headers: { "Content-Type": "application/wasm" } }), "empty body"],
|
||||
];
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
for (const [argumentFactory, name] of invalidArguments) {
|
||||
promise_test(t => {
|
||||
const argument = argumentFactory();
|
||||
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly[method](argument));
|
||||
}, `${method}: ${name}`);
|
||||
|
||||
promise_test(t => {
|
||||
const argument = Promise.resolve(argumentFactory());
|
||||
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly[method](argument));
|
||||
}, `${method}: ${name} in a promise`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/wasm/jsapi/wasm-constants.js
|
||||
// META: script=/wasm/jsapi/wasm-module-builder.js
|
||||
// META: script=/wasm/jsapi/bad-imports.js
|
||||
|
||||
test_bad_imports((name, error, build, ...args) => {
|
||||
promise_test(t => {
|
||||
const builder = new WasmModuleBuilder();
|
||||
build(builder);
|
||||
const buffer = builder.toBuffer();
|
||||
const response = new Response(buffer, { "headers": { "Content-Type": "application/wasm" } });
|
||||
return promise_rejects(t, error, WebAssembly.instantiateStreaming(response, ...args));
|
||||
}, name);
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/wasm/jsapi/wasm-constants.js
|
||||
// META: script=/wasm/jsapi/wasm-module-builder.js
|
||||
// META: script=/wasm/jsapi/assertions.js
|
||||
// META: script=/wasm/jsapi/instanceTestFactory.js
|
||||
|
||||
let emptyModuleBinary;
|
||||
setup(() => {
|
||||
emptyModuleBinary = new WasmModuleBuilder().toBuffer();
|
||||
});
|
||||
|
||||
for (const [name, fn] of instanceTestFactory) {
|
||||
promise_test(async () => {
|
||||
const { buffer, args, exports, verify } = fn();
|
||||
const response = new Response(buffer, { "headers": { "Content-Type": "application/wasm" } });
|
||||
const result = await WebAssembly.instantiateStreaming(response, ...args);
|
||||
assert_WebAssemblyInstantiatedSource(result, exports);
|
||||
verify(result.instance);
|
||||
}, name);
|
||||
}
|
28
tests/wpt/web-platform-tests/wasm/webapi/invalid-args.any.js
Normal file
28
tests/wpt/web-platform-tests/wasm/webapi/invalid-args.any.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
// META: global=window,worker
|
||||
|
||||
const invalidArguments = [
|
||||
[undefined],
|
||||
[null],
|
||||
[true],
|
||||
["test"],
|
||||
[Symbol()],
|
||||
[0],
|
||||
[0.1],
|
||||
[NaN],
|
||||
[{}, "Empty object"],
|
||||
[Response, "Response interface object"],
|
||||
[Response.prototype, "Response interface prototype object"],
|
||||
];
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
for (const [argument, name = format_value(argument)] of invalidArguments) {
|
||||
promise_test(t => {
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](argument));
|
||||
}, `${method}: ${name}`);
|
||||
|
||||
promise_test(t => {
|
||||
const promise = Promise.resolve(argument);
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](argument));
|
||||
}, `${method}: ${name} in a promise`);
|
||||
}
|
||||
}
|
16
tests/wpt/web-platform-tests/wasm/webapi/invalid-code.any.js
Normal file
16
tests/wpt/web-platform-tests/wasm/webapi/invalid-code.any.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/wasm/jsapi/wasm-constants.js
|
||||
// META: script=/wasm/jsapi/wasm-module-builder.js
|
||||
|
||||
let emptyModuleBinary;
|
||||
setup(() => {
|
||||
emptyModuleBinary = new WasmModuleBuilder().toBuffer();
|
||||
});
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
promise_test(t => {
|
||||
const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0]));
|
||||
const response = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
|
||||
return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly[method](response));
|
||||
}, `Invalid code: ${method}`);
|
||||
}
|
15
tests/wpt/web-platform-tests/wasm/webapi/origin.sub.any.js
Normal file
15
tests/wpt/web-platform-tests/wasm/webapi/origin.sub.any.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
// META: global=window,worker
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
promise_test(t => {
|
||||
const url = "http://{{domains[www]}}:{{ports[http][0]}}/wasm/incrementer.wasm";
|
||||
const response = fetch(url, { "mode": "no-cors" });
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](response));
|
||||
}, `Opaque response: ${method}`);
|
||||
|
||||
promise_test(t => {
|
||||
const url = "/fetch/api/resources/redirect.py?redirect_status=301&location=/wasm/incrementer.wasm";
|
||||
const response = fetch(url, { "mode": "no-cors", "redirect": "manual" });
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](response));
|
||||
}, `Opaque redirect response: ${method}`);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// META: global=window,worker
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
promise_test(t => {
|
||||
const error = { "name": "custom error" };
|
||||
const promise = Promise.reject(error);
|
||||
return promise_rejects(t, error, WebAssembly[method](promise));
|
||||
}, `${method}`);
|
||||
}
|
21
tests/wpt/web-platform-tests/wasm/webapi/status.any.js
Normal file
21
tests/wpt/web-platform-tests/wasm/webapi/status.any.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
// META: global=window,worker
|
||||
|
||||
const statuses = [
|
||||
0,
|
||||
300,
|
||||
400,
|
||||
404,
|
||||
500,
|
||||
600,
|
||||
700,
|
||||
999,
|
||||
];
|
||||
|
||||
for (const method of ["compileStreaming", "instantiateStreaming"]) {
|
||||
for (const status of statuses) {
|
||||
promise_test(t => {
|
||||
const response = fetch(`status.py?status=${status}`);
|
||||
return promise_rejects(t, new TypeError(), WebAssembly[method](response));
|
||||
}, `Response with status ${status}: ${method}`);
|
||||
}
|
||||
}
|
4
tests/wpt/web-platform-tests/wasm/webapi/status.py
Normal file
4
tests/wpt/web-platform-tests/wasm/webapi/status.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
def main(request, response):
|
||||
status = int(request.GET["status"])
|
||||
module = b"\0asm\1\0\0\0"
|
||||
return status, [("Content-Type", "application/wasm")], module
|
Loading…
Add table
Add a link
Reference in a new issue