Commit 2f0dd05a authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Modernize WPT: resource-timing and navigation-timing.https.html

As a part of the effort to understand the current behavior of the
resource timing, I changed the tests to use async/await for readability
with adding a few comments.

Bug: 1128786
Change-Id: I45daee67e52a13c98ad3f2010131d858a58781d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2413927
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Auto-Submit: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807845}
parent 14ac32ed
......@@ -32,81 +32,45 @@ function navigate_in_frame(frame, url) {
const worker_url = 'resources/navigation-timing-worker.js';
promise_test(t => {
promise_test(async (t) => {
const scope = 'resources/empty.html';
let frame;
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
const frame = await with_iframe(scope);
t.add_cleanup(() => frame.remove());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(r => {
return wait_for_state(t, r.installing, 'activated');
})
.then(() => with_iframe(scope))
.then(f => {
frame = f;
return navigate_in_frame(frame, 'resources/empty.html');
})
.then(timing => {
assert_greater_than(timing.workerStart, 0);
verify(timing);
})
.catch(unreached_rejection(t))
.then(() => {
if (frame)
frame.remove();
return service_worker_unregister(t, scope);
});
const timing = await navigate_in_frame(frame, scope);
assert_greater_than(timing.workerStart, 0);
verify(timing);
}, 'Service worker controlled navigation timing');
promise_test(t => {
promise_test(async (t) => {
const scope = 'resources/empty.html?network-fallback';
let frame;
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
const frame = await with_iframe(scope);
t.add_cleanup(() => frame.remove());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(r => {
return wait_for_state(t, r.installing, 'activated');
})
.then(() => with_iframe(scope))
.then(f => {
frame = f;
return navigate_in_frame(frame, 'resources/empty.html?network-fallback');
})
.then(timing => {
verify(timing);
})
.catch(unreached_rejection(t))
.then(() => {
if (frame)
frame.remove();
return service_worker_unregister(t, scope);
});
const timing = await navigate_in_frame(frame, scope);
verify(timing);
}, 'Service worker controlled navigation timing network fallback');
promise_test(t => {
promise_test(async (t) => {
const scope = 'resources/redirect.py?Redirect=empty.html';
let frame;
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
const frame = await with_iframe(scope);
t.add_cleanup(() => frame.remove());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(r => {
return wait_for_state(t, r.installing, 'activated');
})
.then(() => with_iframe(scope))
.then(f => {
frame = f;
return navigate_in_frame(frame, 'resources/redirect.py?Redirect=empty.html');
})
.then(timing => {
verify(timing);
// Additional checks for redirected navigation.
assert_true(timing.redirectStart <= timing.redirectEnd,
'Expected redirectStart <= redirectEnd');
assert_true(timing.redirectEnd <= timing.fetchStart,
'Expected redirectEnd <= fetchStart');
})
.catch(unreached_rejection(t))
.then(() => {
if (frame)
frame.remove();
return service_worker_unregister(t, scope);
});
const timing = await navigate_in_frame(frame, scope);
verify(timing);
// Additional checks for redirected navigation.
assert_true(timing.redirectStart <= timing.redirectEnd,
'Expected redirectStart <= redirectEnd');
assert_true(timing.redirectEnd <= timing.fetchStart,
'Expected redirectEnd <= fetchStart');
}, 'Service worker controlled navigation timing redirect');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment