Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <meta charset="utf-8"> | |
| 3 <title>FetchEvent with Navigation Preload 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 simulate the flowing situation: | |
|
falken
2017/03/23 06:19:01
nit: "simulates", "following"
horo
2017/03/23 06:46:39
Done.
| |
| 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 Returns a dummy response "hello". | |
| 14 // 3. The server sleeps 100 ms. So the browser process cancels the navigation | |
| 15 // preload request when it recieves the response from the SW. | |
| 16 // 4. Retry 1, 2 and 3 again. | |
| 17 // Before https://crbug.com/702527#c9, |m_pendingPreloadFetchEvents| of | |
| 18 // ServiceWorkerGlobalScopeProxy is accidentally cleared in the GC. So the SW | |
| 19 // crashed when it receives the fetch event with preload request again in step 4 | |
| 20 // while inserting the fetch into |m_pendingPreloadFetchEvents|. | |
| 21 promise_test(t => { | |
| 22 var script = 'resources/navigation-preload-after-gc-worker.js'; | |
| 23 var scope = 'resources/navigation-preload-after-gc-scope.php'; | |
| 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 }) | |
| 34 .then(_ => with_iframe(scope)) | |
| 35 .then(frame => { | |
| 36 assert_equals(frame.contentWindow.document.body.innerText, 'hello'); | |
| 37 }); | |
| 38 }, 'Navigation Preload is not counted if not enabled.'); | |
| 39 | |
| 40 </script> | |
| OLD | NEW |