Commit graph

171 commits

Author SHA1 Message Date
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
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
Timothy Flynn
b0eb45f7c7 WebDriver+Browser: Implement GET /session/{id}/element/{id}/screenshot 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
d907fb304e WebDriver: Pass StringView by value
See: 8b1108e485.
2022-11-03 19:40:43 -04:00
Timothy Flynn
92cb67522d WebDriver: Consolidate getting a known connected element to a helper
Instead of verbosely repeating the NOTE and to_int() checks, move this
step to a helper. When we have real connected elements, we can then just
fix this helper.
2022-11-03 19:40:43 -04:00
Timothy Flynn
0f2b4d0aac WebDriver+Browser: Implement GET /session/{id}/element/{id}/enabled 2022-11-03 19:15:43 +00:00
Timothy Flynn
08c687ef20 WebDriver+Browser: Implement GET /session/{id}/element/{id}/rect 2022-11-03 19:15:43 +00:00
Timothy Flynn
a490bca29b WebDriver: Rename serialize_window_rect to serialize_rect
This won't only be used for "Window" rects.
2022-11-03 19:15:43 +00:00
Timothy Flynn
61d0b66bfb WebDriver+Browser: Implement GET /session/{id}/source 2022-11-03 14:48:04 +00:00
Linus Groh
629fbc2cfc WebDriver: Implement POST /session/{session id}/execute/async endpoint 2022-11-02 23:46:30 +00:00
Linus Groh
f88a0c51a3 WebDriver: Implement POST /session/{session id}/execute/sync endpoint 2022-11-02 23:46:30 +00:00
Linus Groh
6e1131e6de WebDriver: Support "data" field in error responses 2022-11-02 23:46:30 +00:00
Timothy Flynn
1ffaad29e1 WebDriver+Browser: Implement GET /session/{id}/screenshot
This doesn't follow the spec to a tee. Our OutOfProcessWebView already
has a bitmap that can be used as the window screenshot. Therefore, we
can bypass the steps that assume we need to access the window's frame
buffer in-flight.

We also don't create an HTMLCanvasElement. We would need a Document in
the WebDriver process to do so. Instead, we can still run the encoding
steps exactly as-is using the screenshot bitmap.
2022-11-02 17:55:37 +00:00
Timothy Flynn
819598aecf WebContent: Support sending large responses to the WebDriver client
Some endpoints, like /session/{id}/screenshot, will require sending
large data to the client. We won't be able to write all of the data in
one shot, so loop over the data until we've sent it all (or fail).
2022-11-02 17:55:37 +00:00
Timothy Flynn
11d0489fa3 WebDriver+Browser: Implement POST /session/{id}/window/minimize 2022-11-02 15:41:19 +00:00
Timothy Flynn
89b2ff72f7 WebDriver+Browser: Implement POST /session/{id}/window/maximize 2022-11-02 15:41:19 +00:00
Timothy Flynn
174248678e WebDriver+Browser: Implement POST /session/{id}/window/rect 2022-11-02 15:41:19 +00:00
Timothy Flynn
dac91c5790 WebDriver+Browser: Implement GET /session/{id}/window/rect 2022-11-02 15:41:19 +00:00
Timothy Flynn
7561308af1 WebDriver: Convert a couple tabs to spaces 2022-11-02 15:41:19 +00:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
martinfalisse
76da0c6c54 WebDriver: Implement GET /session/{id}/element/{id}/text endpoint 2022-11-01 10:55:34 +00:00
demostanis
3e8b5ac920 AK+Everywhere: Turn bool keep_empty to an enum in split* functions 2022-10-24 23:29:18 +01:00
Tobias Christiansen
a534e61b44 WebDriver: Implement GET /session/{id}/element/{id}/name endpoint 2022-10-22 13:44:49 +02:00
Sam Atkins
607767fd10 WebDriver: Extract repeated "check for window or return error" code
If `TRY()` doesn't solve your problems, you're not using enough of it.
2022-10-21 19:59:03 +02:00
Sam Atkins
3232622255 WebDriver: Use WebDriverError::from_code() for all error creation 2022-10-21 19:59:03 +02:00
Sam Atkins
9393904073 WebDriver: Introduce WebDriver::ErrorCode enum
To avoid having to duplicate error text and http codes over and over,
and potentially make mistakes, let's put them all in one place.
2022-10-21 19:59:03 +02:00
Sam Atkins
89c3e0b567 WebDriver: Rename HttpError -> WebDriverError 2022-10-21 19:59:03 +02:00
Tobias Christiansen
354a845d65 WebDriver: Implement GET /session/{id}/element/{id}/css/{name} 2022-10-20 21:26:10 +02:00
Tobias Christiansen
92fd97ed63 WebDriver: Fix old current_window style 2022-10-19 22:34:10 +02:00
Tobias Christiansen
e87456e38f WebDriver: Implement GET /session/{id}/element/{id}/property/{name} 2022-10-19 22:30:06 +02:00
Linus Groh
6641c99c80 WebDriver: Implement GET /session/{session id}/window/handles endpoint 2022-10-19 22:23:47 +02:00
Linus Groh
04ae4b89a3 WebDriver: Fix Session::close_window() declaration order 2022-10-19 21:11:37 +02:00
Linus Groh
7cb9b85c25 WebDriver: Rename Session::{get_window_object => current_window}()
- It's not a "window object" (in the JS sense), it's a simple struct
  storing a handle and is_open property
- We usually omit 'get' for getters
- The new name makes it more clear that this is looked up using the
  m_current_window_handle as a key
2022-10-19 21:11:37 +02:00
Linus Groh
7812b3c130 WebDriver: Remove unused Session::get_window_handles()
With all the implementations being in the Session class, there should
be no reason to expose this to the outside world anyway.
2022-10-19 21:11:37 +02:00
Linus Groh
6eecdb6853 WebDriver: Condense Client handler functions a bit
These comments really aren't necessary, it's clear from the code that
they forward to Session for the actual implementation.
2022-10-19 21:11:37 +02:00
Linus Groh
24ee5a2202 WebDriver: Move GET /session/{session id}/window impl into Session 2022-10-19 21:11:37 +02:00
Linus Groh
0064d2e8c8 WebDriver: Implement POST /session/{session id}/timeouts endpoint 2022-10-19 21:11:37 +02:00
Linus Groh
5c32eacac9 WebDriver: Implement GET /session/{session id}/timeouts endpoint 2022-10-19 21:11:37 +02:00
Linus Groh
4db5f6d081 WebDriver: Use monotonic timer in Session::find() 2022-10-19 21:11:37 +02:00
Linus Groh
f0a8e3bc05 WebDriver: Replace hardcoded timeout with a TimeoutsConfiguration struct 2022-10-19 21:11:37 +02:00
Tobias Christiansen
249350a7a3 WebDriver: Implement GET /session/{id}/element/{id}/attribute/{name} 2022-10-19 17:30:58 +02:00
Tobias Christiansen
e1fb64abad WebDriver: Implement POST /session/{id}/element/{id}/elements 2022-10-19 15:32:31 +02:00
Tobias Christiansen
d26bbcab42 WebDriver: Implement POST /session/{id}/element/{id}/element 2022-10-19 15:32:31 +02:00
Tobias Christiansen
063bd663a7 WebDriver: Implement POST /session/{id}/elements endpoint 2022-10-19 15:32:31 +02:00
Linus Groh
8fc4c5d27b WebDriver: Avoid some JsonValue copies in Session::find_element() 2022-10-18 23:22:38 +02:00