mirror of
https://github.com/servo/servo.git
synced 2025-08-18 03:45:33 +01:00
Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317
This commit is contained in:
parent
aa199307c8
commit
2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions
|
@ -0,0 +1,134 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: the body of FetchEvent using XMLHttpRequest</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="/common/media.js"></script>
|
||||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
let frame;
|
||||
|
||||
// Set up the service worker and the frame.
|
||||
promise_test(t => {
|
||||
const kScope = 'resources/empty.https.html';
|
||||
const kScript = 'resources/fetch-destination-worker.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');
|
||||
})
|
||||
.then(() => {
|
||||
return with_iframe(kScope);
|
||||
})
|
||||
.then(f => {
|
||||
frame = f;
|
||||
add_completion_callback(() => { f.remove(); });
|
||||
});
|
||||
}, 'Initialize global state');
|
||||
|
||||
// Actual tests
|
||||
|
||||
// HTMLImageElement - image destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var node = frame.contentWindow.document.createElement("img");
|
||||
node.onload = resolve;
|
||||
node.onerror = reject;
|
||||
node.src = "dummy.png?dest=image";
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLImageElement fetches with an "image" Request.destination');
|
||||
|
||||
// fetch() - empty string destination
|
||||
promise_test(async t => {
|
||||
let response = await frame.contentWindow.fetch("dummy?dest=");
|
||||
assert_true(response.ok);
|
||||
}, 'fetch() fetches with an empty string Request.destination');
|
||||
|
||||
// HTMLAudioElement - audio destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var audioURL = getAudioURI("dummy_audio");
|
||||
var node = frame.contentWindow.document.createElement("audio");
|
||||
node.onloadeddata = resolve;
|
||||
node.onerror = reject;
|
||||
node.src = audioURL + "?dest=audio";
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLAudioElement fetches with an "audio" Request.destination');
|
||||
|
||||
// HTMLVideoElement - video destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var videoURL = getVideoURI("dummy_video");
|
||||
var node = frame.contentWindow.document.createElement("video");
|
||||
node.onloadeddata = resolve;
|
||||
node.onerror = reject;
|
||||
node.src = videoURL + "?dest=video";
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLVideoElement fetches with a "video" Request.destination');
|
||||
|
||||
// HTMLScriptElement - script destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var node = frame.contentWindow.document.createElement("script");
|
||||
node.onload = resolve;
|
||||
node.onerror = reject;
|
||||
node.src = "dummy?dest=script";
|
||||
frame.contentWindow.document.body.appendChild(node);
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLScriptElement fetches with a "script" Request.destination');
|
||||
|
||||
// HTMLLinkElement with rel=stylesheet - script destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var node = frame.contentWindow.document.createElement("link");
|
||||
node.rel = "stylesheet";
|
||||
node.onload = resolve;
|
||||
node.onerror = reject;
|
||||
node.href = "dummy?dest=style";
|
||||
frame.contentWindow.document.body.appendChild(node);
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLLinkElement with rel=stylesheet fetches with a "style" Request.destination');
|
||||
|
||||
// HTMLLinkElement with rel=preload and as=fetch - empty string destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var node = frame.contentWindow.document.createElement("link");
|
||||
node.rel = "preload";
|
||||
node.as = "fetch";
|
||||
node.onload = resolve;
|
||||
node.onerror = reject;
|
||||
node.href = "dummy?t=2&dest=";
|
||||
frame.contentWindow.document.body.appendChild(node);
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLLinkElement with rel=preload and as=fetch fetches with an empty string Request.destination');
|
||||
|
||||
// HTMLLinkElement with rel=preload and as=style - style destination
|
||||
promise_test(async t => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var node = frame.contentWindow.document.createElement("link");
|
||||
node.rel = "preload";
|
||||
node.as = "style";
|
||||
node.onload = resolve;
|
||||
node.onerror = reject;
|
||||
node.href = "dummy?t=2&dest=style";
|
||||
frame.contentWindow.document.body.appendChild(node);
|
||||
}).catch(() => {
|
||||
assert_unreached("Fetch errored.");
|
||||
});
|
||||
}, 'HTMLLinkElement with rel=preload and as=style fetches with a "style" Request.destination');
|
||||
</script>
|
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
self.addEventListener('fetch', function(event) {
|
||||
if (event.request.url.includes('dummy')) {
|
||||
let destination = new URL(event.request.url).searchParams.get("dest");
|
||||
if (event.request.destination == destination) {
|
||||
event.respondWith(fetch(event.request));
|
||||
} else {
|
||||
event.respondWith(Response.error());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue