Commit graph

2435 commits

Author SHA1 Message Date
Timothy Flynn 60fa3752ee LibWeb+WebContent: Partially implement the switch-to-frame endpoint
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
This is needed by the cookie tests for WPT.
2024-09-15 00:56:21 +01:00
Timothy Flynn bf60765903 LibWeb+WebContent: Implement the WebDriver JSON clone steps for elements
This is needed by WPT to serialize NodeList instances.
2024-09-15 00:56:21 +01:00
Timothy Flynn 2dc8cad785 LibWeb+WebContent: Move element reference WebDriver AOs to a helper file
These will be needed outside of WebDriverConnection.cpp.
2024-09-15 00:56:21 +01:00
Timothy Flynn 5fc51b2ff9 WebContent+WebDriver: Update the current BC when switching windows
We had only implemented this step in the WebDriver process, but we need
to update the remote WebContent process as well.
2024-09-15 00:56:21 +01:00
Timothy Flynn 4a6d0e0f90 LibWeb+WebContent: Use the current window to execute WebDriver scripts
Rather than using the page's top-level window, we must use the window
that is currently active in the WebDriver session.
2024-09-15 00:56:21 +01:00
Timothy Flynn c4da022864 WebContent: Implement the WebDriver concept of current browsing context
When we create a WebDriverConnection object, we currently hand it the
page client for which it was opened, and perform all actions on that
client. However, some WebDriver endpoints change the browsing context
(and therefore page client) on which future commands should be executed.
For example, the switch-frame endpoint will switch the current browsing
context to a frame/iframe context.

This patch implements the current browsing context (and current top-
level browsing context) concepts. They are initialized to that of the
original page. Most of this patch is making sure we execute actions on
the correct context.
2024-09-15 00:56:21 +01:00
Timothy Flynn c2cf65adac WebDriver: Handle script execution results without spinning event loops
We currently spin the platform event loop while awaiting scripts to
complete. This causes WebContent to hang if another component is also
spinning the event loop. The particular example that instigated this
patch was the navigable's navigation loop (which spins until the fetch
process is complete), triggered by a form submission to an iframe.

So instead of spinning, we now return immediately from the script
executors, after setting up listeners for either the script's promise to
be resolved or for a timeout. The HTTP request to WebDriver must finish
synchronously though, so now the WebDriver process spins its event loop
until WebContent signals that the script completed. This should be ok -
the WebDriver process isn't expected to be doing anything else in the
meantime.

Also, as a consequence of these changes, we now actually handle time
outs. We were previously creating the timeout timer, but not starting
it.
2024-09-13 10:11:21 -04:00
Timothy Flynn 541968b30d LibWeb+LibWebView+WebContent: Return a named enum from UI event handlers
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
UI event handlers currently return a boolean where false means the event
was cancelled by a script on the page, or otherwise dropped. It has been
a point of confusion for some time now, as it's not particularly clear
what should be returned in some special cases, or how the UI process
should handle the response.

This adds an enumeration with a few states that indicate exactly how the
WebContent process handled the event. This should remove all ambiguity,
and let us properly handle these states going forward.

There should be no behavior change with this patch. It's meant to only
introduce the enum, not change any of our decisions based on the result.
2024-09-12 17:38:36 -04:00
Jelle Raaijmakers 85fd2e281b LibMedia: Absorb LibAudio
LibMedia will be responsible for both audio and video decoding.
2024-09-12 10:01:19 +02:00
Asutosh Variar 229b64a4b7 Everywhere: Convert from_string_view -> from_string_literal where static 2024-09-11 10:59:04 +01:00
Noah Bright ee352e59db WebDriver: Add boilerplate for endpoint 15.7 Perform Actions
Some checks are pending
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
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
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
Following the structure of the ReleaseActions endpoints, define
analogous classes and methods for PerformActions
2024-09-09 14:11:23 +01:00
Timothy Flynn 0a482e1a53 WebContent+WebDriver: Properly define and invoke stubbed methods
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
2024-09-08 09:01:25 -04:00
Han d1ba317e22 WebDriver: Add Routes, IPC definitions, and boilerplates
Added the following Routes, IPC definitions, and boilerplates for the
missing endpoints:

- Switch To Frame
- Switch To Parent Frame
- Element Clear
- Element Send Keys
2024-09-08 12:59:06 +01:00
Andreas Kling ddbfac38b0 LibWeb: Note what's causing a style invalidation to happen
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.

I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.
2024-09-08 09:45:31 +02:00
Timothy Flynn fc809f9755 LibWebView: Add context menu support to the Inspector's cookie table
The menu can currently support deleting a specific cookie or all cookies
for the current page.
2024-09-07 11:10:27 +02:00
Tim Ledbetter 107549dc86 LibWeb/WebDriver: Align execute script methods with the specification
This change updates `ExecuteScript::execute_script()` and
`ExecuteScript::execute_script()` to bring their behavior in line with
each other and the current specification text.

Instances of the variable `timeout` have also been renamed to
`timeout_ms`, for clarity.
2024-09-06 09:54:16 +02:00
Aliaksandr Kalenik 8cd6682e6f LibGfx+WebContent: Remove unused Font::variant() and Typeface::variant() 2024-09-05 19:21:52 +02:00
Timothy Flynn 5ee92af1d9 LibJS+WebContent: Cache the resolved system time zone identifier
Even though the underlying time zone is already cached by LibUnicode, JS
performs additional expensive lookups with that time zone. There's no
need to do those lookups again until the system time zone has changed.
2024-09-03 19:26:04 +02:00
Sam Atkins da171c3230 Inspector: Add a basic style sheet inspector
Choosing options from the `<select>` will load and display that style
sheet's source text, with some checks to make sure that the text that
just loaded is the one we currently want.

The UI is a little goofy when scrolling, as it uses `position: sticky`
which we don't implement yet. But that's just more motivation to
implement it! :^)
2024-09-03 10:12:07 +01:00
Sam Atkins 51a426cc05 LibWeb: Add method for listing all style sheets on a page
This will be used by the inspector, for showing style sheet contents.

Identifying a specific style sheet is a bit tricky. Depending on where
it came from, a style sheet may have a URL, it might be associated with
a DOM element, both, or neither. This varied information is wrapped in
a new StyleSheetIdentifier struct.
2024-09-03 10:12:07 +01:00
Timothy Flynn d8c69a0e9e LibWebView+WebContent: Monitor for system time zone changes
This creates a TimeZoneWatcher in the UI process to inform all open
WebContent processes when the time zone changes. The WebContent process
will clear its time zone cache to retrieve a fresh zone the next time
it is asked for one.
2024-08-25 09:47:42 +02:00
Gasim Gasimzada 785180dd45 LibJS+WebContent: Implement console.table
- Expose table from console object
- Add new Table log level
- Create a JS object that represents table rows and columns
- Print table as HTML using WebContentConsoleClient
2024-08-22 09:08:50 +01:00
Timothy Flynn 3ec5c1941f LibWeb+LibWebView: Add a button to the Inspector to export its contents
When working on the Inspector's HTML, it's often kind of tricky to debug
when an element is styled / positioned incorrectly. We don't have a way
to inspect the Inspector itself.

This adds a button to the Inspector to export its HTML/CSS/JS contents
to the downloads directory. This allows for more easily testing changes,
especially by opening the exported HTML in another browser's dev tools.

We will ultimately likely remove this button (or make it hidden) by the
time we are production-ready. But it's quite useful for now.
2024-08-20 09:28:25 +02:00
Aliaksandr Kalenik 69c6e07139 LibWeb: Move m_needs_repaint and record_display_list() in Document
Let's make document responsible for display list invalidation,
considering it already takes care of style and layout.
2024-08-19 18:57:20 +02:00
Timothy Flynn 948b6de3b1 LibWeb+LibWebView+WebContent: Add IPC to send drag-and-drop events
This adds the IPC and related hooks to allow the UI to send drag-and-
drop events from the UI process to the WebContent process.
2024-08-19 13:29:19 +02:00
Aliaksandr Kalenik 3edd22143d LibWeb: Remove set_needs_display() from PageClient::ready_to_paint()
There is no need to force repaint when client is ready for the next
frame. We simply need to make sure HTML event loop processing is
scheduled.
2024-08-19 09:03:33 +02:00
Sam Atkins 0e3487b9ab LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue

No behaviour changes.
2024-08-15 13:58:38 +01:00
Maks Verver c68b8b5bda RequestServer: Fix compiling with -DREQUESTSERVER_DEBUG=ON 2024-08-12 02:27:48 +02:00
Tim Ledbetter 5b09430c5e WebContent: Actually start WebDriver timeout timers
The timers added previously in #1021 had no effect, as they were never
started.
2024-08-10 23:18:08 +01:00
Tim Ledbetter 1b2f35c3af WebContent: Add timeouts to WebDriver window state modification methods 2024-08-10 10:37:43 +02:00
Tim Ledbetter fbff0ca6a8 WebContent: Abort WebDriver navigation if session timeout exceeded 2024-08-10 10:37:43 +02:00
Tobias Christiansen 5621f34062 LibWebView + WebContent: Add fonts to be transferable to inspector
This patch adds all the needed plumbing to transfer information
regarding fonts of the selected DOM node to the inspector.
2024-08-09 18:58:04 +01:00
Jelle Raaijmakers b193fe658d LibGfx: Store alpha type information in Gfx::Bitmap
We use instances of `Gfx::Bitmap` to move pixel data all the way from
raw image bytes up to the Skia renderer. A vital piece of information
for correct blending of bitmaps is the alpha type, i.e. are we dealing
with premultiplied or unpremultiplied color values?

Premultiplied means that the RGB colors have been multiplied with the
associated alpha value, i.e. RGB(255, 255, 255) with an alpha of 2% is
stored as RGBA(5, 5, 5, 2%).

Unpremultiplied means that the original RGB colors are stored,
regardless of the alpha value. I.e. RGB(255, 255, 255) with an alpha of
2% is stored as RGBA(255, 255, 255, 2%).

It is important to know how the color data is stored in a
`Gfx::Bitmap`, because correct blending depends on knowing the alpha
type: premultiplied blending uses `S + (1 - A) * D`, while
unpremultiplied blending uses `A * S + (1 - A) * D`.

This adds the alpha type information to `Gfx::Bitmap` across the board.
It isn't used anywhere yet.
2024-08-07 18:51:12 +02:00
Sam Atkins 4ec3968178 WebContent+LibWeb: Display resolved pseudo-element style in inspector
This also now uses the cached computed style for them, instead of
computing it fresh each time.
2024-08-07 16:14:49 +02:00
Timothy Flynn e75ba44f37 LibProtocol+RequestServer: Add IPC to dump RequestServer connection info
This was available on Serenity by sending SIGINFO to RequestServer. Add
an IPC so we may see this info while running the browser.
2024-08-03 15:53:07 -04:00
Andreas Kling b42b7c8dd0 LibWeb: Use bitmaps for important/inherited bits in StyleProperties
This avoids padding the style value array, shrinking StyleProperties
from 4368 bytes to 2288 bytes per instance.
2024-08-02 20:37:40 +02:00
Timothy Flynn facaf953eb LibWeb+WebContent: Add a page hook to invoke the did-click-link IPC 2024-08-02 08:07:00 +02:00
Timothy Flynn 3ff965d672 WebContent: Remove unnecessary [[maybe_unused]] attributes
Noticed while copy-pasting this method to a did-click-link method.
2024-08-02 08:07:00 +02:00
Tim Ledbetter ae51fbd5de WebDriver: Use correct WebDriver IPC path argument name
Previously, the incorrect name for this argument  was being used when
attempting to launch `headless-browser`.
2024-08-01 16:40:19 -04:00
Timothy Flynn 0e640f6f70 WebContent: Limit the Console client to the top-level navigable client
We don't want to set the intrinsic Console object's client to non-top-
level clients, created for e.g. subframes. We also want to make sure the
Console client is updated if the top-level document has changed.
2024-08-01 11:35:49 +02:00
Timothy Flynn 0a819e628e LibWeb+WebContent: Store console clients on the DOM document
We explicitly stopped visting the map of documents to console clients in
commit 44659f2f2a to avoid keeping the
document alive. However, if nothing else visits the console clients, we
may set the top-level console client to a client that has been garbage
collected.

So instead of storing this map, just store the console client on the
document itself. This will allow the document to visit its client.
2024-08-01 11:35:49 +02:00
Timothy Flynn a1c57ed79a WebContent: Do not create JS consoles for fragment-parsing documents
There's no need to go through this setup.
2024-08-01 11:35:49 +02:00
Ali Mohammad Pur 93216a875e RequestServer: Actually hold on to the preload job until it's done
This was some nonsense code left in by mistake, ref commit:
4211639e45

Fixes #904.
2024-07-30 12:03:30 -04:00
Timothy Flynn 4f5604c7db WebContent: Ignore invalid attributes set via the Inspector
Rather than crash, just ignore these values for now. We should invent a
mechanism to send feedback to the user (perhaps via the JS console).
2024-07-30 09:41:35 +02:00
Ali Mohammad Pur 4211639e45 RequestServer+LibHTTP: Cancel requests on client exit
That usually happens in "exceptional" states when the client exits
unexpectedly (crash, force quit mid-load, etc), leading to the job flush
timer firing and attempting to write to a nonexistent object (the
client).

This commit makes RS simply cancel such jobs; cancelled jobs in this
state simply go away instead of sending notifications around.
2024-07-28 13:02:49 +02:00
Shannon Booth c5c1a8fcc7 Bindings: Make item_value return an Optional<JS::Value>
This removes some ambiguity about what the return value should be if
the index is out of range.

Previously, we would sometimes return a JS null, and other times a JS
undefined.

It will also let us fold together the checks for whether an index is a
supported property index, followed by getting the value just afterwards.
2024-07-26 14:26:16 +02:00
Shannon Booth 081c92bf3d Bindings: Remove exception handling for named_item
We don't need this for any case, so just remove it to simplify handling
in PlatformObject.
2024-07-26 14:26:16 +02:00
Andrew Kaster cdffc4238a WebContent: Ignore GC for page client member of BackingStoreManager
This is very non-ideal, but the use of a reference for this member is
technically ok in its current usage as a member of the PageClient
itself.
2024-07-25 18:35:57 -06:00
Jamie Mansfield 2ca8fd1832 LibWeb: Make preferred languages configurable
This also changes fetch to use the preferred languages for the
Accept-Language header.
2024-07-25 11:38:59 +01:00
Sam Atkins 6160400ab7 Revert "WebContent: Limit the Console client to the top-level navigable"
This reverts commit 758f4887bc.

This commit was causing ASAN to complain about a use-after-poison, see
https://github.com/LadybirdBrowser/ladybird/issues/809
2024-07-24 16:44:52 +01:00