| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <!-- This test requires internals because it tests Chromium's |
| 4 internal UseCounter. --> |
| 5 <title>Navigation Preload use counter</title> |
| 6 <script src="../../../resources/testharness.js"></script> |
| 7 <script src="../../../resources/testharnessreport.js"></script> |
| 8 <script src="../../resources/test-helpers.js"></script> |
| 9 <script> |
| 10 function is_navigation_preload_counted(frame) { |
| 11 // From UseCounter.h |
| 12 const ServiceWorkerNavigationPreload = 1803; |
| 13 |
| 14 return frame.contentWindow.internals.isUseCounted( |
| 15 frame.contentDocument, ServiceWorkerNavigationPreload); |
| 16 } |
| 17 |
| 18 promise_test(t => { |
| 19 var script = 'resources/worker.js?no-preload'; |
| 20 var scope = 'resources/dummy?no-preload-passthrough'; |
| 21 return service_worker_unregister_and_register(t, script, scope) |
| 22 .then(registration => { |
| 23 add_completion_callback(_ => registration.unregister()); |
| 24 var worker = registration.installing; |
| 25 return wait_for_state(t, worker, 'activated'); |
| 26 }) |
| 27 .then(() => { |
| 28 return with_iframe(scope); |
| 29 }) |
| 30 .then(frame => { |
| 31 assert_false(is_navigation_preload_counted(frame)); |
| 32 }); |
| 33 }, 'Navigation Preload is not counted if not enabled.'); |
| 34 |
| 35 promise_test(t => { |
| 36 var script = 'resources/worker.js'; |
| 37 var scope = 'resources/dummy?respondWith'; |
| 38 return service_worker_unregister_and_register(t, script, scope) |
| 39 .then(registration => { |
| 40 add_completion_callback(_ => registration.unregister()); |
| 41 var worker = registration.installing; |
| 42 return wait_for_state(t, worker, 'activated'); |
| 43 }) |
| 44 .then(() => with_iframe(scope)) |
| 45 .then(frame => { |
| 46 assert_true(is_navigation_preload_counted(frame)); |
| 47 }); |
| 48 }, 'Navigation Preload is use counted.'); |
| 49 |
| 50 promise_test(t => { |
| 51 var script = 'resources/worker.js'; |
| 52 var scope = 'resources/dummy?passthrough'; |
| 53 return service_worker_unregister_and_register(t, script, scope) |
| 54 .then(registration => { |
| 55 add_completion_callback(_ => registration.unregister()); |
| 56 var worker = registration.installing; |
| 57 return wait_for_state(t, worker, 'activated'); |
| 58 }) |
| 59 .then(() => with_iframe(scope)) |
| 60 .then(frame => { |
| 61 assert_true(is_navigation_preload_counted(frame)); |
| 62 }); |
| 63 }, 'Navigation Preload is use counted even if preloadResponse is not used.'); |
| 64 </script> |
| OLD | NEW |