Truly independent web browser
Tests: Wait for the native-key fixture to report its own load
Tim Ledbetter115713db00cf
diff --git a/Tests/LibWeb/AccessibilityBridge/input/native-control-key-editing.html b/Tests/LibWeb/AccessibilityBridge/input/native-control-key-editing.htmlindex 1f387c89dbb..9e34b376ac1 100644--- a/Tests/LibWeb/AccessibilityBridge/input/native-control-key-editing.html+++ b/Tests/LibWeb/AccessibilityBridge/input/native-control-key-editing.html@@ -14,7 +14,7 @@def</textarea><div id="rich" contenteditable>hello world</div><iframe id="iframe" srcdoc='<input value="hello world">'></iframe>-<input id="result" aria-label="Result" readonly value="ready">+<input id="result" aria-label="Result" readonly value="loading"><script>let target;let events = [];@@ -22,6 +22,7 @@ let cancelDeletion = false;let cancelKeyboard = false;let serial = 0;const result = document.getElementById("result");+window.onload = () => { result.value = "ready"; };function report() {if (!target) return;const doc = target.ownerDocument;diff --git a/Tests/LibWeb/AccessibilityBridgeMac/harness/ladybird.py b/Tests/LibWeb/AccessibilityBridgeMac/harness/ladybird.pyindex 1beaa640d57..e24a8c78913 100644--- a/Tests/LibWeb/AccessibilityBridgeMac/harness/ladybird.py+++ b/Tests/LibWeb/AccessibilityBridgeMac/harness/ladybird.py@@ -135,7 +135,6 @@ class LadybirdContext:self._web = Noneself._stderr_file: Optional[tempfile.NamedTemporaryFile] = Noneself._profile_directory: Optional[str] = None- self._initial_load_notifications = Nonedef __enter__(self) -> "LadybirdContext":self.start()@@ -243,12 +242,6 @@ class LadybirdContext:self._app = AXUIElementCreateApplication(self._process.pid)startup_timeout = float(os.environ.get("LADYBIRD_AX_STARTUP_TIMEOUT", "60"))- if self._launch_via_launch_services:- from .notifications import NotificationCollector-- if not wait_for(lambda: _ax_attr(self._app, kAXRoleAttribute), timeout=startup_timeout):- raise RuntimeError("The fixture did not become responsive to accessibility requests")- self._initial_load_notifications = NotificationCollector(self._process.pid, self._app, ["AXLoadComplete"])# A test that decides for itself when an assistive technology first reads the page waits for nothing here: Any# accessibility query into the window turns Qt's accessibility on, and with it the fetch of the page's tree.@@ -290,26 +283,7 @@ class LadybirdContext:f"Stderr:\n{stderr_excerpt}")- if self._initial_load_notifications is not None:- collector = self._initial_load_notifications- try:-- def initial_focus_delivered():- collector.collect(0.05)- return "AXLoadComplete" in collector.names()-- if not wait_for(- initial_focus_delivered, timeout=startup_timeout, description="initial accessibility focus delivery"- ):- raise RuntimeError("The fixture didn't finish its initial accessibility focus announcement")- finally:- collector.close()- self._initial_load_notifications = None-def stop(self) -> None:- if self._initial_load_notifications is not None:- self._initial_load_notifications.close()- self._initial_load_notifications = Noneif self._process is None:self._cleanup_stderr_file()self._cleanup_profile_directory()diff --git a/Tests/LibWeb/AccessibilityBridgeMac/tests/test_native_control_key_editing.py b/Tests/LibWeb/AccessibilityBridgeMac/tests/test_native_control_key_editing.pyindex 1ba7d493e14..33f0658f9b4 100644--- a/Tests/LibWeb/AccessibilityBridgeMac/tests/test_native_control_key_editing.py+++ b/Tests/LibWeb/AccessibilityBridgeMac/tests/test_native_control_key_editing.py@@ -105,6 +105,17 @@ class NativeControlKeyEditingTests(unittest.TestCase):)self.addCleanup(self._cleanup_fixture)self.ctx.start()+ # A page announces its load only to an assistive technology that queried it during the load, and only while+ # the view holds the keyboard focus in the key window. So the fixture reports its own load event.+ self.assertTrue(+ wait_for(+ lambda: any(+ _ax_attr(field, kAXValueAttribute) == "ready"+ for field in find_all_by_role(self.ctx.web, "AXTextField")+ )+ ),+ "fixture did not finish loading",+ )activate_fixture(self.ctx.pid)def _cleanup_fixture(self):