Closed Bug 1857571 Opened 1 year ago Closed 8 days ago

Update Marionette to handle window positioning on Wayland

Categories

(Remote Protocol :: Marionette, task, P2)

task
Points:
2

Tracking

(firefox133 fixed)

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: stransky, Assigned: Sasha)

References

(Blocks 2 open bugs, Regressed 1 open bug, )

Details

(Whiteboard: [webdriver:m13], [wptsync upstream])

Attachments

(6 files)

Fix Marionette window positions tests

Component: Task Configuration → Widget: Gtk
Priority: -- → P3
Product: Firefox Build System → Core
Assignee: nobody → stransky
Status: NEW → ASSIGNED
Summary: Fix Marionette window positions tests → Fix Marionette window positions tests under Wayland

Wayland protocol doesn't allow to position toplevel windows (or place them to selected workspace). It also doesn't support to get toplevel window position - random coordinates may be returned.

There's no point to test toplevel wayland window position unless it's in maximized/fullscreen or tiled mode. In such case we know window positions.

Thank you for the information Martin! Based on your feedback I think that we should do the following:

The Webdriver classic specification includes the setWindowRect capability which should basically indicate if a remote end supports all the resizing and positioning commands. Given that this is not possible with Wayland we should set this capability to false when returning the session capabilities in the New Session command. With that we won't need another Wayland specific capability.

Also we would have to assert for Wayland in the WebDriver:SetWindowRect command and return a unsupported operation error.

Do we have a mozinfo flag that we actually could use to indicate that these tests should not be run?

Component: Widget: Gtk → Agent
Product: Core → Remote Protocol

The product::component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit BugBot documentation.

Priority: P3 → --

(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #5)

Do we have a mozinfo flag that we actually could use to indicate that these tests should not be run?

AFAIK Wayland flags is available as nsIGfxInfo.windowProtocol or nsIXULRuntime.idl
https://searchfox.org/mozilla-central/rev/1865e9fba4166ab2aa6c9d539913115723d9cc53/xpcom/system/nsIXULRuntime.idl#346

C++ code uses GdkIsWaylandDisplay() call:
https://searchfox.org/mozilla-central/source/widget/gtk/WidgetUtilsGtk.h#33

What we actually need is flag for mozinfo so that it can be used to skip tests. As it looks like mozinfo has the display flag available which is set to wayland.

If we could still resize the window we should probably split the Marionette unit tests into two tests. One for setting the position and another one for resizing.

Component: Agent → Marionette
Priority: -- → P3
Summary: Fix Marionette window positions tests under Wayland → Update Marionette to handle window positioning on Wayland
Assignee: stransky → nobody
Status: ASSIGNED → NEW

We should re-evaluate the priority of this bug given that it blocks moving all web-platform related tests to the Wayland pool. Also users on such machines using WebDriver classic are affected.

Maybe we should consider this bug for our M12 milestone.

Priority: P3 → --
Whiteboard: [webdriver:triage]

Not sure if it's relevant but we already have such checks in Firefox itself:

let isWayland = gfxInfo.windowProtocol == "wayland";

https://searchfox.org/mozilla-central/rev/6b17ef1f53b0bc68a0d746599c01ad8723c80880/browser/base/content/test/popups/head.js#288

Or in tests:

skip-if = [
  "os == 'android'",
  "os == 'mac'", # Bug 1579623, 1776996
  "display == 'wayland' && os_version == '22.04'",  # Bug 1857240
  "http3",
  "http2",
]

https://searchfox.org/mozilla-central/rev/6b17ef1f53b0bc68a0d746599c01ad8723c80880/dom/base/test/fullscreen/mochitest.toml#52

Mozinfo has it too:

 sandbox.wayland = mozinfo.display == "wayland";

https://searchfox.org/mozilla-central/source/layout/tools/reftest/manifest.sys.mjs#633

Thank you for the additional information! It's good to see that we can easily get the Wayland status in Firefox and mozinfo. So it means that we only have to take care of Marionette and possible manifest updates.

I actually wonder if there is a way to use the Ubuntu 22.04 workers without Wayland given that otherwise we wouldn't be able to test the window positioning feature at all anymore. Joel, do you know if we have a different worker type, or is Wayland the only supported display manager?

Flags: needinfo?(jmaher)

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #13)

I actually wonder if there is a way to use the Ubuntu 22.04 workers without Wayland given that otherwise we wouldn't be able to test the window positioning feature at all anymore. Joel, do you know if we have a different worker type, or is Wayland the only supported display manager?

You can set MOZ_ENABLE_WAYLAND=0 env variable and Firefox will run on X11 (XWayland). We support both (Wayland and X11/XWayland) everywhere on Linux.

that hasn't been tested on the VM worker, most likely it will work though.

there is a desire to get X11 22.04 workers available in CI, but that will be later in H2.

Flags: needinfo?(jmaher)

(In reply to Joel Maher ( :jmaher ) (UTC -8) from comment #15)

there is a desire to get X11 22.04 workers available in CI, but that will be later in H2.

Does it mean that the MOZ_ENABLE_WAYLAND=0 environment variable doesn't work yet, or can it be used as a workaround until realy workers are available?

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #16)

(In reply to Joel Maher ( :jmaher ) (UTC -8) from comment #15)

there is a desire to get X11 22.04 workers available in CI, but that will be later in H2.

Does it mean that the MOZ_ENABLE_WAYLAND=0 environment variable doesn't work yet, or can it be used as a workaround until realy workers are available?

Yes, you can use as a workaround until real workers are available.
Also the env variable set may be the only difference between X11 and Wayland workers.

that assumes xvfb is installed as per references in:
https://searchfox.org/mozilla-central/source/taskcluster/scripts/tester/test-linux.sh

^ it is likely that could silently fail as I don't believe we need xvfb as we are on a VM not a docker image.

I am not aware of it being tested, but it is worth trying.

There is a little bit that we should check for tests running on Wayland:

  • Setting the size of the window should always work but not the position.
  • What does calling WebDriver:GetWindowRect return for both the size and the position? Are these some fake numbers?
  • Because setting the size and position is handled by the same command maybe we can just ignore x and y when Wayland is active.
  • Extending the setWindowRect capability might not be an option because getWindowRect is also affected

Overall more users will switch to Wayland so that we indeed have to make sure that this command works. But we cannot only test with Wayland enabled in CI because we would loose test coverage for setting and getting the window position. As such we may have to run another wdspec test job that uses X11 for just these tests for classic and BiDi.

Beside that the wptrunner should be updated to not depend on the positioning of the test window.

James filed a WebDriver spec issue to clarify the Wayland behavior:
https://github.com/w3c/webdriver/issues/1826

Keeping for triage for next session. Will need to address this in the near future, so probably a good candidate for P2 backlog.

It is acceptable to ignore the actual values when trying to position a window on Wayland or any other window manager that cannot set a specific position for the window. This means we should not fail when x and y coordinates are provided but the target position is not reached due to the use of Wayland.

However, we still need to address how to run tests under both Wayland and X11 environments to ensure that window positioning is correctly tested for window managers that support it. But not sure if it's worth to spin a separate test job for just a handful of tests to run. But if we do we should get the wdspec tests running and move all the not yet covered Marionette tests over. So maybe 2 points are not enough but lets see.

Points: --- → 2
Priority: -- → P2
Whiteboard: [webdriver:triage] → [webdriver:m12]
Whiteboard: [webdriver:m12] → [webdriver:m13]
Assignee: nobody → aborovova
Status: NEW → ASSIGNED

While working on handling window positioning, I've noticed a couple of more things which don't work as expected around window management:

  1. The window maximizing, when calling window.maximize() command the window size is increased but not to the size of the screen (smaller than that). But it seems to also not work when trying to increase the size of the window to the size of the screen, again the window size increases but still stays smaller than the desired screen dimensions.
  2. The restoring of the window after minimization. If we call window.minimize() and then window.restore() the window stays hidden (sizemodechange event is also not fired. Maybe it's also related to the inability to set coordinates, but I'm not sure.

Yes I see the same results on Fedora 40. It's not guaranteed on Wayland that any app size/state request is accepted by compositor.

Attachment #9429641 - Attachment description: Bug 1857571 - [wdspec] Update set_window_rect tests. → Bug 1857571 - [wdspec] Update setting window position and dimensions tests to not fail on Wayland.
Attachment #9429642 - Attachment description: Bug 1857571 - [wdspec] Put window minimization tests at the end of the file to avoid breaking other tests. → Bug 1857571 - [wdspec] Put window minimization tests in the separate files to avoid breaking other tests.
Pushed by aborovova@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2b84cb063260 [marionette] Handle window positioning on Wayland. r=webdriver-reviewers,jdescottes https://hg.mozilla.org/integration/autoland/rev/57fc69f2fc84 [wdspec] Update setting window position and dimensions tests to not fail on Wayland. r=webdriver-reviewers,jdescottes https://hg.mozilla.org/integration/autoland/rev/b10786d2b3db [wdspec] Put window minimization tests in the separate files to avoid breaking other tests. r=webdriver-reviewers,jdescottes
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/48560 for changes under testing/web-platform/tests
Whiteboard: [webdriver:m13] → [webdriver:m13], [wptsync upstream]
Pushed by smolnar@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/179e501f7a4a [wdspec] Disable window minimization tests on Android.
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: