mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
Update web-platform-tests to revision 2be2d7e3abcde5baded3448b85d0bb88e58d3cf7
This commit is contained in:
parent
c9c5f8b9e5
commit
5a55ae1b13
377 changed files with 9772 additions and 15950 deletions
|
@ -46,7 +46,7 @@
|
|||
|
||||
const fetchPromise = w.fetch('data.json', { signal });
|
||||
|
||||
await promise_rejects_dom(t, "AbortError", fetchPromise);
|
||||
await promise_rejects_dom(t, "AbortError", w.DOMException, fetchPromise);
|
||||
|
||||
await w.fetch('data.json?no-abort');
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
|||
Promise.resolve().then(() => log.push('next-microtask'))
|
||||
]);
|
||||
|
||||
await promise_rejects_dom(t, "AbortError", bodyPromise);
|
||||
await promise_rejects_dom(t, "AbortError", w.DOMException, bodyPromise);
|
||||
|
||||
assert_array_equals(log, [`${bodyMethod}-reject`, 'next-microtask']);
|
||||
}, `response.${bodyMethod}() rejects if already aborted`);
|
||||
|
@ -97,8 +97,8 @@
|
|||
|
||||
controller.abort();
|
||||
|
||||
await promise_rejects_dom(t, "AbortError", reader.read());
|
||||
await promise_rejects_dom(t, "AbortError", reader.closed);
|
||||
await promise_rejects_dom(t, "AbortError", w.DOMException, reader.read());
|
||||
await promise_rejects_dom(t, "AbortError", w.DOMException, reader.closed);
|
||||
}, "Stream errors once aborted.");
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body></body>
|
||||
<script>
|
||||
|
||||
const createDataUrlIframe = (url, cors) => {
|
||||
const iframe = document.createElement("iframe");
|
||||
const fetchURL = new URL(url, location.href) +
|
||||
`${cors === 'null-origin'
|
||||
? '?pipe=header(Access-Control-Allow-Origin, null)' : ''}`;
|
||||
const tag_name = 'script';
|
||||
iframe.src =
|
||||
`data:text/html, <${tag_name}>` +
|
||||
`async function test() {` +
|
||||
` let allowed = true;` +
|
||||
` try {` +
|
||||
` await fetch('${fetchURL}');` +
|
||||
` } catch (e) {` +
|
||||
` allowed = false;` +
|
||||
` }` +
|
||||
` parent.postMessage({allowed}, '*');` +
|
||||
`}` +
|
||||
`test(); </${tag_name}>`;
|
||||
return iframe;
|
||||
};
|
||||
|
||||
const fetch_from_data_url_iframe_test =
|
||||
(url, cors, expectation, description) => {
|
||||
promise_test(async () => {
|
||||
const iframe = createDataUrlIframe(url, cors);
|
||||
document.body.appendChild(iframe);
|
||||
const msgEvent = await new Promise(resolve => window.onmessage = resolve);
|
||||
assert_equals(msgEvent.data.allowed ? 'allowed' : 'rejected', expectation);
|
||||
}, description);
|
||||
};
|
||||
|
||||
fetch_from_data_url_iframe_test(
|
||||
'../resources/top.txt',
|
||||
'acao-omitted',
|
||||
'rejected',
|
||||
'fetching "top.txt" without ACAO should be rejected.'
|
||||
);
|
||||
fetch_from_data_url_iframe_test(
|
||||
'../resources/top.txt',
|
||||
'null-origin',
|
||||
'allowed',
|
||||
'fetching "top.txt" with CORS allowing null origin should be allowed.'
|
||||
);
|
||||
fetch_from_data_url_iframe_test(
|
||||
'data:text/plain, top',
|
||||
'acao-omitted',
|
||||
'allowed',
|
||||
'fetching data url script should be allowed.'
|
||||
);
|
||||
|
||||
</script>
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
const fetch_from_data_url_worker_test =
|
||||
(url, cors, expectation, description) => {
|
||||
promise_test(async () => {
|
||||
const fetchURL = new URL(url, location.href) +
|
||||
`${cors === 'null-origin'
|
||||
? '?pipe=header(Access-Control-Allow-Origin, null)' : ''}`;
|
||||
const scriptURL =
|
||||
`data:text/javascript,` +
|
||||
`async function test(port) {` +
|
||||
` let allowed = true;` +
|
||||
` try {` +
|
||||
` await fetch('${fetchURL}');` +
|
||||
` } catch (e) {` +
|
||||
` allowed = false;` +
|
||||
` }` +
|
||||
` port.postMessage({allowed});` +
|
||||
`}` +
|
||||
`onconnect = e => {` +
|
||||
` test(e.ports[0]);` +
|
||||
`};`;
|
||||
const worker = new SharedWorker(scriptURL);
|
||||
const msgEvent =
|
||||
await new Promise(resolve => worker.port.onmessage = resolve);
|
||||
assert_equals(msgEvent.data.allowed ? 'allowed' : 'rejected', expectation);
|
||||
}, description);
|
||||
};
|
||||
|
||||
fetch_from_data_url_worker_test(
|
||||
'../resources/top.txt',
|
||||
'acao-omitted',
|
||||
'rejected',
|
||||
'fetching "top.txt" without ACAO should be rejected.'
|
||||
);
|
||||
fetch_from_data_url_worker_test(
|
||||
'../resources/top.txt',
|
||||
'null-origin',
|
||||
'allowed',
|
||||
'fetching "top.txt" with CORS allowing null origin should be allowed.'
|
||||
);
|
||||
fetch_from_data_url_worker_test(
|
||||
'data:text/plain, top',
|
||||
'acao-omitted',
|
||||
'allowed',
|
||||
'fetching data url script should be allowed.'
|
||||
);
|
||||
|
||||
</script>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
const fetch_from_data_url_shared_worker_test =
|
||||
(url, cors, expectation, description) => {
|
||||
promise_test(async () => {
|
||||
const fetchURL = new URL(url, location.href) +
|
||||
`${cors === 'null-origin'
|
||||
? '?pipe=header(Access-Control-Allow-Origin, null)' : ''}`;
|
||||
const scriptURL =
|
||||
`data:text/javascript,` +
|
||||
`async function test() {` +
|
||||
` let allowed = true;` +
|
||||
` try {` +
|
||||
` await fetch('${fetchURL}');` +
|
||||
` } catch (e) {` +
|
||||
` allowed = false;` +
|
||||
` }` +
|
||||
` postMessage({allowed});` +
|
||||
`}` +
|
||||
`test();`;
|
||||
const worker = new Worker(scriptURL);
|
||||
const msgEvent = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_equals(msgEvent.data.allowed ? 'allowed' : 'rejected', expectation);
|
||||
}, description);
|
||||
};
|
||||
|
||||
fetch_from_data_url_shared_worker_test(
|
||||
'../resources/top.txt',
|
||||
'acao-omitted',
|
||||
'rejected',
|
||||
'fetching "top.txt" without ACAO should be rejected.'
|
||||
);
|
||||
fetch_from_data_url_shared_worker_test(
|
||||
'../resources/top.txt',
|
||||
'null-origin',
|
||||
'allowed',
|
||||
'fetching "top.txt" with CORS allowing null origin should be allowed.'
|
||||
);
|
||||
fetch_from_data_url_shared_worker_test(
|
||||
'data:text/plain, top',
|
||||
'acao-omitted',
|
||||
'allowed',
|
||||
'fetching data url script should be allowed.'
|
||||
);
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue