mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 21:45:20 +00:00
Tests: Fix 404 at css selector test
Fixes css/selectors/focus-visible-009.html
This commit is contained in:
parent
dcca24868c
commit
1d2ceaf33f
Notes:
github-actions[bot]
2024-11-29 12:17:57 +00:00
Author: https://github.com/shlyakpavel Commit: https://github.com/LadybirdBrowser/ladybird/commit/1d2ceaf33ff Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2216 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 52 additions and 1 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue