Opaque being-loaded responses should clone their body
[WebKit-https.git] / LayoutTests / http / wpt / service-workers / clone-opaque-being-loaded-response.https.html
1 <html>
2 <head>
3 <title>Service Worker returning an opaque cloned response</title>
4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script>
6 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
7 </head>
8 <body>
9 <script>
10 var registration;
11 var iframe;
12 promise_test(async (test) => {
13     registration = await navigator.serviceWorker.getRegistration("resources/");
14     if (registration)
15         await registration.unregister();
16     registration = await navigator.serviceWorker.register("clone-opaque-being-loaded-response-worker.js", { scope : "resources/" });
17     activeWorker = registration.active;
18     if (activeWorker)
19         return;
20     activeWorker = registration.installing;
21     await new Promise(resolve => {
22         activeWorker.addEventListener('statechange', () => {
23             if (activeWorker.state === "activated")
24                 resolve();
25         });
26     });
27 }, "Setup worker");
28
29 promise_test(async (test) => {
30     iframe = await with_iframe("resources/clone-opaque-being-loaded-response-iframe.html");
31     assert_equals(iframe.contentWindow.document.body.innerHTML.trim(), "PASS");
32     iframe.remove();
33 }, "Ensure opaque response fetch is working");
34 </script>
35 </body>
36 </html>