mirror of
https://github.com/servo/servo.git
synced 2025-09-04 12:08:21 +01:00
Update web-platform-tests to revision 70fdd27f4cecb8a5cae3dafa76ba05265531c9e2
This commit is contained in:
parent
e5689df6b4
commit
bea56037ef
701 changed files with 13864 additions and 1909 deletions
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Fetch destination tests for resources with no load event</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
let frame;
|
||||
const kScope = 'resources/dummy.html?dest=frame';
|
||||
|
||||
// Set up the service worker and the frame.
|
||||
promise_test(t => {
|
||||
const kScript = 'resources/fetch-destination-worker-frame.js';
|
||||
return service_worker_unregister_and_register(t, kScript, kScope)
|
||||
.then(registration => {
|
||||
add_completion_callback(() => {
|
||||
registration.unregister();
|
||||
});
|
||||
|
||||
return wait_for_state(t, registration.installing, 'activated');
|
||||
});
|
||||
}, 'Initialize global state');
|
||||
|
||||
var waitOnMessageFromSW = async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
navigator.serviceWorker.onmessage = t.step_func(event => {
|
||||
if (event.data == "PASS") {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}).catch(() => {;
|
||||
assert_unreached("Wrong destination.");
|
||||
});
|
||||
t.add_cleanup(() => { frame.contentWindow.navigator.serviceWorker.onmessage = null; });
|
||||
}
|
||||
|
||||
// Document destination
|
||||
///////////////////////
|
||||
promise_test(async t => {
|
||||
var f = document.createElement('frame');
|
||||
frame = f;
|
||||
f.className = 'test-frame';
|
||||
f.src = kScope;
|
||||
document.body.appendChild(f);
|
||||
await waitOnMessageFromSW(t);
|
||||
add_completion_callback(() => { f.remove(); });
|
||||
}, 'frame fetches with a "frame" Request.destination');
|
||||
|
||||
</script>
|
|
@ -6,7 +6,7 @@
|
|||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
let frame;
|
||||
const kScope = 'resources/dummy.html?dest=document';
|
||||
const kScope = 'resources/dummy.html?dest=iframe';
|
||||
|
||||
// Set up the service worker and the frame.
|
||||
promise_test(t => {
|
||||
|
@ -46,6 +46,6 @@ promise_test(async t => {
|
|||
document.body.appendChild(f);
|
||||
await waitOnMessageFromSW(t);
|
||||
add_completion_callback(() => { f.remove(); });
|
||||
}, 'iframe fetches with a "document" Request.destination');
|
||||
}, 'iframe fetches with a "iframe" Request.destination');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
self.addEventListener('fetch', function(event) {
|
||||
if (event.request.url.includes('dummy')) {
|
||||
event.waitUntil(async function() {
|
||||
let destination = new URL(event.request.url).searchParams.get("dest");
|
||||
let clients = await self.clients.matchAll({"includeUncontrolled": true});
|
||||
clients.forEach(function(client) {
|
||||
if (client.url.includes("fetch-destination-frame")) {
|
||||
if (event.request.destination == destination) {
|
||||
client.postMessage("PASS");
|
||||
} else {
|
||||
client.postMessage("FAIL");
|
||||
}
|
||||
}
|
||||
})
|
||||
}());
|
||||
}
|
||||
event.respondWith(fetch(event.request));
|
||||
});
|
||||
|
||||
|
|
@ -167,11 +167,22 @@
|
|||
var urlSearchParamsBlob = new Blob([urlSearchParamsData], { "type": urlSearchParamsType });
|
||||
formData.append("name", textData);
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-body-package-data
|
||||
// "UTF-8 decoded without BOM" is used for formData(), either in
|
||||
// "multipart/form-data" and "application/x-www-form-urlencoded" cases,
|
||||
// so BOMs in the values should be kept.
|
||||
// (The "application/x-www-form-urlencoded" cases are tested in
|
||||
// url/urlencoded-parser.any.js)
|
||||
var textDataWithBom = "\uFEFFquick\uFEFFfox\uFEFF";
|
||||
var formTextDataWithBom = stringToMultipartFormTextData(multipartBoundary, "name", textDataWithBom);
|
||||
var formTextDataWithBomExpectedForMultipartFormData = stringToMultipartFormTextData(multipartBoundary, "name", textDataWithBom);
|
||||
|
||||
checkResponseBody(responsePromise(textData, textResponseInit), textData, checkBodyText, "from text to text");
|
||||
checkResponseBody(responsePromise(textData, textResponseInit), textData, checkBodyBlob, "from text to blob");
|
||||
checkResponseBody(responsePromise(textData, textResponseInit), textData, checkBodyArrayBuffer, "from text to arrayBuffer");
|
||||
checkResponseBody(responsePromise(textData, textResponseInit), textData, checkBodyJSON, "from text to json");
|
||||
checkResponseBody(responsePromise(formTextData, formTextResponseInit), formTextData, checkBodyFormDataMultipart, "from text with correct multipart type to formData");
|
||||
checkResponseBody(responsePromise(formTextDataWithBom, formTextResponseInit), formTextDataWithBomExpectedForMultipartFormData, checkBodyFormDataMultipart, "from text with correct multipart type to formData with BOM");
|
||||
checkResponseBody(responsePromise(formTextData, textResponseInit), undefined, checkBodyFormDataError, "from text without correct multipart type to formData (error case)");
|
||||
checkResponseBody(responsePromise(urlSearchParamsData, urlSearchParamsResponseInit), urlSearchParamsData, checkBodyFormDataUrlencoded, "from text with correct urlencoded type to formData");
|
||||
checkResponseBody(responsePromise(urlSearchParamsData, textResponseInit), undefined, checkBodyFormDataError, "from text without correct urlencoded type to formData (error case)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue