Bug 1693313 [wpt PR 27658] - Portals: Deflake autofocus tests, a=testonly

Automatic update from web-platform-tests
Portals: Deflake autofocus tests

Autofocused elements are not guaranteed to be focused on load, flushing
autofocus candidates for a document is part of the rendering update
(see 11.5 in [1]). This CL updates tests to call requestAnimationFrame
after the document loads to ensure Document::FlushAutofocusCandidates()
[2] gets a chance to run.

[1] https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering
[2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/dom/document.cc;l=7770;drc=15d361f31e050e55eb6b2ada1a02ea5b26eb4f70

Bug: 1178492
Change-Id: Iedc6758c47e2cff53a3bca499aa55e13437fe6ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2699127
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: Lucas Gadani <lfg@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#855275}

--

wpt-commits: eec76c2cddc57690d5621d374ac5a62bd2f4ad81
wpt-pr: 27658
This commit is contained in:
Adithya Srinivasan 2021-02-22 21:47:46 +00:00 коммит произвёл moz-wptsync-bot
Родитель 92fd4478c2
Коммит 6345b136e1
1 изменённых файлов: 4 добавлений и 2 удалений

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

@ -6,8 +6,10 @@
<script>
function messageHandler(e) {
if (e.data === 'check-active-element') {
let autofocusedButton = document.querySelector('#two');
e.source.postMessage(document.activeElement === autofocusedButton);
window.requestAnimationFrame(() => {
let autofocusedButton = document.querySelector('#two');
e.source.postMessage(document.activeElement === autofocusedButton);
});
}
}