зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1630768 [wpt PR 23035] - [EventTiming] Implement target, a=testonly
Automatic update from web-platform-tests [EventTiming] Implement target This CL adds the 'target' attribute to PerformanceEventTiming under the disabled-by-default EventTiming flag. Note that this is needed since first input timing is already shipped. The implementation simply sets the value upon finishing running event handlers, which guarantees that the very last target is the one used. In addition, the webexposed value needs to perform some checks to make sure that the target can be exposed. These are the same checks as the ElementTiming currently does for its 'element' attribute, and that the LayoutInstability API will need to perform as well, so these are moved to a static method in Performance. Bug: 543598 Change-Id: I10fa259713406c3898eebc0b682fe3d48ca7f641 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152999 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Steve Kobes <skobes@chromium.org> Cr-Commit-Position: refs/heads/master@{#760250} -- wpt-commits: bc01db77c4d739582f51c3b418037ae410116b06 wpt-pr: 23035
This commit is contained in:
Родитель
7a648dc65a
Коммит
edb475ea78
|
@ -32,7 +32,7 @@
|
|||
assert_not_equals(timeAfterFirstClick, undefined);
|
||||
assert_not_equals(timeAfterSecondClick, undefined);
|
||||
// First click.
|
||||
verifyClickEvent(observedEntries[0]);
|
||||
verifyClickEvent(observedEntries[0], 'button');
|
||||
assert_between_exclusive(observedEntries[0].processingStart,
|
||||
timeBeforeFirstClick,
|
||||
timeAfterFirstClick,
|
||||
|
@ -41,7 +41,7 @@
|
|||
"timeAfterFirstClick should be later than first click's start time.");
|
||||
|
||||
// Second click.
|
||||
verifyClickEvent(observedEntries[1]);
|
||||
verifyClickEvent(observedEntries[1], 'button');
|
||||
assert_between_exclusive(observedEntries[1].processingStart,
|
||||
timeAfterFirstClick,
|
||||
timeAfterSecondClick,
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
function validateEntries(entries) {
|
||||
assert_equals(entries.length, 1, "Only 1 entry should be received");
|
||||
const entry = entries[0];
|
||||
verifyClickEvent(entry, true);
|
||||
verifyClickEvent(entry, 'button', true);
|
||||
|
||||
assert_less_than(entry.processingStart, clickDone,
|
||||
"The entry's processing start should be before clickDone.");
|
||||
|
@ -38,7 +38,8 @@
|
|||
}
|
||||
// |childFrameData| has properties with the same names as its
|
||||
// PerformanceEventTiming counterpart.
|
||||
verifyClickEvent(childFrameData);
|
||||
verifyClickEvent(childFrameData, null);
|
||||
assert_equals(childFrameData.target, 'iframe_div');
|
||||
|
||||
assert_less_than(childFrameData.processingStart, childFrameData.clickDone,
|
||||
"The entry's processing start should be before than the child frame's clickDone.");
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset=utf-8 />
|
||||
<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/event-timing-test-utils.js></script>
|
||||
|
||||
<button id='the_button'>ClickMe</button>
|
||||
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
|
||||
const observer = new PerformanceObserver(t.step_func_done((entryList) => {
|
||||
const entries = entryList.getEntries().filter(e => e.name === 'mousedown');
|
||||
// There must only be one click entry.
|
||||
assert_equals(entries.length, 1);
|
||||
const entry = entries[0];
|
||||
// This checks that entry.target returns the correct button Node.
|
||||
verifyClickEvent(entry, 'the_button', true);
|
||||
const button = document.getElementById('the_button');
|
||||
button.parentNode.removeChild(button);
|
||||
// After removing the button, entry.target should now return null.
|
||||
assert_equals(entry.target, null);
|
||||
}));
|
||||
observer.observe({entryTypes: ['event']});
|
||||
clickAndBlockMain('the_button');
|
||||
}, "Event Timing: when target is disconnected, entry.target returns null.");
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset=utf-8 />
|
||||
<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/event-timing-test-utils.js></script>
|
||||
|
||||
<custom-button id='custom_button'></custom-button>
|
||||
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
|
||||
let innerButtonClicked = false;
|
||||
customElements.define('custom-button', class extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.attachShadow({mode: 'open'});
|
||||
this.shadowRoot.innerHTML = `<button id='inner_button_id'>Click me</button>`;
|
||||
this.shadowRoot.getElementById('inner_button_id').onclick = () => {
|
||||
innerButtonClicked = true;
|
||||
};
|
||||
}
|
||||
});
|
||||
const observer = new PerformanceObserver(t.step_func_done((entryList) => {
|
||||
const entries = entryList.getEntries().filter(e => e.name === 'mousedown');
|
||||
// There must only be one click entry.
|
||||
assert_equals(entries.length, 1);
|
||||
verifyClickEvent(entries[0], 'custom_button', true);
|
||||
assert_true(innerButtonClicked);
|
||||
}));
|
||||
observer.observe({entryTypes: ['event']});
|
||||
clickAndBlockMain('custom_button');
|
||||
}, "Event Timing: target reports the last Event Target, i.e. nothing from shadow DOM.");
|
||||
</script>
|
||||
</html>
|
|
@ -27,10 +27,7 @@
|
|||
// This ensures that the entry is exposing timing from the second click, i.e.
|
||||
// the one from the clickAndBlockMain() call.
|
||||
assert_greater_than_equal(entry.processingStart, beforeClick);
|
||||
// Check that the first input entry was also from the second click.
|
||||
const firstInput = performance.getEntriesByType('first-input');
|
||||
assert_equals(firstInput.length, 1);
|
||||
assert_greater_than_equal(firstInput[0].processingStart, beforeClick);
|
||||
verifyClickEvent(entry, 'div2', true);
|
||||
}));
|
||||
observer.observe({entryTypes: ['event']});
|
||||
document.getElementById('div').click();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src=event-timing-test-utils.js></script>
|
||||
<div style="width: 300px; height: 300px" onmousedown="mainThreadBusy(120)">
|
||||
<div style="width: 300px; height: 300px" id='iframe_div' onmousedown="mainThreadBusy(120)">
|
||||
<script>
|
||||
(async () => {
|
||||
const clickTimeMin = performance.now();
|
||||
|
@ -30,6 +30,7 @@
|
|||
// Other values
|
||||
"clickTimeMin": clickTimeMin,
|
||||
"clickDone" : clickDone,
|
||||
"target": entry.target.id,
|
||||
}, '*');
|
||||
}) ();
|
||||
</script>
|
||||
|
|
|
@ -21,7 +21,7 @@ function mainThreadBusy(duration) {
|
|||
// This method should receive an entry of type 'event'. |is_first| is true only
|
||||
// when the event also happens to correspond to the first event. In this case,
|
||||
// the timings of the 'first-input' entry should be equal to those of this entry.
|
||||
function verifyClickEvent(entry, is_first=false) {
|
||||
function verifyClickEvent(entry, targetId, is_first=false) {
|
||||
assert_true(entry.cancelable);
|
||||
assert_equals(entry.name, 'mousedown');
|
||||
assert_equals(entry.entryType, 'event');
|
||||
|
@ -47,6 +47,8 @@ function verifyClickEvent(entry, is_first=false) {
|
|||
assert_equals(firstInput.processingEnd, entry.processingEnd);
|
||||
assert_equals(firstInput.cancelable, entry.cancelable);
|
||||
}
|
||||
if (targetId)
|
||||
assert_equals(entry.target, document.getElementById(targetId));
|
||||
}
|
||||
|
||||
function wait() {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
'processingStart',
|
||||
'processingEnd',
|
||||
'cancelable',
|
||||
'target',
|
||||
];
|
||||
for (const key of keys) {
|
||||
assert_equals(json[key], entry[key],
|
||||
|
|
Загрузка…
Ссылка в новой задаче