Skip to content

Commit

Permalink
chore: update WPT
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and github-actions[bot] committed Jan 8, 2025
1 parent 54c5c68 commit f28ab7f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
const SCRIPT = 'resources/fetch-with-body-worker.js';
const SCOPE = 'resources/blank.html';

let frame, registration;

promise_test(async t => {
t.add_cleanup(async() => {
if (frame)
frame.remove();
if (registration)
await registration.unregister();
});

await service_worker_unregister(t, SCOPE);
registration = await navigator.serviceWorker.register(SCRIPT, {scope: SCOPE});
await wait_for_state(t, registration.installing, 'activating');
frame = await with_iframe(SCOPE);

const request1 = new Request("resources/fetch-with-body-worker.py", {
method: "GET",
});

const response1 = await frame.contentWindow.fetch(request1);
assert_false(response1.ok);

const request2 = new Request("resources/fetch-with-body-worker.py", {
method: "POST",
body: "BODY",
headers: { "Content-Type": "text/ascii" },
});

const response2 = await frame.contentWindow.fetch(request2);
assert_true(response2.ok);
}, 'Validate body is preserved');

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
self.addEventListener("fetch", (event) => {
event.request.body;
event.respondWith(fetch(event.request));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def main(request, response):
if len(request.body):
return 200, [], u"BODY"
return 400, [], u"NO BODY"

0 comments on commit f28ab7f

Please sign in to comment.