fetch-request-xhr.https.html (2477B)
1 <!DOCTYPE html> 2 <title>Service Worker: the body of FetchEvent using XMLHttpRequest</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/get-host-info.sub.js"></script> 6 <script src="resources/test-helpers.sub.js?pipe-sub"></script> 7 <script> 8 let frame; 9 10 // Set up the service worker and the frame. 11 promise_test(t => { 12 const kScope = 'resources/fetch-request-xhr-iframe.https.html'; 13 const kScript = 'resources/fetch-request-xhr-worker.js'; 14 return service_worker_unregister_and_register(t, kScript, kScope) 15 .then(registration => { 16 promise_test(() => { 17 return registration.unregister(); 18 }, 'restore global state'); 19 20 return wait_for_state(t, registration.installing, 'activated'); 21 }) 22 .then(() => { 23 return with_iframe(kScope); 24 }) 25 .then(f => { 26 frame = f; 27 add_completion_callback(() => { f.remove(); }); 28 }); 29 }, 'initialize global state'); 30 31 // Run the tests. 32 promise_test(t => { 33 return frame.contentWindow.get_header_test(); 34 }, 'event.request has the expected headers for same-origin GET.'); 35 36 promise_test(t => { 37 return frame.contentWindow.post_header_test(); 38 }, 'event.request has the expected headers for same-origin POST.'); 39 40 promise_test(t => { 41 return frame.contentWindow.cross_origin_get_header_test(); 42 }, 'event.request has the expected headers for cross-origin GET.'); 43 44 promise_test(t => { 45 return frame.contentWindow.cross_origin_post_header_test(); 46 }, 'event.request has the expected headers for cross-origin POST.'); 47 48 promise_test(t => { 49 return frame.contentWindow.string_test(); 50 }, 'FetchEvent#request.body contains XHR request data (string)'); 51 52 promise_test(t => { 53 return frame.contentWindow.blob_test(); 54 }, 'FetchEvent#request.body contains XHR request data (blob)'); 55 56 promise_test(t => { 57 return frame.contentWindow.custom_method_test(); 58 }, 'FetchEvent#request.method is set to XHR method'); 59 60 promise_test(t => { 61 return frame.contentWindow.options_method_test(); 62 }, 'XHR using OPTIONS method'); 63 64 promise_test(t => { 65 return frame.contentWindow.form_data_test(); 66 }, 'XHR with form data'); 67 68 promise_test(t => { 69 return frame.contentWindow.mode_credentials_test(); 70 }, 'XHR with mode/credentials set'); 71 72 promise_test(t => { 73 return frame.contentWindow.data_url_test(); 74 }, 'XHR to data URL'); 75 </script>