Commit graph

1615 commits

Author SHA1 Message Date
thankyouverycool 59e10d5283 WindowServer: Don't compute title usernames for frameless Windows
This was causing a slight delay when opening ComboBox ListViews.
As an easy first optimization, don't bother computing this at all
for frameless windows and those not type Normal.
2022-11-19 16:04:42 +01:00
thankyouverycool 4aa608aa71 LibGUI+Taskbar+Applets+Applications: Set various windows as Popups
Makes the Audio applet, Taskbar clock, CommandPalette, EmojiPicker,
and Assistant work as Popup windows. Popups are frameless, unmovable,
and unresizable by default, in addition to their preemptive function.
Also sets Assistant not to obey widget min size so its search result
area resizes correctly
2022-11-19 16:04:42 +01:00
thankyouverycool 24d299c9c8 LibGUI+WindowServer+Applets+Taskbar: Remove active input concepts
and the CaptureInput mode. They are a source of unneeded complexity
in WindowServer and have proven prone to regressions, so this patch
replaces them with a simple input preemption scheme using Popups.

Popup windows now have ergonomics similar to menus: When open,
a popup preempts all mouse and key events for the entire window
stack; however, they are fragile and will close after WindowServer
swallows the first event outside them. This is similar to how combo
box windows and popups work in the classic Windows DE and has the
added benefit of letting the user click anywhere to dismiss a popup
without having to worry about unwanted interactions with other
widgets.
2022-11-19 16:04:42 +01:00
thankyouverycool 35bd79701c WindowServer: Add request_close_fragile_windows() helper 2022-11-19 16:04:42 +01:00
thankyouverycool c23adeaaf7 WindowServer: Add foremost_popup_window() helper 2022-11-19 16:04:42 +01:00
thankyouverycool 3027cf7e99 LibGUI+WindowServer: Remove InputPreemptor concept
This functionality will be superceded by WindowType:Popups
2022-11-19 16:04:42 +01:00
thankyouverycool 5d567565a4 LibGUI+WindowServer: Replace WindowInput{Enter,Leave} Events
with WindowInput{Preempted,Restored} Events and allow Widgets to save
the state of their focus preemption. As of now, only Popups will
preempt input and trigger these events.
2022-11-19 16:04:42 +01:00
thankyouverycool 1718a40ac7 LibGUI+WindowServer: Add WindowType:Autocomplete and helpers 2022-11-19 16:04:42 +01:00
MacDue 8a5d2be617 Everywhere: Remove unnecessary mutable attributes from lambdas
These lambdas were marked mutable as they captured a Ptr wrapper
class by value, which then only returned const-qualified references
to the value they point from the previous const pointer operators.

Nothing is actually mutating in the lambdas state here, and now
that the Ptr operators don't add extra const qualifiers these
can be removed.
2022-11-19 14:37:31 +00:00
Timothy Flynn 7398fd107c WebContent: Add missing user prompt handling steps
The text on these steps is slightly different than when this was also
done in 0e94904034, so these were missed.
2022-11-18 12:21:57 +00:00
Timothy Flynn 37c4bf3afd WebDriver: Implement all modes for handling the current user prompt 2022-11-18 12:21:57 +00:00
Timothy Flynn adc7977ec7 WebContent+WebDriver: Send the parsed capabilities over to WebContent 2022-11-18 12:21:57 +00:00
Timothy Flynn e0c7b5747d LibWeb+WebDriver: Begin processing and matching WebDriver capabilities
Still some TODOs here:
* We don't handle all capabilities (e.g. proxy)
* We don't match the capabilities against the running browser

But this will parse the capabilities JSON object received from the
WebDriver client.
2022-11-18 12:21:57 +00:00
Timothy Flynn f7bb835d09 LibWeb+LibWebView+WebContent+WebDriver: Implement Send Alert Text 2022-11-16 17:23:56 +00:00
Timothy Flynn f9b8742fff LibWeb+WebContent+WebDriver: Implement Get Alert Text 2022-11-16 17:23:56 +00:00
Timothy Flynn 3e7d633954 LibWeb+WebContent+WebDriver: Implement Accept Alert 2022-11-16 17:23:56 +00:00
Timothy Flynn 7cf2feb047 LibWeb+WebContent+WebDriver: Implement Dismiss Alert 2022-11-16 17:23:56 +00:00
Timothy Flynn 0e94904034 LibWebView+WebContent: Begin handling open user dialogs for WebDriver
The way in which dialogs should be handled is configurable by the driver
capabilities object, which we don't support yet. So this implements just
the default mode to dismiss the dialog and return an error if there is
one open.

In the OOPWV, this means we need to refer to the dialog after it has
been open, so we now hold a pointer to whatever dialog is open.
2022-11-16 17:23:56 +00:00
Timothy Flynn 364f44d7d8 LibWebView+WebContent: Wait for dialog responses without blocking IPC
Currently, the WebContent process is completely blocked while waiting
for a response to a dialog request. This patch allows the IPC event loop
to continue executing while only blocking the HTML event loop.

This will allow other processes like WebDriver to continue to operate on
the WebContent process while a dialog is open.
2022-11-16 17:23:56 +00:00
Idan Horowitz 798d7c6fae LibWeb: Add 'should block pop ups' user config to Page
This will also be used by the window.open algorithm steps.
2022-11-15 21:48:19 +00:00
Timothy Flynn 4fd9e3ab08 Userland: Remove workarounds for LibIPC include order sensitivity 2022-11-15 13:25:51 -05:00
Timothy Flynn 05f41382bb Userland: Properly define IPC::encode and IPC::decode specializations
In order to avoid the base encode/decode methods from being used (and
failing a static assertion), we must be sure to declare/define the
custom type implementations as template specializations.

After this, LibIPC is no longer sensitive to include order.
2022-11-15 13:25:51 -05:00
Timothy Flynn 8e624c8f6d LibWeb+WebContent+WebDriver: Implement Find Elements From Shadow Root 2022-11-15 11:55:36 +00:00
Timothy Flynn 6d9bd04233 LibWeb+WebContent+WebDriver: Implement Find Element From Shadow Root 2022-11-15 11:55:36 +00:00
Timothy Flynn 4d9fd5d190 LibWeb+WebContent+WebDriver: Implement Get Element Shadow Root 2022-11-15 11:55:36 +00:00
Timothy Flynn cb91e6067c LibWeb+WebContent+WebDriver: Implement Get Active Element
Unfortunately, nothing ever calls DOM::Document::set_active_element at
the moment, so this will always return ErrorCode::NoSuchElement.
2022-11-15 11:55:36 +00:00
Timothy Flynn 826d5f8f9a WebContent+WebDriver: Move Window commands to WebContent
This moves Get Window Handle, Close Window, and Get Window Handles over
to WebContent so they may be implemented closer to the spec and be used
by Ladybird.
2022-11-14 13:43:24 -05:00
Timothy Flynn be50806a18 WebDriver: Remove "Services/" prefix from local WebDriver includes
This is to allow building some of these files from Ladybird. The Build
directory for Ladybird does not include the "Services/" path.
2022-11-14 13:43:24 -05:00
Timothy Flynn 4d4ed96fa1 WebContent: Provide access to ConnectionFromClient's PageHost
This is needed to construct a WebDriverConnection from outside of
PageHost itself in Ladybird.
2022-11-14 13:43:24 -05:00
Timothy Flynn d2b2d3ad80 WebContent: Allow creating a WebDriverConnection with an existing socket
The socket used by WebDriverConnection will be created separately for
Ladybird.
2022-11-14 13:43:24 -05:00
Samuel Bowman d947555527 Taskbar: Support launching apps that require root
If an app file has RequiresRoot=true, launch the app with the requsite
setuid binary. For GUI apps, this is Escalator. For app files with
RunInTerminal=true, this is pls.
2022-11-14 14:58:10 +00:00
Alec Murphy c2f3dead91 WindowServer: Update alt shortcuts for menu items when text changes
WindowServer: Make CI happy :^)
2022-11-13 18:13:17 -07:00
Karol Kosek 0b7f5bbdfb Userland: Accept drag_enter events for widgets supporting file drops
This patch will switch cursor to DragCopy when a user enters a widget
while dragging file(s), giving them a visual clue that it *might* be
dropped into this widget.

This is a rather naive approach, as the cursor icon will change for any
kind of file, as currently programs don't know the drag contents before
dropping it. But after all I think it's better than nothing. :^)
2022-11-13 16:13:03 -07:00
meiskam 8768417b1c WindowServer: Add "[user]" to titlebar when uid differs from login user 2022-11-13 16:02:39 -07:00
Timothy Flynn 5385cb1287 LibWeb+WebContentr+WebDriver: Move driver response wrapping to LibWeb
Success responses are meant to be wrapped in a JSON object with a single
"value" key. Instead of doing this in both WebContent and WebDriver, do
it once in LibWeb.
2022-11-13 16:41:07 +00:00
Timothy Flynn 2c3ff6bb74 WebDriver: Port the WebDriver client to be a Web::WebDriver::Client 2022-11-13 16:41:07 +00:00
Timothy Flynn 47493b5734 WebDriver: Implement Close Window closer to the spec
We are expected to return the list of open handles after closing the
current handle. Also just return a WebDriver::Response instead of a
wrapped Error variant.
2022-11-13 16:41:07 +00:00
Alex Chronopoulos 457fda6354 AudioServer: Stop re-creating the device stream buffer
The buffer provided to `OutputMemoryStream` was made a private class
member. This is because there is no reason to re-create it in every
iteration. Also, the logic becomes more symmetric with
`m_zero_filled_buffer` which is already a class member.
2022-11-12 10:03:42 -07:00
Alex Chronopoulos b22c840963 AudioServer: Stop glitching when toggling mute
Initialize the `AudioServer::Mixer::m_zero_filled_buffer` to zero. The
garbage memory inside that buffer was causing a glitch sound when the
user was toggling the mute checkbox or was moving the volume slider on
and off zero. Glitching was more obvious if the toggling was happening
without any sound being played in parallel.

In addition to that, the `m_zero_filled_buffer` turned to `const` since
there is no intention to modify its content.
2022-11-12 10:03:42 -07:00
Tobias Christiansen 1aa16b4dd4 WebDriver: Implement POST /session/{id}/window/fullscreen endpoint 2022-11-12 12:12:05 +00:00
Timothy Flynn 6a55370401 WebContent: Pass the script timeout into the WebDriver script executor
This was dropped in 0b9803d and 31469ee before the timeouts object was
avaiable in WebContent.
2022-11-11 22:03:23 +00:00
Timothy Flynn 04f41bda52 WebContent+WebDriver: Move Get/Set Timeouts to WebContent 2022-11-11 22:03:23 +00:00
Timothy Flynn cb4b9108d1 LibWeb+WebDriver: Move the timeouts configuration object to LibWeb 2022-11-11 22:03:23 +00:00
Timothy Flynn 7972916be7 Browser+WebDriver: Remove the connection between Browser and WebDriver
WebDriver now only has an IPC connection to WebContent. WebDriver still
launches the browser, but now when the session ends, we simply send a
SIGTERM signal to the browser.
2022-11-11 22:03:23 +00:00
Timothy Flynn c64da0d00c Browser+WebDriver: Add missing header includes
These are currently being included transitively, and will cause an error
when those intermediate includes are removed.
2022-11-11 22:03:23 +00:00
Timothy Flynn 2c9549cb76 Browser+WebContent+WebDriver: Move Get Title to WebContent 2022-11-11 22:03:23 +00:00
Timothy Flynn 7f142745e2 Browser+WebContent+WebDriver: Move Back, Forward, Refresh to WebContent 2022-11-11 22:03:23 +00:00
Timothy Flynn 24fb7cd0ad LibWebView+WebContent: Add IPCs to navigate the browser's history 2022-11-11 22:03:23 +00:00
Timothy Flynn ff6055e0a3 Browser+WebContent+WebDriver: Move Delete All Cookies to WebContent 2022-11-11 18:02:04 +00:00
Timothy Flynn b7f21bb92e Browser+WebContent+WebDriver: Move Delete Cookie to WebContent 2022-11-11 18:02:04 +00:00
Timothy Flynn d202999853 LibWebView+WebContent: Add IPC to update a document's cookie 2022-11-11 18:02:04 +00:00
Timothy Flynn 18abc6c85d Browser+WebContent+WebDriver: Move Add Cookie to WebContent
The new implementation is made a bit simpler by way of TRY. It also
implements setting the SameSite attribute.
2022-11-11 18:02:04 +00:00
Timothy Flynn a3d6c2f6af Browser+WebContent+WebDriver: Move Get Named Cookie to WebContent
Instead of sending *all* cookies over IPC and filtering by name, we now
filter by name from the cookie jar and send just the first matching
cookie.
2022-11-11 18:02:04 +00:00
Timothy Flynn c6a0888088 LibWebView+WebContent: Add IPC to get a document's named cookie 2022-11-11 18:02:04 +00:00
Timothy Flynn c77260c480 Browser+WebContent+WebDriver: Move Get All Cookies to WebContent
There are a couple changes here from the existing Get All Cookies
implementation.

1. Previously, WebDriver actually returned *all* cookies in the cookie
   jar. The spec dictates that we only return cookies that match the
   document's URL. Specifically, it calls out that we must run just the
   first step of RFC 6265 section 5.4 to perform domain matching.

   This change adds a special mode to our implementation of that section
   to skip the remaining steps.

2. We now fill in the SameSite cookie attribute when serializing the
   cookie to JSON (this was a trival FIXME that didn't get picked up
   when SameSite was implemented).
2022-11-11 18:02:04 +00:00
Timothy Flynn d2c1957d8f LibWebView+WebContent: Add IPC to get all cookies for a document's URL 2022-11-11 18:02:04 +00:00
Timothy Flynn 31469ee45a Browser+WebContent+WebDriver: Move Execute Async Script to WebContent
With this, WebDriverEndpoints is unused and removed :^)
2022-11-11 11:36:07 +00:00
Timothy Flynn 0b9803dc93 WebContent+WebDriver: Move Execute Script to WebContent 2022-11-11 11:36:07 +00:00
Timothy Flynn 88dcdf681f Browser+WebContent+WebDriver: Move Get Page Source to WebContent 2022-11-11 11:36:07 +00:00
Timothy Flynn 561f9f36f7 WebContent: Capture entire content rect when taking a full screenshot
Instead of offsetting the screenshot by the position of the document
element, just take a screenshot of the entire content rect. After
looking at Acid3 a bit more, this more accurately represents what the
user actually sees on the webpage.
2022-11-11 11:36:07 +00:00
Timothy Flynn ea0561a0b3 Browser+WebContent+WebDriver: Move Take Element Screenshot to WebContent 2022-11-11 11:36:07 +00:00
Timothy Flynn de1e882601 Browser+WebContent+WebDriver: Move Take Screenshot to WebContent 2022-11-11 11:36:07 +00:00
Timothy Flynn 93e14799c5 Browser+WebContent+WebDriver: Move Is Element Enabled to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 30d6a73d0e Browser+WebContent+WebDriver: Move Get Element Rect to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 9dd62228c8 Browser+WebContent+WebDriver: Move Get Element Tag Name to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 5d32fd7026 Browser+WebContent+WebDriver: Move Get Element Text to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 06f1b8825c Browser+WebContent+WebDriver: Move Get Element CSS Value to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 3c00d0e92b Browser+WebContent+WebDriver: Move Get Element Property to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 1bc94e135f Browser+WebContent+WebDriver: Move Get Element Attribute to WebContent
In doing so, this also implements a FIXME to handle boolean attributes.
2022-11-10 17:02:11 +00:00
Timothy Flynn 7b1f3b7253 WebContent: Return a DOM::Element when getting a known connected element
This is how WebContent::ConnectionFromClient also behaves. Returning the
element as a DOM::ParentNode isn't quite strict enough for upcoming
endpoints.
2022-11-10 17:02:11 +00:00
Timothy Flynn 04ea3992e9 Browser+WebContent+WebDriver: Move Is Element Selected to WebContent 2022-11-10 17:02:11 +00:00
Timothy Flynn 560da56a1d Browser+WebContent+WebDriver: Move Find Elements From Element to WC
This also lets us remove the element location strategy and some
WebContent IPC from Browser/LibWebView now that they are unused.
2022-11-10 13:10:16 +00:00
Timothy Flynn 5a750dc58c WebContent+WebDriver: Move Find Element From Element to WebContent 2022-11-10 13:10:16 +00:00
Timothy Flynn 6dca784fc4 WebContent+WebDriver: Move Find Elements to WebContent 2022-11-10 13:10:16 +00:00
Timothy Flynn 61de50c7fd WebContent+WebDriver: Move Find Element to WebContent
Note that this does nothing to "fix" how element references are created.
We continue to return the element ID because, otherwise, all other
element WebDriver endpoints would break.

On the bright side, we avoid several IPC round trips now that we perform
the entire 'find' operation in the WebContent process; and we are able
to work directly on DOM nodes.
2022-11-10 13:10:16 +00:00
Timothy Flynn 03d0c7a5b6 Browser+WebContent+WebDriver: Move [Max,Min]imize Window to WebContent
This also lets us more fully implement the "iconify the window" method,
which requires we block until the document reaches the "hidden" state.
2022-11-09 19:59:26 +00:00
Timothy Flynn 1c398b32ce Browser+LibWebView+WebContent: Add IPC to minimize and maximize window
Requests to maximize and minimize Browser windows will be coming from
the WebContent process rather than the WebDriver process. Add hooks to
propagate these requests back up to the Browser.
2022-11-09 19:59:26 +00:00
Timothy Flynn b57d7e4332 Browser+WebContent+WebDriver: Move Get/Set Window Rect to WebContent
This also lets us more fully implement the "restore the window" method,
which requires we block until the document reaches the "visible" state.
2022-11-09 19:59:26 +00:00
Timothy Flynn 9505928fdb Browser+LibWebView+WebContent: Add IPC to re[store,size,position] window
Requests to restore, resize, and reposition Browser windows will be
coming from the WebContent process rather than the WebDriver process.
Add hooks to propagate these requests back up to the Browser.

The spec notes "The specification does not guarantee that the resulting
window size will exactly match that which was requested", so these new
methods return the actual new size/position.
2022-11-09 19:59:26 +00:00
Nico Weber 6911c5545c Everywhere: Fix a few comment typos 2022-11-09 16:00:32 +00:00
Timothy Flynn 098216fad7 WebContent: Remove the DRIVER_TRY macro now that it is no longer needed
We can now invoke TRY directly, and don't need to wrap single-value
return statements with braces.
2022-11-09 14:15:59 +00:00
Timothy Flynn cc78a74c51 WebContent+WebDriver: Fully implement closing a session
There were a couple steps missing to close the remote end. Further, we
were not removing the session from the list of active sessions.
2022-11-08 19:58:34 -05:00
Timothy Flynn 3ba6b5a7cb WebContent+WebDriver: Move the Get Current URL command to WebContent 2022-11-08 19:58:34 -05:00
Timothy Flynn 31bb79295d WebContent+WebDriver: Move the Navigate To command to WebContent 2022-11-08 19:58:34 -05:00
Timothy Flynn f7c212a19d WebContent+WebDriver: Set the navigator.webdriver flag from WebDriver
This moves setting the navigator.webdriver flag from after WebContent
creates the WebDriver connection, to its own IPC to be triggered from
WebDriver. This is closer to the spec, but mostly serves as an easy
test to validate the connection.
2022-11-08 19:58:34 -05:00
Timothy Flynn 50ae1ad18a Browser+LibWebView+WebDriver: Connect WebDriver to WebContent
First, this moves the WebDriver socket to the /tmp/websocket/ directory,
as WebDriver now creates multiple sockets per session. Those sockets are
now created with Core::LocalServer rather than manually setting up the
listening sockets (this was an existing FIXME which resolved some issues
I was hitting with creating a second listening socket).

WebDriver passes both socket paths to Browser via command line. Browser
continues to connect itself via one socket path, then forwards the other
socket path to the WebContent process created by the OOPWV. WebContent
then connects to WebDriver over this path.

WebContent will temporarily set the navigator.webdriver flag to true
after connecting to WebDriver. This will soon be moved to its own IPC to
be sent by WebDriver.
2022-11-08 19:58:34 -05:00
Timothy Flynn 6b014489d4 WebContent: Add a very-empty WebDriver IPC class to WebContent
This just sets up the infrastructure for the WebContent process to house
WebDriver IPCs, and adds an IPC for WebContent to create the WebDriver
connection. The WebDriverConnection class inside WebContent ultimately
will contain most of what is currently in WebDriver::Session (so the
copyright attributions are copied here as well).

The socket created by WebDriver is currently /tmp/browser_webdriver
(formatted with some IDs). This will be moved to the /tmp/webdriver
folder, as WebDriver will create multiple sockets to communicate with
both Browser and WebContent as the IPCs are iteratively moved to
WebContent. That path is unveiled here, though it is unused as of this
commit.
2022-11-08 19:58:34 -05:00
Timothy Flynn 8ae10ba0fd LibWeb+WebDriver: Add an IPC-transferable Web::WebDriver::Response class
This is essentially an ErrorOr<JsonValue, Web::WebDriver::Error> class.
Unfortunately, that ErrorOr would not be default-constructible, which is
required for the generated IPC classes. So this is a thin wrapper around
a Variant<JsonValue, Web::WebDriver::Error> to emulate ErrorOr.
2022-11-08 19:58:34 -05:00
Timothy Flynn 0246abec80 LibWeb+WebDriver: Move WebDriverError to Web::WebDriver::Error
This is to prepare for WebContent becoming the WebDriver client.
2022-11-08 19:58:34 -05:00
Sergiy Stupar 288d75fdab WindowServer: Cycle through menu items with the same Alt shortcut
If there are multiple items with the same Alt shortcut, cycle through
them with each keypress instead of activating immediately.
2022-11-08 11:48:37 +01:00
Alex Chronopoulos e86cab00b6 AudioServer: Skip mixing when volume is zero
When volume is zero it is not necessary to go through the mixing loop.
The zero-filled buffer can be written directly to the device, instead,
similar to the muted case. Tested by using the piano app and the main
volume control.
2022-11-07 12:30:57 +00:00
Timothy Flynn cfa5e03108 WebContent: Capture horizontal overflow in full document screenshots
The full-page screenshot was missing horizontal overflow content on most
web pages. Change the dimensions of the captured screenshot to match the
actual content size.
2022-11-05 17:21:30 +00:00
Timothy Flynn 2f5ceeac62 WebContent: Store and provide access to web page content size 2022-11-05 17:21:30 +00:00
Timothy Flynn 95e591b61b LibWebView+WebContent: Add an IPC to take a full document screenshot 2022-11-05 09:29:28 +01:00
Timothy Flynn b0eb45f7c7 WebDriver+Browser: Implement GET /session/{id}/element/{id}/screenshot 2022-11-05 01:10:03 +00:00
Timothy Flynn 3c1c2994f1 LibWebView+WebContent: Add an IPC to take an element screenshot 2022-11-05 01:10:03 +00:00
Timothy Flynn 424e80ee75 LibWebView+WebContent: Add an IPC to scroll an element into view
Note that even though there is no response, this IPC has to be
synchronous to allow all scroll events to trigger before returning to
the calling WebDriver process.
2022-11-05 01:10:03 +00:00
Timothy Flynn 3510fbbea8 WebContent: Abstract calculating an element's absolute rect to a helper 2022-11-05 01:10:03 +00:00
Timothy Flynn 2d75229192 WebDriver+Browser: Implement GET /session/{id}/element/{id}/selected 2022-11-03 19:40:43 -04:00
Timothy Flynn 4067138702 LibWebView+WebConent: Add an IPC to get an element's selected state 2022-11-03 19:40:43 -04:00