| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/use-counter.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/use-counter.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/use-counter.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6b52114164cfb6c784ad7ef45dfa21257d875ea2
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/use-counter.html
|
| @@ -0,0 +1,64 @@
|
| +<!DOCTYPE html>
|
| +<meta charset="utf-8">
|
| +<!-- This test requires internals because it tests Chromium's
|
| + internal UseCounter. -->
|
| +<title>Navigation Preload use counter</title>
|
| +<script src="../../../resources/testharness.js"></script>
|
| +<script src="../../../resources/testharnessreport.js"></script>
|
| +<script src="../../resources/test-helpers.js"></script>
|
| +<script>
|
| +function is_navigation_preload_counted(frame) {
|
| + // From UseCounter.h
|
| + const ServiceWorkerNavigationPreload = 1803;
|
| +
|
| + return frame.contentWindow.internals.isUseCounted(
|
| + frame.contentDocument, ServiceWorkerNavigationPreload);
|
| +}
|
| +
|
| +promise_test(t => {
|
| + var script = 'resources/worker.js?no-preload';
|
| + var scope = 'resources/dummy?no-preload-passthrough';
|
| + return service_worker_unregister_and_register(t, script, scope)
|
| + .then(registration => {
|
| + add_completion_callback(_ => registration.unregister());
|
| + var worker = registration.installing;
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(() => {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(frame => {
|
| + assert_false(is_navigation_preload_counted(frame));
|
| + });
|
| + }, 'Navigation Preload is not counted if not enabled.');
|
| +
|
| +promise_test(t => {
|
| + var script = 'resources/worker.js';
|
| + var scope = 'resources/dummy?respondWith';
|
| + return service_worker_unregister_and_register(t, script, scope)
|
| + .then(registration => {
|
| + add_completion_callback(_ => registration.unregister());
|
| + var worker = registration.installing;
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(() => with_iframe(scope))
|
| + .then(frame => {
|
| + assert_true(is_navigation_preload_counted(frame));
|
| + });
|
| + }, 'Navigation Preload is use counted.');
|
| +
|
| +promise_test(t => {
|
| + var script = 'resources/worker.js';
|
| + var scope = 'resources/dummy?passthrough';
|
| + return service_worker_unregister_and_register(t, script, scope)
|
| + .then(registration => {
|
| + add_completion_callback(_ => registration.unregister());
|
| + var worker = registration.installing;
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(() => with_iframe(scope))
|
| + .then(frame => {
|
| + assert_true(is_navigation_preload_counted(frame));
|
| + });
|
| + }, 'Navigation Preload is use counted even if preloadResponse is not used.');
|
| +</script>
|
|
|