Skip to content

Commit ecd44ec

Browse files
shaseleyfoolip
authored andcommitted
[soft navs] Track paints before URL change for PrePaint attribution mode
Soft Navigation detection currently limits paint tracking to the context associated with the current URL (not including initial URL), which it does for efficiency since determining attribution in the advanced (lazy) attribution mode involves a DOM walk. But this can be inaccurate, and we'd like to remove this restriction. Since performance is hopefully fixed by the PrePaint attribution mode (still needs to be proved out experimentally), and there is relatively little additional overhead in this mode of tracking pre-URL-change paints, this CL enables that in this mode. Most of the heavy lifting was done in crrev.com/c/6779158, and now that SoftNavigationHeuristics supports computing FCP for all painted contexts and emitting buffered LCP on entry emission, recording paints before URL change is just a matter of not limiting MaybeGetSoftNavigationContextForTiming() to the context for the current URL. Bug: 423670827, 434130450 Change-Id: I14656312f5c589163982a0dc68c109362c9aa15e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6778273 Reviewed-by: Michal Mocny <[email protected]> Reviewed-by: Philip Rogers <[email protected]> Reviewed-by: Johannes Henkel <[email protected]> Commit-Queue: Scott Haseley <[email protected]> Cr-Commit-Position: refs/heads/main@{#1492331}
1 parent 7d3f380 commit ecd44ec

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/testdriver.js"></script>
6+
<script src="/resources/testdriver-vendor.js"></script>
7+
<script src="/soft-navigation-heuristics/resources/soft-navigation-test-helper.js"></script>
8+
9+
<button id="navigateButton">Click here!</button>
10+
<div id="content"></div>
11+
12+
<script>
13+
promise_test(async t => {
14+
const URL = '/late-url-change';
15+
16+
navigateButton.addEventListener("click", async () => {
17+
content.innerHTML = '<img src="/images/lcp-256x256.png" elementtiming="test-image"></img>';
18+
19+
const entries = await new Promise(resolve => {
20+
new PerformanceObserver((list, observer) => {
21+
resolve(list.getEntries());
22+
observer.disconnect();
23+
}).observe({type: 'element', buffered: true});
24+
});
25+
assert_equals(
26+
entries.length, 1, 'Expected exactly one ElementTiming entry');
27+
assert_equals(
28+
entries[0].identifier, 'test-image', 'Unexpected ElementTiming entry.');
29+
history.pushState({}, '', URL);
30+
}, {once: true});
31+
32+
const softNavPromise = SoftNavigationTestHelper.getPerformanceEntries(
33+
/*type=*/ "soft-navigation",
34+
/*include_soft_navigation_observations=*/ false,
35+
/*min_num_entries=*/ 1,
36+
);
37+
38+
if (test_driver) {
39+
test_driver.click(navigateButton);
40+
}
41+
42+
const helper = new SoftNavigationTestHelper(t);
43+
const entries = await helper.withTimeoutMessage(
44+
softNavPromise, "Soft navigation entry never arrived.", 3000);
45+
assert_equals(entries.length, 1, 'Expected exactly one soft navigation.');
46+
assert_true(
47+
entries[0].name.endsWith(URL),
48+
'Unexpected Soft Navigation URL.');
49+
}, 'Soft Navigation Detection supports setting URL after paint');
50+
</script>

0 commit comments

Comments
 (0)