Commit graph

2489 commits

Author SHA1 Message Date
Timothy Flynn
1aab7b51ea LibWebView: Generate hyperlinks for attributes that represent links
On the view-source page, generate anchor tags for any 'href' or 'src'
attribute value we come across. This handles both when the attribute
contains an absolute URL and a URL relative to the page.

This requires sending the document's base URL over IPC to resolve
relative URLs.
2024-10-20 08:50:01 +02:00
Timothy Flynn
048b51eb54 WebContent: Add a JS visitor to WebDriver's IPC connection
We've added a few JS::Handle members to this class over time. Let's
avoid creating a new GC root for each of these, and explicitly add a
visitation method.
2024-10-18 09:45:04 +02:00
Timothy Flynn
022e2b8a94 LibWeb+WebContent: Rename the WebDriver get-known-element AO
The underlying concept is the same, but this method was renamed in the
spec to drop the word "connected".
2024-10-18 09:45:04 +02:00
Timothy Flynn
a96a762305 LibWeb+WebContent: Use NNGCPtr in WebDriver code where appropriate
Some of this code is older than widespread use of GCPtr. These functions
returning raw pointers has been a point of confusion at times, so lets
just indicate that they are non-null.
2024-10-18 09:45:04 +02:00
Timothy Flynn
32a22c49e3 LibWeb: Move StructuredSerializeOptions to its own header
This largely reduces the number of files needed to be compiled when we
change the MessagePort header.
2024-10-17 16:34:32 -04:00
Aliaksandr Kalenik
c690fb9df3 LibWeb: Rename Layout::Node::paintable() to first_paintable()
Layout node is allowed to have multiple corresponding paintables, so
first_paintable() is more explicit name for getter that returns first
paintable.
2024-10-16 20:25:42 +02:00
Sam Atkins
5cc75d4de4 LibWeb: Remove tiny-OOM handling from dump code 2024-10-16 08:32:29 +02:00
Timothy Flynn
e070ed5658 LibWeb+LibWebView: Add an internal API to expire cookies with an offset
Cookies have a minimum expiry resolution of 1 second. So to test cookie
expiration, the test had to idle for at least a second, which is quite a
noticeable delay now that LibWeb tests are parallelized.

Instead, we can add an internal API to expire cookies with a time offset
to avoid this idle delay.
2024-10-14 08:25:41 +02:00
Timothy Flynn
dae6200c1d LibWeb: Update (not replace) timeout values in WebDriver's Set Timeouts
Contradictory to the spec, the Set Timeouts endpoint should update the
existing timeouts configuration in-place, rather than replacing it. WPT
expects this, and other browsers already implement this endpoint this
way.
2024-10-12 15:02:41 +02:00
Timothy Flynn
8396afeb76 LibWeb: Update WebDriver timeout parsing/serializing to the latest spec
Namely, all fields in the timeouts object may now be null. There are a
few calling AOs that we will want to bring up to date as well.
2024-10-12 15:02:41 +02:00
Timothy Flynn
8598ed86fe LibWeb+WebContent: Implement the Element Clear endpoint 2024-10-12 15:01:35 +02:00
rmg-x
10acf3f6c7 RequestServer: Set CURLOPT_CONNECTTIMEOUT instead of CURLOPT_TIMEOUT
Set the connection timeout which only limits the connection phase of the
request.

Previously, CURLOPT_TIMEOUT would apply to all transfer operations which
could result in legitimate upload or download operations being
cancelled.
2024-10-11 13:18:05 +02:00
Timothy Flynn
23d134708c LibWeb: Begin implementing the Element Send Keys endpoint 2024-10-11 09:09:23 +02:00
Timothy Flynn
922837f31b WebDriver: Generalize asynchronous event handling
Instead of having N functions all implement the same practice of looping
until an async event has arrived, this templatizes the bulk of the work.
2024-10-11 09:09:23 +02:00
rmg-x
db0dbb384e RequestServer: Set default timeout to 90 seconds for all requests 2024-10-10 19:56:11 +01:00
rmg-x
ff18114ae7 LibWeb+LibRequests+RequestServer: Report network error on request finish
This allows us to bubble up network errors to API consumers after
finishing a request.
2024-10-10 19:56:11 +01:00
Timothy Flynn
13fe3477ab WebContent: Wait for same-URL WebDriver navigations to complete
The spec says we don't need to await navigations if we navigate to the
same URL that we are already on, but at least in our implementation, we
should still await the page load. Otherwise, we will invoke WebDriver
endpoints on the wrong page.
2024-10-10 10:41:10 +02:00
Timothy Flynn
cbf8f1495c WebContent: Create an execution context when getting an element property
Calling Object::get requires a running execution context.
2024-10-10 10:41:10 +02:00
Timothy Flynn
62e732e5ad Revert "WebContent+WebDriver: Inform WebDriver when a window is closed"
This reverts commit 556a0936dd.

This was causing a large slow down in WPT, and a crash on macOS during
session shutdown when running WebDriver manually.
2024-10-07 07:40:22 -04:00
Timothy Flynn
ce11a90726 WebContent+WebDriver: Handle when new windows are immediately closed
This happens when window.close() is invoked immediately upon a window
being opened.
2024-10-06 01:42:24 +01:00
Timothy Flynn
556a0936dd WebContent+WebDriver: Inform WebDriver when a window is closed from JS
This hooks into the same PageClient method that closes the UI tab after
an invocation to window.close().
2024-10-06 01:42:24 +01:00
Timothy Flynn
5aa50bff8b LibWeb+WebDriver+WebContent: Implement the Element Click endpoint 2024-10-06 01:42:24 +01:00
Timothy Flynn
95bf6c9877 WebContent: Do not wait for navigations on BCs that have no navigable
This avoids a crash seen in WPT when a click event is fired on a BC that
has been removed from the document.
2024-10-06 01:42:24 +01:00
Timothy Flynn
ab3cfd9bbb WebContent: Separately store the WebDriver parent and top-level BCs
We are currently trying to access the current parent and top-level
browsing contexts from the current BC itself. However, if the current BC
is closed, its association to the parent and top-level BCs is lost, and
we are no longer able to handle WebDriver endpoints involving those BCs.

Instead, let's store the parent and top-level BCs separately, and update
them in accordance with the spec.
2024-10-06 01:42:24 +01:00
Timothy Flynn
969361abdb WebDriver: Allow deleting sessions with an invalid window handle
This case was missed in commit b5aa8f65b1.
2024-10-06 01:42:24 +01:00
Andreas Kling
cc4b3cbacc Meta: Update my e-mail address everywhere
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-10-04 13:19:50 +02:00
Aliaksandr Kalenik
4a43d0ac98 LibWeb: Move updating the rendering into HTML task
Implements https://github.com/whatwg/html/pull/10007 which basically
moves style, layout and painting from HTML processing task into HTML
task with "rendering" source.

The biggest difference is that now we no longer schedule HTML event loop
processing whenever we might need a repaint, but instead queue a global
rendering task 60 times per second that will check if any documents
need a style/layout/paint update.

That is a great simplification of our repaint scheduling model. Before
we had:
- Optional timer that schedules animation updates 60 hz
- Optional timer that schedules rAF updates
- PaintWhenReady state to schedule a paint if navigable doesn't have a
  rendering opportunity on the last event loop iteration

Now all that is gone and replaced with a single timer that drives
repainting at 60 hz and we don't have to worry about excessive repaints.

In the future, hard-coded 60 hz refresh interval could be replaced with
CADisplayLink on macOS and similar API on linux to drive repainting in
synchronization with display's refresh rate.
2024-10-04 07:07:01 +02:00
Timothy Flynn
bf668696de LibWeb+WebContent: Do not include DOM HTML in text test expectations
For example, in the following abbreviated test HTML:

    <span>some text</span>
    <script>println("whf")</script>

We would have to craft the expectation file to include the "some text"
segment, usually with some leading whitespace. This is a bit annoying,
and makes it difficult to manually craft expectation files.

So instead of comparing the expectation against the entire DOM inner
text, we now send the inner text of just the <pre> element containing
the test output when we invoke `internals.signalTextTestIsDone`.
2024-10-03 07:07:28 -04:00
Zachary Huang
e0bd42be95 ImageDecoder+LibGfx: Collate decoded bitmaps before sending over IPC
There is an issue where gifs with many frames cannot be loaded, as each
bitmap is sent over IPC using a separate file descriptor, and there is
limit on the maximum number of descriptors per IPC message. Thus, trying
to load gifs with more than 64 frames (the current limit) causes the
image decoder process to die.

This commit introduces the BitmapSequence class, which is a thin wrapper
around the type Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>> and
provides an IPC encode/decode routine that collates all bitmap data into
a single buffer so that only a single file descriptor is required per
IPC transfer, even if multiple frames are being sent.
2024-10-02 15:57:41 -06:00
Timothy Flynn
b3f8d63372 WebContent: Implement the Release Actions endpoint 2024-10-01 11:02:27 +02:00
Timothy Flynn
709deeb482 LibWeb+WebContent+WebDriver: Implement the Perform Actions endpoint
Similar to script execution, this spins the WebDriver process until the
action is complete (rather than spinning the WebContent process, which
we've seen result in deadlocks).
2024-10-01 11:02:27 +02:00
Timothy Flynn
94c243acd6 LibWeb+WebContent: Partially implement WebDriver's JSON deserialize AO
In particular, we need to convert web element references to the actual
element. The AO isn't fully implemented because we will need to work out
mixing JsonValue types with JS value types, which currently isn't very
straight forward with our JSON clone algorithm.
2024-10-01 11:02:27 +02:00
Timothy Flynn
8944c6db3f LibWeb+WebContent: Move WebDriver property extraction to a helper file
This will be needed outside of WebContent.
2024-10-01 11:02:27 +02:00
Timothy Flynn
264b2827cd WebContent: Create a temporary execution context to parse WebDriver JSON 2024-09-29 11:48:40 +02:00
Timothy Flynn
b5aa8f65b1 WebDriver: Ensure that the session's current window handle is valid
After closing a window, it is the client's job to switch to another
window before executing any other command. Currently, we will crash if
that did not happen when we try to send an IPC to a window handle that
we no longer hold. This patch makes us return a "no such window" error
instead.

The exceptions to this new check are the "Switch to Window" and "Get
Window Handles" commands.
2024-09-29 11:48:40 +02:00
Timothy Flynn
157d41bb0d LibWeb: Form the correct representation of a WebDriver element reference
We are currently returning a JSON object of the form:

    {
        "name": "element-6066-11e4-a52e-4f735466cecf",
        "value": "foo"
    }

Instead, we are expected to return an object of the form:

    {
        "element-6066-11e4-a52e-4f735466cecf": "foo"
    }
2024-09-27 09:46:55 +01:00
Timothy Flynn
b035f0cd3d WebContent+WebDriver: Log all unimplemented WebDriver endpoints
It's difficult to know what we need to implement if we silently ignore
these endpoints. Let's log the endpoints and their parameters, and clean
up the wall of FIXME comments to be easier to grok.
2024-09-25 14:03:46 -04:00
Tim Ledbetter
8939ae8522 WebContent: Return errors from unimplemented WebDriver endpoints
Previously, some otherwise unimplemented WebDriver endpoints were
indicating that they had executed successful, this was causing a large
number of Web Platform Tests to time out when they should have failed.
2024-09-23 08:43:18 -04:00
Timothy Flynn
9e21e44841 LibWebView+WebContent+UI: Remove cookie related WebView callbacks
There's no need for each individual chrome to implement the cookie
callbacks. We can handle these entirely within LibWebView.
2024-09-22 14:11:18 -04:00
Timothy Flynn
93ec010bee RequestServer: Remove unused threading-related includes 2024-09-22 14:07:16 -04:00
Andreas Kling
504c80a202 RequestServer: Remove now-unused HTTP related code 2024-09-22 06:43:12 +02:00
marcin mikołajczak
fc2141c852 RequestServer: Set request body for other methods that can have a body 2024-09-21 18:13:31 +02:00
Noah Bright
6862796d5e WebDriver: Implement Switch To Frame for null ID
Fill in a few lines from the spec :^)
2024-09-21 16:47:16 +01:00
Andrew Kaster
1d43d5b086 LibWeb: Use proper enums in WorkerOptions dictionary 2024-09-20 22:41:24 +01:00
Timothy Flynn
3332230cef LibWebView+WebContent+headless-browser: Make the page info IPCs async
The IPCs to request a page's text, layout tree, etc. are currently all
synchronous. This can result in a deadlock when WebContent also makes
a synchronous IPC call, as both ends will be waiting on each other.

This replaces the page info IPCs with a single, asynchronous IPC. This
new IPC is promise-based, much like our screenshot IPC.
2024-09-19 18:07:17 +02:00
Andreas Kling
3ef0fc89b3 RequestServer: Fix assertion on exit when curl had pending timeouts
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
If we already destroyed our timer during destruction, and then curl
tries to flush its timeouts when we tear down the multi, we can just
ignore the timer callbacks.
2024-09-19 11:45:15 +02:00
Andreas Kling
3e6448efcf RequestServer: Use CURLOPT_PRIVATE to store pointer to our own data
This is a lot nicer than scanning through our list of requests. :^)
2024-09-19 11:45:15 +02:00
Andreas Kling
e205723b95 RequestServer: Make WebSocket IPC APIs asynchronous
This fixes deadlocking when interacting with WebSockets while
RequestServer is trying to stream downloaded data to WebContent.
2024-09-19 07:37:46 +02:00
Andreas Kling
853a75c4ab RequestServer: Remove download progress updates that nobody used 2024-09-19 07:37:46 +02:00
Andreas Kling
6d91c42214 RequestServer: Remove "dump connection info" mechanism and UI
This is not relevant anymore when we use CURL.
2024-09-19 07:37:46 +02:00