Skip to content

Commit 4f8b7d5

Browse files
Guohui Dengmoz-wptsync-bot
Guohui Deng
authored andcommitted
Bug 1931981 [wpt PR 49240] - Put timing values of DocumentTiming in a GCed object, a=testonly
Automatic update from web-platform-tests Put timing values of DocumentTiming in a GCed object So they can outlive the document, and PerformanceNavigationTiming can collect them. Bug: 40793421 Change-Id: I2cbb53862ff9fab08f963d9408ef65ff462e5dd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5935276 Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: Guohui Deng <guohuideng@microsoft.com> Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org> Cr-Commit-Position: refs/heads/main@{#1384608} -- wpt-commits: d639d949a473d412a3557eab71eba43a58420f3f wpt-pr: 49240
1 parent 22dbe62 commit 4f8b7d5

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

testing/web-platform/tests/navigation-timing/nav2-test-document-replaced.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<h1>
5555
Description</h1>
5656
<p>
57-
This test validates that a PerformanceNavigatingTiming corresponding to a detached document can't access a different document's state. </p>
57+
This test validates that a PerformanceNavigationTiming corresponding to a detached document can't access a different document's state. </p>
5858
<iframe id="frameContext" onload="onload_test();" src="resources/blank_page_yellow_with_onunload.html" style="width: 250px; height: 250px;"></iframe>
5959
</body>
6060
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
4+
<head>
5+
<meta charset=utf-8>
6+
<title>PerformanceNavigationTiming timing remains after iframe removed</title>
7+
<script src="/resources/testharness.js"></script>
8+
<script src="/resources/testharnessreport.js"></script>
9+
</head>
10+
11+
<body>
12+
<script>
13+
const timingAttributes = [
14+
'domComplete',
15+
'domContentLoadedEventEnd',
16+
'domContentLoadedEventStart',
17+
'domInteractive',
18+
];
19+
function verify_timing(pnt, description) {
20+
for (const att of timingAttributes) {
21+
assert_greater_than(pnt[att], 0, `${description} ${att}`);
22+
}
23+
}
24+
25+
promise_test(async function (t) {
26+
const iframe = document.createElement("iframe");
27+
document.body.appendChild(iframe);
28+
29+
iframe.src = "resources/blank_page_green.html";
30+
await new Promise(resolve => {
31+
iframe.onload = function () {
32+
assert_equals(iframe.contentWindow.performance.getEntriesByType("navigation").length, 1, "Only one navigation time entry");
33+
const pnt = iframe.contentWindow.performance.getEntriesByType("navigation")[0];
34+
assert_equals(pnt.name, iframe.contentWindow.location.toString(), "navigation name matches the window.location");
35+
assert_true(pnt.name.endsWith("blank_page_green.html"), "navigation name is blank_page_green.html");
36+
verify_timing(pnt, "timing values should be positive number:");
37+
iframe.remove();
38+
verify_timing(pnt, "timing values should remain positive after iframe is removed:");
39+
resolve();
40+
}
41+
});
42+
43+
}, "iframe navigation times are persistent after the iframe is removed.");
44+
</script>
45+
</body>
46+
47+
</html>

0 commit comments

Comments
 (0)