commit 300e786d1b7a96f78679872bd8334e05b7a85cac
parent 6d2686c342bcc8551cde65e07a5c0a72b3fc6257
Author: Michal Mocny <mmocny@chromium.org>
Date: Tue, 21 Oct 2025 10:31:21 +0000
Bug 1994864 [wpt PR 55493] - [EventTiming] Rename targetIdentifier to targetSelector after feedback., a=testonly
Automatic update from web-platform-tests
[EventTiming] Rename targetIdentifier to targetSelector after feedback.
Recently presented this new feature to the Web Performance WG at a
biweekly meeting and got strong positive support, but feedback that the
name is misleading (confusing with just element.id value), and also that
the specific format of the query-selector for target might need to
evolve in the future.
Renaming based on that feedback, and will update spec wording PR.
Spec Issue: https://github.com/w3c/event-timing/issues/126
I2P: https://chromestatus.com/feature/5143499213242368
Spec: https://github.com/w3c/event-timing/pull/160
Bug: 40887145
Change-Id: I154c6706578fa88485aa9a91eb6f8e8a700beb5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7044923
Reviewed-by: Scott Haseley <shaseley@chromium.org>
Commit-Queue: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1530914}
--
wpt-commits: 021f7cd491c9d71de9631d9bdc13c299e2e512a2
wpt-pr: 55493
Diffstat:
2 files changed, 92 insertions(+), 97 deletions(-)
diff --git a/testing/web-platform/tests/event-timing/target-identifier.html b/testing/web-platform/tests/event-timing/target-identifier.html
@@ -1,96 +0,0 @@
-<!DOCTYPE html>
-<html>
-<meta charset=utf-8 />
-<meta name="timeout" content="long">
-<title>Event Timing targetIdentifier.</title>
-<script src=/resources/testharness.js></script>
-<script src=/resources/testharnessreport.js></script>
-<script src=/resources/testdriver.js></script>
-<script src=/resources/testdriver-actions.js></script>
-<script src=/resources/testdriver-vendor.js></script>
-<script src=resources/event-timing-test-utils.js></script>
-<div id='div-with-id'>Target with ID</div>
-<div>Target without ID</div>
-<img id='img-with-id-and-src' src='/images/blue.png'>
-<img src='/images/green.png'>
-<script>
- function verifyTargetIdentifier(entry, target) {
- if ('targetIdentifier' in entry) {
- let expectedIdentifier = target.tagName;
- if (target.id) {
- expectedIdentifier += '#' + target.id;
- } else if (target.hasAttribute('src')) {
- expectedIdentifier += '[src="' + target.getAttribute('src') + '"]';
- }
- assert_equals(entry.targetIdentifier, expectedIdentifier);
- }
- }
-
- function runTest(t, eventType, target) {
- let entry;
- const callback = (entryList) => {
- const entries = entryList.getEntriesByName(eventType);
- if (entries.length > 0) {
- entry = entries[0];
- }
- };
- const readyToResolve = () => !!entry;
- const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
- return interactAndObserve(eventType, target, observerPromise)
- .then(() => {
- assert_equals(entry.name, eventType);
- assert_equals(entry.entryType, 'event');
- assert_equals(entry.target, target);
- verifyTargetIdentifier(entry, target);
- if (entry.target) {
- const matchingElements = document.querySelectorAll(entry.targetIdentifier);
- assert_true(Array.from(matchingElements).includes(target));
- }
- });
- }
-
- promise_test(async t => {
- // Element with tagName and id.
- return runTest(t, 'click', document.getElementById('div-with-id'));
- }, "Test with target that has an ID");
-
- promise_test(async t => {
- // Element with tagName only.
- return runTest(t, 'click', document.querySelector('div:not([id])'));
- }, "Test with simple target (no id)");
-
- promise_test(async t => {
- // Element with tagName, id, and src.
- return runTest(t, 'click', document.getElementById('img-with-id-and-src'));
- }, "Test with image target with id and src");
-
- promise_test(async t => {
- // Element with tagName and src.
- return runTest(t, 'click', document.querySelector('img:not([id])'));
- }, "Test with image target with src only");
-
- promise_test(async t => {
- let entry;
- const callback = (entryList) => {
- const entries = entryList.getEntriesByName('click');
- if (entries.length > 0) {
- entry = entries[0];
- }
- };
- const readyToResolve = () => !!entry;
- const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
- const parent = document.body;
- const target = document.createElement('button');
- target.id = 'temp-target';
- target.textContent = 'Click Me';
- parent.appendChild(target);
- await interactAndObserve('click', target, observerPromise);
- const expectedIdentifier = target.tagName + '#' + target.id;
- parent.removeChild(target);
- // The garbage collector might need some time to collect |target|.
- await new Promise(r => t.step_timeout(r, 0));
- assert_equals(entry.target, null);
- assert_equals(entry.targetIdentifier, expectedIdentifier);
- }, "Test with disconnected target");
-</script>
-</html>
-\ No newline at end of file
diff --git a/testing/web-platform/tests/event-timing/target-selector.tentative.html b/testing/web-platform/tests/event-timing/target-selector.tentative.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<meta name="timeout" content="long">
+<title>Event Timing targetSelector.</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/resources/testdriver.js></script>
+<script src=/resources/testdriver-actions.js></script>
+<script src=/resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='div-with-id'>Target with ID</div>
+<div>Target without ID</div>
+<img id='img-with-id-and-src' src='/images/blue.png'>
+<img src='/images/green.png'>
+<script>
+ function computeExpectedTargetSelector(target) {
+ let selector = target.tagName;
+ if (target.id) {
+ selector += '#' + target.id;
+ } else if (target.hasAttribute('src')) {
+ selector += '[src="' + target.getAttribute('src') + '"]';
+ }
+ return selector;
+ }
+
+ function runTest(t, eventType, target) {
+ let entry;
+ const callback = (entryList) => {
+ const entries = entryList.getEntriesByName(eventType);
+ if (entries.length > 0) {
+ entry = entries[0];
+ }
+ };
+ const readyToResolve = () => !!entry;
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+ return interactAndObserve(eventType, target, observerPromise)
+ .then(() => {
+ assert_equals(entry.name, eventType);
+ assert_equals(entry.entryType, 'event');
+ assert_equals(entry.target, target);
+ assert_equals(entry.targetSelector, computeExpectedTargetSelector(entry.target));
+ const matchingElements = document.querySelectorAll(entry.targetSelector);
+ assert_true(Array.from(matchingElements).includes(target));
+ });
+ }
+
+ promise_test(async t => {
+ // Element with tagName and id.
+ return runTest(t, 'click', document.getElementById('div-with-id'));
+ }, "Test with target that has an ID");
+
+ promise_test(async t => {
+ // Element with tagName only.
+ return runTest(t, 'click', document.querySelector('div:not([id])'));
+ }, "Test with simple target (no id)");
+
+ promise_test(async t => {
+ // Element with tagName, id, and src.
+ return runTest(t, 'click', document.getElementById('img-with-id-and-src'));
+ }, "Test with image target with id and src");
+
+ promise_test(async t => {
+ // Element with tagName and src.
+ return runTest(t, 'click', document.querySelector('img:not([id])'));
+ }, "Test with image target with src only");
+
+ promise_test(async t => {
+ let entry;
+ const callback = (entryList) => {
+ const entries = entryList.getEntriesByName('click');
+ if (entries.length > 0) {
+ entry = entries[0];
+ }
+ };
+ const readyToResolve = () => !!entry;
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+ const parent = document.body;
+ const target = document.createElement('button');
+ target.id = 'temp-target';
+ target.textContent = 'Click Me';
+ parent.appendChild(target);
+ await interactAndObserve('click', target, observerPromise);
+ const expectedIdentifier = target.tagName + '#' + target.id;
+ parent.removeChild(target);
+ // The garbage collector might need some time to collect |target|.
+ await new Promise(r => t.step_timeout(r, 0));
+ assert_equals(entry.target, null);
+ assert_equals(entry.targetSelector, expectedIdentifier);
+ }, "Test with disconnected target");
+</script>
+</html>