Skip to content

[WebDriver] Properly report error: "No such window"#37385

Merged
jdm merged 4 commits intoservo:mainfrom
yezhizhen:fix-browsing-context
Jun 10, 2025
Merged

[WebDriver] Properly report error: "No such window"#37385
jdm merged 4 commits intoservo:mainfrom
yezhizhen:fix-browsing-context

Conversation

@yezhizhen
Copy link
Copy Markdown
Member

For WebDriver, return "No Such Window" properly according to spec.

Testing: ./mach test-wpt -r --log-raw "D:\servo test log\all.txt" .\tests\wpt\tests\webdriver\tests\classic\ --product servodriver

@yezhizhen
Copy link
Copy Markdown
Member Author

cc @xiaochengh @jdm

@yezhizhen yezhizhen changed the title [WebDriver] Properly report error: no browsing context [WebDriver] Properly report error: "No such window" Jun 10, 2025
Copy link
Copy Markdown
Member Author

@yezhizhen yezhizhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite many added lines, most of them are repetition.
fn verify_browsing_context_is_open and fn verify_top_level_browsing_context_is_open are the core logic being reused.

Signed-off-by: Euclid Ye <[email protected]>
@yezhizhen yezhizhen requested a review from jdm June 10, 2025 18:32
Copy link
Copy Markdown
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Signed-off-by: Euclid Ye <[email protected]>
@jdm jdm enabled auto-merge June 10, 2025 19:09
@jdm jdm added this pull request to the merge queue Jun 10, 2025
Copy link
Copy Markdown
Contributor

@longvatrong111 longvatrong111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me with some suggestions.
In addition, we will check webview still open with embedder soon since we move webdriver to servoshell, but not a big problem.

) -> WebDriverResult<()> {
let browsing_context_id = self.session()?.browsing_context_id;
self.verify_browsing_context_is_open(browsing_context_id)?;
let msg = EmbedderToConstellationMessage::WebDriverCommand(
Copy link
Copy Markdown
Contributor

@longvatrong111 longvatrong111 Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify_browsing_context_is_open here makes webdriver check everytime it sends a script message.
There are scenarios in which webdriver sends multiple script message, we only need to verify once, outside of this function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There are many clean-ups later, this is definitely one of them.

WebDriverCommandMsg::CheckWebViewOpen(webview_id, sender),
))
.unwrap();
if !receiver.recv().unwrap_or(false) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can consider using try_recv and reuse wait_for_script_response here. Benefit are:

  • Can handle error like ipc channel closed.
  • Avoid blocking and timeout in test.

Copy link
Copy Markdown
Member Author

@yezhizhen yezhizhen Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can consider using try_recv

I don't think try_recv is correct here. Perhaps you mean recv_timeout?

reuse wait_for_script_response

Sure! I just further checked, this won't simplify anything.

@longvatrong111
Copy link
Copy Markdown
Contributor

longvatrong111 commented Jun 10, 2025

@jdm after merging this PR, is webdriver test result good enough for us to enable it in the CI?

auto-merge was automatically disabled June 10, 2025 20:08

Pull Request is not mergeable

Merged via the queue into servo:main with commit 56bbc49 Jun 10, 2025
21 checks passed
@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 11, 2025

@longvatrong111 I doubt it. Every intermittent failure that I saw was a panic in the script thread trying to fetch browsing context information from the constellation. You can run some try jobs with the tests enabled in your fork if you want to experiment, though!

@yezhizhen yezhizhen deleted the fix-browsing-context branch June 11, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants