Bug 1632253 [wpt PR 23180] - Reland "[EventTiming] Add shadow DOM test for first input", a=testonly

Automatic update from web-platform-tests
Reland "[EventTiming] Add shadow DOM test for first input"

This is a reland of 9591b7074cacf1e8aeb9082dee2a4f46a171083f

Original change's description:
> [EventTiming] Add shadow DOM test for first input
>
> This CL tests event.target for first-input. The DOM elements do not have
> event listeners to show that event retargetting correctly retargets to
> the shadow host.
>
> Bug: 543598
> Change-Id: Ibd5a4a37a50f79b86d93a5c9c18c8ac7300ba723
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159622
> Reviewed-by: Steve Kobes <skobes@chromium.org>
> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#761417}

Bug: 543598
Change-Id: I21537ddc47075a5f0acaf0b53662b4db242c66a0

--

wpt-commits: 2a3389554f038ed396be6f699414aad23e7fe581
wpt-pr: 23180
This commit is contained in:
Nicolás Peña Moreno 2020-04-28 11:38:38 +00:00 коммит произвёл moz-wptsync-bot
Родитель d2976ff5d2
Коммит 5b2ce62944
1 изменённых файлов: 42 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,42 @@
<!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>
<body>
<div id='container'>
<custom-button id='custom_button'></custom-button>
</div>
<script>
promise_test(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').onmousedown = () => {
innerButtonClicked = true;
};
}
});
const observerPromise = new Promise(resolve => {
new PerformanceObserver(t.step_func(entryList => {
// There must only be one first-input entry.
assert_equals(entryList.getEntries().length, 1);
// entry.target must be the shadow host due to retargetting.
assert_equals(entryList.getEntries()[0].target,
document.getElementById('custom_button'));
assert_true(innerButtonClicked, 'Did not reach the shadow DOM event listener!');
resolve();
})).observe({entryTypes: ['first-input']});
});
const clickPromise = test_driver.click(document.getElementById('custom_button'));
return Promise.all([observerPromise, clickPromise]);
}, "Event Timing: test first input on shadow DOM.");
</script>
</body>
</html>