Skip to content

Commit

Permalink
Bug 1931981 [wpt PR 49240] - Put timing values of DocumentTiming in a…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
Commit-Queue: Guohui Deng <[email protected]>
Reviewed-by: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1384608}

--

wpt-commits: d639d949a473d412a3557eab71eba43a58420f3f
wpt-pr: 49240
  • Loading branch information
Guohui Deng authored and moz-wptsync-bot committed Nov 20, 2024
1 parent 22dbe62 commit 4f8b7d5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<h1>
Description</h1>
<p>
This test validates that a PerformanceNavigatingTiming corresponding to a detached document can't access a different document's state. </p>
This test validates that a PerformanceNavigationTiming corresponding to a detached document can't access a different document's state. </p>
<iframe id="frameContext" onload="onload_test();" src="resources/blank_page_yellow_with_onunload.html" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>

<head>
<meta charset=utf-8>
<title>PerformanceNavigationTiming timing remains after iframe removed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>

<body>
<script>
const timingAttributes = [
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
];
function verify_timing(pnt, description) {
for (const att of timingAttributes) {
assert_greater_than(pnt[att], 0, `${description} ${att}`);
}
}

promise_test(async function (t) {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);

iframe.src = "resources/blank_page_green.html";
await new Promise(resolve => {
iframe.onload = function () {
assert_equals(iframe.contentWindow.performance.getEntriesByType("navigation").length, 1, "Only one navigation time entry");
const pnt = iframe.contentWindow.performance.getEntriesByType("navigation")[0];
assert_equals(pnt.name, iframe.contentWindow.location.toString(), "navigation name matches the window.location");
assert_true(pnt.name.endsWith("blank_page_green.html"), "navigation name is blank_page_green.html");
verify_timing(pnt, "timing values should be positive number:");
iframe.remove();
verify_timing(pnt, "timing values should remain positive after iframe is removed:");
resolve();
}
});

}, "iframe navigation times are persistent after the iframe is removed.");
</script>
</body>

</html>

0 comments on commit 4f8b7d5

Please sign in to comment.