Files
sousa-gecko/testing/web-platform/tests/element-timing/text-not-observed-when-changed.html
T
Scott Haseley 94a222b2ba Bug 1980530 [wpt PR 54090] - ElementTiming: add a test for overwriting text, a=testonly
Automatic update from web-platform-tests
ElementTiming: add a test for overwriting text

Per https://www.w3.org/TR/paint-timing/#mark-paint-timing, step 6.1,
text elements aren't reconsidered to be painted nodes, which means only
one paint should count towards elementtiming. This CL adds a test for
this, as a baseline before we start messing around with this for soft
navs.

Bug: 424437484
Change-Id: I79bafd6e4720b6159610e3b8f02a861e83a62361
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6803129
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1495126}

--

wpt-commits: 8c4fc7604ca96eeed3efeb5b9c386b378e26c8a7
wpt-pr: 54090
2025-08-06 15:21:23 +00:00

53 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Element Timing: text not observed when changed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/element-timing-helpers.js"></script>
<p id="content" elementtiming="initial-text">This is some text</p>
<div id="target"></div>
<script>
promise_test(async t => {
assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let entries = await new Promise(resolve => {
new PerformanceObserver((list, observer) => {
resolve(list.getEntries());
observer.disconnect();
}).observe({type: 'element', buffered: true});
});
assert_equals(
entries.length, 1,
'Expected exactly one ElementTiming entry for initial text');
assert_equals(
entries[0].identifier, 'initial-text',
'Unexpected ElementTiming entry; expected "initial-text"');
// Update existing text. We should not get an entry for this.
content.innerText = "This is new text for an existing element";
// Add new text. We should get an entry for this.
target.innerHTML = '<div elementtiming="new-element-text">This is new text for a new element</div>';
// Wait for the ElementTiming entry. Note: it's okay to kick this off after
// after modifying the DOM because paint timing isn't marked until
// rendering, which happens in a separate task.
entries = await new Promise(resolve => {
new PerformanceObserver((list, observer) => {
resolve(list.getEntries());
observer.disconnect();
}).observe({type: 'element'});
});
assert_equals(
entries.length, 1,
'Expected exactly one ElementTiming entry for additional text');
assert_equals(
entries[0].identifier, 'new-element-text',
'Unexpected ElementTiming entry: expected "new-element-text"');
}, 'Changing the text of an already-observed element is not observed');
</script>