Bug 1633704 [wpt PR 23087] - [server-timing] Populate values for NavigationTiming, a=testonly

Automatic update from web-platform-tests
[server-timing] Populate values for NavigationTiming

Currently, Navigation Timing's Server Timing values are populated when
the entry is first created, which happens when it is first queried. For
long documents, that can happen before the body is loaded, which is the
point in which the response is set on the NavigationTiming entry's
TimingInfo.
This CL fixes that, by setting the response on the TimingInfo earlier,
at the document's commit time.

Change-Id: I10522342a7d92560167bdb7d33956823e588d9d8

Bug: 1068937
Change-Id: I10522342a7d92560167bdb7d33956823e588d9d8

--

wpt-commits: 0084aa71d4d4935fcbb43bd8122328da9d305098
wpt-pr: 23087
This commit is contained in:
Yoav Weiss 2020-04-28 11:38:53 +00:00 коммит произвёл moz-wptsync-bot
Родитель 6441e81375
Коммит 37ec34b504
3 изменённых файлов: 59 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_done: true})
window.addEventListener("message", e => {
test(() => {
assert_equals(e.data, "PASS", "The iframe saw ServerTiming entries in its NavigationTiming entry.");
done();
})
});
</script>
</head>
<body>
<iframe src="resources/navigation-timing.html?pipe=trickle(800:d1)"></iframe>
</body>

Просмотреть файл

@ -0,0 +1,38 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script>
const server_timing = performance.getEntriesByType('navigation')[0].serverTiming;
const compare_entry = (entry, expected) => {
if (!entry) {
return false;
}
const keys = Object.keys(expected);
for (key of keys) {
if (entry[key] != expected[key]) {
return false;
}
}
return true;
};
if (!compare_entry(server_timing[0], {
duration: 1.1,
name: 'metric1',
description: 'document',
}) ||
!compare_entry(server_timing[1], {
duration: 1.2,
name: 'metric1',
description: 'document',
})) {
parent.postMessage("FAIL", "*");
}
parent.postMessage( "PASS", "*");
</script>
<!-- The script above should not go beyond 800 bytes, or it will be trickled, defeating the test -->
</head>
<body>
<!-- This comment is here to make sure the document body is larger than 800 bytes, so will be trickled down -->
</body>
</html>

Просмотреть файл

@ -0,0 +1 @@
Server-Timing: metric1; dur=1.1; desc=document, metric1; dur=1.2; desc=document