Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /soft-navigation-heuristics/largest-painted-element-multiple-paints-before-url.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset="utf-8">
<title>SoftNavigationEntry largestInteractionContentfulPaint attribute: Multiple paints before URL.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/soft-navigation-helper.js"></script>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<main id=main>
<a id=link>Click me!</a>
</main>
<script>
promise_test(async t => {
const soft_nav_promise = getNextEntry('soft-navigation');
const clickTarget = document.getElementById("link");
let largeId;
clickTarget.addEventListener('click', async () => {
// Yield to ensure task tracking is working and we mark a timeOrigin.
await new Promise(r => t.step_timeout(r, 0));
// First paint (small).
const small = await addTextParagraphToMain("Small element");
// Second paint (large).
const large = await addTextParagraphToMain("Much larger element that should be the largest interaction contentful paint in this interaction context");
largeId = large.id;
// URL change.
history.pushState({}, '', `foobar.html?${counter++}`);
});
await test_driver.click(clickTarget);
const entry = await soft_nav_promise;
assert_true("paintTime" in entry, "paintTime attribute should exist on soft nav entry");
assert_greater_than(entry.paintTime, 0, "soft nav entry paintTime should be greater than 0");
const largest = entry.largestInteractionContentfulPaint;
assert_not_equals(largest, null, "largestInteractionContentfulPaint is not null");
assert_equals(largest.id, largeId, "largestInteractionContentfulPaint is the large one");
assert_true("paintTime" in largest, "paintTime attribute should exist on ICP entry");
assert_greater_than(largest.paintTime, 0, "ICP entry paintTime should be greater than 0");
assert_greater_than(largest.paintTime, entry.paintTime, "ICP paintTime should be later than FCP paintTime");
}, "Test that the largestInteractionContentfulPaint attribute is correctly set with multiple paints before URL change");
</script>