OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Navigation redirection must clear body</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/get-host-info.js?pipe=sub"></script> |
| 6 <script src="resources/test-helpers.js"></script> |
| 7 <body> |
| 8 <script> |
| 9 promise_test(function(t) { |
| 10 var scope = 'resources/navigation-redirect-body.php'; |
| 11 var script = 'resources/navigation-redirect-body-worker.js'; |
| 12 var registration; |
| 13 var frame = document.createElement('frame'); |
| 14 frame.src = 'about:blank'; |
| 15 frame.name = 'target_frame'; |
| 16 frame.id = 'frame'; |
| 17 document.body.appendChild(frame); |
| 18 var form = document.createElement('form'); |
| 19 form.method = 'POST'; |
| 20 form.action = scope; |
| 21 form.target = 'target_frame'; |
| 22 var hidden_input = document.createElement('input'); |
| 23 hidden_input.type = 'hidden'; |
| 24 hidden_input.name = 'data'; |
| 25 hidden_input.value = 'test data'; |
| 26 var submit_button = document.createElement('input'); |
| 27 submit_button.type = 'submit'; |
| 28 submit_button.value = 'submit'; |
| 29 form.appendChild(hidden_input); |
| 30 form.appendChild(submit_button); |
| 31 document.body.appendChild(form); |
| 32 return service_worker_unregister_and_register(t, script, scope) |
| 33 .then(function(r) { |
| 34 registration = r; |
| 35 return wait_for_state(t, registration.installing, 'activated'); |
| 36 }) |
| 37 .then(function() { |
| 38 var frame_load_promise = new Promise(function(resolve) { |
| 39 frame.addEventListener('load', function() { |
| 40 resolve(frame.contentWindow.document.body.innerText); |
| 41 }, false); |
| 42 }); |
| 43 submit_button.click(); |
| 44 return frame_load_promise; |
| 45 }) |
| 46 .then(function(text) { |
| 47 document.body.removeChild(form); |
| 48 document.body.removeChild(frame); |
| 49 var request_uri = decodeURIComponent(text); |
| 50 assert_equals( |
| 51 request_uri, |
| 52 '/serviceworker/resources/navigation-redirect-body.php?redirect'); |
| 53 return registration.unregister(); |
| 54 }); |
| 55 }, 'Navigation redirection must clear body'); |
| 56 </script> |
| 57 </body> |
OLD | NEW |