tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

fetch-with-body.https.html (1209B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="resources/test-helpers.sub.js"></script>
      5 <body>
      6 <script>
      7 const SCRIPT = 'resources/fetch-with-body-worker.js';
      8 const SCOPE = 'resources/blank.html';
      9 
     10 let frame, registration;
     11 
     12 promise_test(async t => {
     13  t.add_cleanup(async() => {
     14    if (frame)
     15      frame.remove();
     16    if (registration)
     17      await registration.unregister();
     18  });
     19 
     20  await service_worker_unregister(t, SCOPE);
     21  registration = await navigator.serviceWorker.register(SCRIPT, {scope: SCOPE});
     22  await wait_for_state(t, registration.installing, 'activating');
     23  frame = await with_iframe(SCOPE);
     24 
     25  const request1 = new Request("resources/fetch-with-body-worker.py", {
     26    method: "GET",
     27  });
     28 
     29  const response1 = await frame.contentWindow.fetch(request1);
     30  assert_false(response1.ok);
     31 
     32  const request2 = new Request("resources/fetch-with-body-worker.py", {
     33    method: "POST",
     34    body: "BODY",
     35    headers: { "Content-Type": "text/ascii" },
     36  });
     37 
     38  const response2 = await frame.contentWindow.fetch(request2);
     39  assert_true(response2.ok);
     40 }, 'Validate body is preserved');
     41 
     42 </script>
     43 </body>
     44 </html>