From 7b43ee97e24d91e6774ae025afb880c99105ea36 Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 26 Jun 2025 23:18:23 +0800 Subject: [PATCH 1/6] Make best-effort change with partial input according to latest spec The spec was changed in https://github.com/w3c/webdriver/pull/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: https://github.com/web-platform-tests/wpt/issues/53409 --- .../tests/classic/set_window_rect/set.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index f036156c35fd7c..3c38c1534fae89 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -186,7 +186,14 @@ def test_width_height_floats(session): {"height": None, "Y": None}, {"width": None, "height": None, "x": None, "y": None}, +]) +def test_no_change(session, rect): + original = session.window.rect + response = set_window_rect(session, rect) + assert_success(response, original) + +@pytest.mark.parametrize("rect", [ {"width": 200}, {"height": 200}, {"x": 200}, @@ -196,11 +203,22 @@ def test_width_height_floats(session): {"width": 200, "y": 200}, {"height": 200, "y": 200}, ]) -def test_no_change(session, rect): +def test_partial_input(session, rect): original = session.window.rect response = set_window_rect(session, rect) - assert_success(response, original) + value = assert_success(response, session.window.rect) + # Wayland doesn't return correct coordinates after changing window position. + 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] def test_set_to_available_size( session, available_screen_size, minimal_screen_position From 49d94bab4a2361fe7c91202c416c3fa1a6df7fcc Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 26 Jun 2025 23:29:53 +0800 Subject: [PATCH 2/6] Fix Lint --- webdriver/tests/classic/set_window_rect/set.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index 3c38c1534fae89..317930426e18d6 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -213,7 +213,7 @@ def test_partial_input(session, rect): fields = ("width", "height") else: fields = ("x", "y", "width", "height") - + for field in fields: if field in rect: assert value[field] == rect[field] From 29037ddaaff22a2c7b49c3cbec2d4082b7ac767d Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 3 Jul 2025 11:42:25 +0800 Subject: [PATCH 3/6] Apply Henrik's suggestion Signed-off-by: Euclid Ye --- webdriver/tests/classic/set_window_rect/set.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index 317930426e18d6..ffa1db4e9b8bf7 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -187,7 +187,7 @@ def test_width_height_floats(session): {"width": None, "height": None, "x": None, "y": None}, ]) -def test_no_change(session, rect): +def test_with_none_values(session, rect): original = session.window.rect response = set_window_rect(session, rect) assert_success(response, original) @@ -208,17 +208,13 @@ def test_partial_input(session, rect): response = set_window_rect(session, rect) value = assert_success(response, session.window.rect) + assert value["width"] == rect.get("width", original["width"]) + assert value["height"] == rect.get("height", original["height"]) # Wayland doesn't return correct coordinates after changing window position. - if is_wayland() and ('x' in rect or 'y' in rect): - fields = ("width", "height") - else: - fields = ("x", "y", "width", "height") + if not is_wayland(): + assert value["x"] == rect.get("x", original["x"]) + assert value["y"] == rect.get("y", original["y"]) - for field in fields: - if field in rect: - assert value[field] == rect[field] - else: - assert value[field] == original[field] def test_set_to_available_size( session, available_screen_size, minimal_screen_position From 3de4b372f15f907732eee26e29762d6bd7469e1d Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Wed, 9 Jul 2025 20:35:46 +0800 Subject: [PATCH 4/6] Revert to initial solution to check more --- webdriver/tests/classic/set_window_rect/set.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index ffa1db4e9b8bf7..331f4275e14e53 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -208,12 +208,16 @@ def test_partial_input(session, rect): response = set_window_rect(session, rect) value = assert_success(response, session.window.rect) - assert value["width"] == rect.get("width", original["width"]) - assert value["height"] == rect.get("height", original["height"]) - # 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"]) + 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] def test_set_to_available_size( From f22c15c36a997bdd5b36965f84a4d44daa73e6cd Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Wed, 9 Jul 2025 20:37:27 +0800 Subject: [PATCH 5/6] Update all Wayland comment --- webdriver/tests/classic/set_window_rect/set.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index 331f4275e14e53..aea89d12bcedd4 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -143,7 +143,7 @@ def test_x_y_floats(session): response = set_window_rect(session, {"x": 150.5, "y": 250}) value = assert_success(response) - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] == 150 assert value["y"] == 250 @@ -151,7 +151,7 @@ def test_x_y_floats(session): response = set_window_rect(session, {"x": 150, "y": 250.5}) value = assert_success(response, session.window.rect) - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] == 150 assert value["y"] == 250 @@ -208,6 +208,7 @@ def test_partial_input(session, rect): response = set_window_rect(session, rect) value = assert_success(response, session.window.rect) + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if is_wayland() and ('x' in rect or 'y' in rect): fields = ("width", "height") else: @@ -235,7 +236,7 @@ def test_set_to_available_size( response = set_window_rect(session, target_rect) value = assert_success(response, session.window.rect) - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value == target_rect else: @@ -355,7 +356,7 @@ def test_x_y(session): assert value["width"] == original["width"] assert value["height"] == original["height"] - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] == original["x"] + 10 assert value["y"] == original["y"] + 10 @@ -389,7 +390,7 @@ def test_x_as_current(session): assert value["width"] == original["width"] assert value["height"] == original["height"] - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] == original["x"] assert value["y"] == original["y"] + 10 @@ -406,7 +407,7 @@ def test_y_as_current(session): assert value["width"] == original["width"] assert value["height"] == original["height"] - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] == original["x"] + 10 assert value["y"] == original["y"] @@ -424,7 +425,7 @@ def test_negative_x_y(session, minimal_screen_position): assert value["width"] == original["width"] assert value["height"] == original["height"] - # Wayland doesn't return correct coordinates after changing window position. + # Unlike X11, Wayland does not permit applications to change their window position programmatically. if not is_wayland(): assert value["x"] <= minimal_screen_position[0] assert value["y"] <= minimal_screen_position[1] From 02965b7cd0c3f2bd6bc0fc9b79537670ffb1049f Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 10 Jul 2025 15:55:50 +0800 Subject: [PATCH 6/6] Wayland position should stay still --- webdriver/tests/classic/set_window_rect/set.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/webdriver/tests/classic/set_window_rect/set.py b/webdriver/tests/classic/set_window_rect/set.py index aea89d12bcedd4..97e6c2edb18fc7 100644 --- a/webdriver/tests/classic/set_window_rect/set.py +++ b/webdriver/tests/classic/set_window_rect/set.py @@ -208,17 +208,15 @@ def test_partial_input(session, rect): response = set_window_rect(session, rect) value = assert_success(response, session.window.rect) + assert value["width"] == rect.get("width", original["width"]) + assert value["height"] == rect.get("height", original["height"]) # Unlike X11, Wayland does not permit applications to change their window position programmatically. - if is_wayland() and ('x' in rect or 'y' in rect): - fields = ("width", "height") + if not is_wayland(): + assert value["x"] == rect.get("x", original["x"]) + assert value["y"] == rect.get("y", original["y"]) 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] + value["x"] == original["x"] + value["y"] == original["y"] def test_set_to_available_size(