Tests: Fix 404 at css selector test

Fixes css/selectors/focus-visible-009.html
This commit is contained in:
Pavel Shliak 2024-11-27 23:59:48 +04:00 committed by Sam Atkins
parent dcca24868c
commit 1d2ceaf33f
Notes: github-actions[bot] 2024-11-29 12:17:57 +00:00
2 changed files with 52 additions and 1 deletions

View file

@ -7,7 +7,7 @@
<link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" /> <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script> <script src="../../html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script>
<style> <style>
@supports not selector(:focus-visible) { @supports not selector(:focus-visible) {
#button:focus { #button:focus {

View file

@ -0,0 +1,51 @@
'use strict';
function waitForEvent(target, type, options) {
return new Promise((resolve, reject) => {
target.addEventListener(type, resolve, options);
});
}
function waitForAnimationFrame(w) {
let targetWindow = w || window;
return new Promise((resolve, reject) => {
targetWindow.requestAnimationFrame(resolve);
});
}
function waitForEvent(target, type, options) {
return new Promise((resolve, reject) => {
target.addEventListener(type, resolve, options);
});
}
function waitForLoad(target) {
return waitForEvent(target, 'load');
}
function timeOut(test, ms) {
return new Promise((resolve, reject) => {
test.step_timeout(resolve, ms);
});
}
// If an element with autofocus is connected to a document and this function
// is called, the autofocus result is deterministic after returning from the
// function.
// Exception: If the document has script-blocking style sheets, this function
// doesn't work well.
async function waitUntilStableAutofocusState(w) {
let targetWindow = w || window;
// Awaiting one animation frame is an easy way to determine autofocus state.
await waitForAnimationFrame(targetWindow);
}
async function waitForIframeLoad(src, w = window) {
const iframe = w.document.createElement("iframe");
let loadPromise = new Promise(resolve => {
iframe.addEventListener("load", () => resolve(iframe));
});
iframe.src = src;
w.document.body.appendChild(iframe);
return loadPromise;
}