Skip to content

[WebDriver: Set Window Rect] Make best-effort with partial input according to latest spec #53421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 11, 2025

Conversation

yezhizhen
Copy link
Contributor

@yezhizhen yezhizhen commented Jun 26, 2025

The spec was changed in w3c/webdriver#1830 to allow partial parameter and change with best-effort. This makes some test assertion out-dated.

This commit removes those out-dated test and move them to a new function test_partial_input to match the new expectation.

Fixes: #53409
The change is recommended in w3c/webdriver#1906 (comment)

The spec was changed in w3c/webdriver#1830 to allow partial parameter and change with best-effort. This makes some test assertion out-dated.

This commit removes those out-dated test and move them to a new function `test_partial_input` to match the new expecation.

Fixes: web-platform-tests#53409
@yezhizhen
Copy link
Contributor Author

cc @xiaochengh @whimboo

@yezhizhen yezhizhen changed the title Make best-effort Set Rect with partial input according to latest spec [WebDriver: Set Window Rect] Make best-effort with partial input according to latest spec Jun 26, 2025
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. It's mostly in good shape. I’ve left a few minor comments with suggested adjustments you want to have a look at.

Comment on lines 212 to 221
if is_wayland() and ('x' in rect or 'y' in rect):
fields = ("width", "height")
else:
fields = ("x", "y", "width", "height")

for field in fields:
if field in rect:
assert value[field] == rect[field]
else:
assert value[field] == original[field]
Copy link
Contributor

Choose a reason for hiding this comment

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

We won't need this loop here. Instead I would suggest to compare height and width directly if set in the rect. And do the same for x and y if it's not Wayland. That way we can safe us from setting up this extra logic.

Copy link
Contributor Author

@yezhizhen yezhizhen Jul 3, 2025

Choose a reason for hiding this comment

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

I have made the change accordingly.
But if neither x nor y is in rect, even for Wayland we should still make sure the coordinates stay the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@whimboo Just a friendly ping.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the application cannot move the window on its own. The solution you used is elegant. Thanks!

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@yezhizhen yezhizhen requested a review from whimboo July 3, 2025 03:45
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Jul 4, 2025
…accurately (#37848)

`toolbar_height` is already part of `inner_size`, caused wrongly
calculated `outer_size`. Even worse, it tried to `request_inner_size`
with the already wrong `outer_size`.

This PR make sure resize is accurate by first calculate the title/border
height, and then compute the `inner_size` for `request_inner_size`. This
is necessary because no direct `request_outer_size` is available.

Testing: As manually tested, set window size WebDriver command no longer
overshoot. This is also shared by
[window.resizeTo](https://drafts.csswg.org/cssom-view/#dom-window-resizeto)
JS method. WPT test would be necessary. (But that one is intermittent
TIMEOUT. So created new one in
#37856)
 
WebDriver test will be postponed after
web-platform-tests/wpt#53421 is merged and
synced to Servo.

Fixes: Task 3 of #37804

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@whimboo
Copy link
Contributor

whimboo commented Jul 8, 2025

Please lets wait with the review of the test changes until we have clarification on the spec PR.

@yezhizhen
Copy link
Contributor Author

until we have clarification on the spec PR

Which spec PR are we referring to?

github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Jul 9, 2025
#37961)

Previously, we only consider OS decoration height. But when testing
#37960, I find that the decoration width is also non-zero.

Testing: Need to wait W3C spec change
web-platform-tests/wpt#53421 related to
webdriver rectangle. When combined with #37960, this can fix at least
`window_resizeTo.html`.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Which spec PR are we referring to?

Sorry, I had w3c/webdriver#1909 in mind but it's indeed de-coupled.

Comment on lines 212 to 221
if is_wayland() and ('x' in rect or 'y' in rect):
fields = ("width", "height")
else:
fields = ("x", "y", "width", "height")

for field in fields:
if field in rect:
assert value[field] == rect[field]
else:
assert value[field] == original[field]
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the application cannot move the window on its own. The solution you used is elegant. Thanks!

# Wayland doesn't return correct coordinates after changing window position.
if not is_wayland():
assert value["x"] == rect.get("x", original["x"])
assert value["y"] == rect.get("y", original["y"])
Copy link
Contributor

Choose a reason for hiding this comment

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

@sadym-chromium i assume that we run Chrome by default with XWAYLAND so that it can still set the position of the window? So we probably should keep what we have here and not explicitely check the x and y coordinates which can be different between browsers.

@yezhizhen yezhizhen requested a review from whimboo July 10, 2025 07:56
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Looks good to me now. Thanks.

@whimboo whimboo merged commit f4a231f into web-platform-tests:master Jul 11, 2025
25 checks passed
@yezhizhen yezhizhen deleted the patch-1 branch July 11, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Webdriver: Set Window Rect] Why we expect no change when only width or height is provided?
4 participants