From 944e79560609ee2fb5f7bfdde2f56be2c1cee01a Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 4 Apr 2025 17:41:14 -0400 Subject: [PATCH] constellation: Only return focused browsing contexts that exist. (#36330) The webdriver server relies on the constellation to report which browsing context is focused, and assumes that a focused context is ready for interaction. However, new browsing contexts exist in a weird state where they are not tracked by the constellation until the initial load is complete, which leads to the constellation rejecting attempts to navigate a browsing context right after it's created. These changes ensure the constellation does not report a browsing context as focused until it's actually created and ready for interaction. Testing: Run `./mach test-wpt --product servodriver tests/wpt/mozilla/tests/mozilla/DOMParser.html`, which now runs to completion. Fixes: #34551 Fixes: #36328 Signed-off-by: Josh Matthews --- components/constellation/constellation.rs | 10 +++++++++- tests/wpt/meta/MANIFEST.json | 2 +- .../tools/wptrunner/wptrunner/browsers/servodriver.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index db973e6c98d..0cfe698106c 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1253,7 +1253,15 @@ where self.handle_exit(); }, EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(resp_chan) => { - let _ = resp_chan.send(self.webviews.focused_webview().map(|(id, _)| id)); + let focused_context = self + .webviews + .focused_webview() + .filter(|(_, webview)| { + self.browsing_contexts + .contains_key(&webview.focused_browsing_context_id) + }) + .map(|(id, _)| id); + let _ = resp_chan.send(focused_context); }, // Perform a navigation previously requested by script, if approved by the embedder. // If there is already a pending page (self.pending_changes), it will not be overridden; diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index d4ae9d452f6..a30e793a3d4 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -510216,7 +510216,7 @@ [] ], "servodriver.py": [ - "bd16d7987e539a3325d88876982462ea1a3eb638", + "7121e1dafcc2d55ebc18bdf3e922ce9978b94ee1", [] ], "webkit.py": [ diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py index bd16d7987e5..7121e1dafcc 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py @@ -101,7 +101,7 @@ class ServoWebDriverBrowser(WebDriverBrowser): # For some reason rustls does not like the certificate generated by the WPT tooling. "--ignore-certificate-errors", "--window-size", "800x600", - "data:,", + "about:blank", ] ca_cert_path = server_config.ssl_config["ca_cert_path"]