Commit graph

111 commits

Author SHA1 Message Date
Ali Mohammad Pur
0c5c75e8a4 LibCore: Slightly rework the Core::Promise API
The previous iteration of this API was somewhat odd and rough in random
places, which degraded usability and made less than perfect sense.
This commit reworks the API to be a little closer to more
conventional promise APIs (a la javascript promises).

Also adds a test to ensure the class even works.
2023-07-08 23:13:00 +01:00
Cameron Youell
8134dccdc7 AK: Add new failable JsonArray::{append/set} functions
Move all old usages to the more explicit `JsonArray:must_{append/set}`
2023-04-24 09:21:51 +02:00
Aliaksandr Kalenik
34224c42ef WebDriver: Unlink server socket before binding to it
Previously, the create_server function would fail with an "Address
already in use" error if a file that used for socket address is
already exists.
2023-03-23 19:38:44 +01:00
Timothy Flynn
a96ba912b3 WebDriver: Activate the browser tab during the Switch To Window command 2023-03-21 09:39:49 +00:00
Aliaksandr Kalenik
16a4949e33 WebDriver: Fix handling of disconnected WebContent process
If WebContent process got disconnected it is only necessary to remove
associated window instead of terminating the entire session.
2023-03-19 14:51:40 +01:00
Aliaksandr Kalenik
7146c33522 WebDriver: Close all WebContent connections while destroying a session
While closing a session, it is necessary to close all windows that may
have been opened during that session.
2023-03-19 14:51:40 +01:00
Aliaksandr Kalenik
63c16ff41a WebDriver: Inline Sesssion::stop() in session destructor
Previously it was possible to have following sequence of calls
while destroying a session:
1. `WebContentConnection::die()` calls `Client::close_session()`
2. `Client::close_session()` removes a session from active sessions
map which causes session destructor call.
3. Session destructor calls `Client::close_session()` to remove a
session from active sessions.

With `stop()` method inlined into destructor `close_session()` need
to be called just once while destroying a session.
2023-03-19 14:51:40 +01:00
Aliaksandr Kalenik
126fa7df14 WebContent+WebDriver: Get window handle from WebContent process
This change makes window handles on WebDriver process side be
consistent with handles returned by /window/new.
2023-03-16 13:17:37 -04:00
kleines Filmröllchen
8f4d0d3797 LibCore+Userland: Make Promise's on_resolve fallible
This will be primarily necessary for BackgroundAction integration, but
it already allows us to add proper error handling in LibIMAP :^)
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
bfd9f681f7 LibCore+Userland: Allow canceling promises
To make EventLoop cancel its managed Promises, we need the ability to
cancel them in the first place.
2023-03-13 12:12:17 +00:00
Timothy Flynn
12015a4db6 WebDriver: Remove active sessions from the close-the-session AO
These steps now have more than one caller; specifically, they may be
called from the Delete Session and Close Window endpoints. The session
was only removed from the active session map for the former endpoint.

Instead, let's more accurately handle removing the session where the
spec tells us to, so that all callers properly perform this step.
2023-03-07 18:16:35 +00:00
Timothy Flynn
7be8931ca0 WebDriver: Defer removing closed window handles until no longer needed
WebDriver::Session::close_window may invoke Session::stop, which needs
the WebContent connection to still exist. Do not remove the window's
handle (thus destroying the connection) until it is no longer needed.
2023-03-07 18:16:35 +00:00
Timothy Flynn
0ae015e266 WebDriver: Do not ignore the result of closing a session 2023-03-07 18:16:35 +00:00
Aliaksandr Kalenik
5c117cdcec WebDriver: Keep WebDriver socket listening until session end
WebDriver socket should not be closed as soon as first client
got connected becaused there might more than one WebContent
process spawned by browser.
2023-03-07 07:16:23 -05:00
Aliaksandr Kalenik
0905fd57e4 WebContent+WebDriver: Move window commands handling back to WebDriver
With current architecture every window has its own WebContent process
and there is one WebDriver process that is responsible for talking to
all opened windows. It thus make sense to manage open windows from
WebDriver process instead of WebContent process that is not supposed
to know about all other opened WebContent processes.

This mostly reverts 826d5f8f9a but also
adds `web_content_connection` to window structure and window id
generation (currently out of spec).

With these changes `get_window_handles`, `switch_to_window` and
`close_window` start to actually switch, close and returned handles
of currently opened windows.
2023-03-07 07:16:23 -05:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Timothy Flynn
cbbaf8ea2c WebDriver: Remove the WebContent socket file when closing the session
Otherwise it is left on disk forever.
2022-12-15 17:29:19 +00:00
Timothy Flynn
956fa84f12 WebDriver: Specify callbacks for clients to launch browser windows
This moves the actual launching of browser windows to the WebDriver main
file. This will allow Ladybird to specify its own callback and re-use
Serenity's Session class.
2022-12-15 17:29:19 +00:00
Timothy Flynn
366f24a73b WebContent+WebDriver: Move WebDriver socket to the standard runtime path
This will allow Ladybird to use local socket files rather than passing
around a bunch of socket FDs.
2022-12-15 17:29:19 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Timothy Flynn
7edd57dc87 LibWeb+WebDriver: Support running headless WebDriver sessions
This adds an "extension capability" for clients to indicate that a
headless browser should be used for the session.
2022-11-24 00:10:56 +00: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
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
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
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
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
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
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
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
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
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