OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Navigation Preload Response after GC shouldn't cause crash.</title> |
| 4 <script src="../../../resources/testharness.js"></script> |
| 5 <script src="../../../resources/testharnessreport.js"></script> |
| 6 <script src="../../resources/test-helpers.js"></script> |
| 7 <script> |
| 8 |
| 9 // This test simulates the following situation: |
| 10 // 1. The browser process sends the navigation preload request to the server. |
| 11 // 2. In SW's FetchEvent handler: |
| 12 // 2.1 Executes GC with internals.collectGarbage(). |
| 13 // 2.2 Sleeps 100 ms not to cancel the navigation request before the server |
| 14 // returns the preload response. |
| 15 // 2.3 Returns a dummy response "hello". |
| 16 // 3. The server returns the preload response, and the SW recieves it via the |
| 17 // browser process. |
| 18 // Before https://crbug.com/702527#c9, |m_pendingPreloadFetchEvents| of |
| 19 // ServiceWorkerGlobalScopeProxy is accidentally cleared in the GC. So the SW |
| 20 // crashed when it receives the preload response. |
| 21 promise_test(t => { |
| 22 var script = 'resources/preload-response-after-gc-worker.js'; |
| 23 var scope = 'resources/preload-response-after-gc-scope.html'; |
| 24 return service_worker_unregister_and_register(t, script, scope) |
| 25 .then(registration => { |
| 26 add_completion_callback(_ => registration.unregister()); |
| 27 var worker = registration.installing; |
| 28 return wait_for_state(t, worker, 'activated'); |
| 29 }) |
| 30 .then(_ => with_iframe(scope)) |
| 31 .then(frame => { |
| 32 assert_equals(frame.contentWindow.document.body.innerText, 'hello'); |
| 33 // Wait for a while to ensure that the SW receives the response. |
| 34 return new Promise(resolve => setTimeout(resolve, 100)); |
| 35 }); |
| 36 }, 'Navigation Preload Response after GC shouldn\'t cause crash'); |
| 37 |
| 38 </script> |
OLD | NEW |