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 <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-04-04 17:41:14 -04:00 committed by GitHub
parent ad95a602f8
commit 944e795606
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View file

@ -1253,7 +1253,15 @@ where
self.handle_exit(); self.handle_exit();
}, },
EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(resp_chan) => { 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. // 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; // If there is already a pending page (self.pending_changes), it will not be overridden;

View file

@ -510216,7 +510216,7 @@
[] []
], ],
"servodriver.py": [ "servodriver.py": [
"bd16d7987e539a3325d88876982462ea1a3eb638", "7121e1dafcc2d55ebc18bdf3e922ce9978b94ee1",
[] []
], ],
"webkit.py": [ "webkit.py": [

View file

@ -101,7 +101,7 @@ class ServoWebDriverBrowser(WebDriverBrowser):
# For some reason rustls does not like the certificate generated by the WPT tooling. # For some reason rustls does not like the certificate generated by the WPT tooling.
"--ignore-certificate-errors", "--ignore-certificate-errors",
"--window-size", "800x600", "--window-size", "800x600",
"data:,", "about:blank",
] ]
ca_cert_path = server_config.ssl_config["ca_cert_path"] ca_cert_path = server_config.ssl_config["ca_cert_path"]