Commit graph

64323 commits

Author SHA1 Message Date
Timothy Flynn
3e9a2ef0b2 LibWeb: Move WebDriver's HeapTimer helper class to its own file
And generalize it a tiny bit to be reusable outside of ExecuteScript.

(cherry picked from commit 8598d4670dc6a5b44f2081457af10ea5b2306108)
2024-11-28 18:58:55 -05:00
Timothy Flynn
528fa3bbdb LibWeb: Add a NavigationObserver to be notified of navigable updates
This contains a hook to be notified when a navigable navigation is
complete, to be used by WebDriver.

(cherry picked from commit 74ef9dc3936d678fdf811bb3c1b39a6ffba2b106)
2024-11-28 18:58:55 -05:00
Timothy Flynn
750ef1466f LibWeb: Allow removing DocumentObserver hooks
Some callers (namely WebDriver) will want to stop receiving updates from
the DocumentObserver.

(cherry picked from commit 247307a2a28e92b20a57d127eed73a093dd4e3d3)
2024-11-28 18:58:55 -05:00
Timothy Flynn
9690784996 LibWeb: Add a DocumentObserver hook to be notified of readyState changes
(cherry picked from commit 0bbe836f8c10cd4d080927021b9b5b48f1dfc20a)
2024-11-28 18:58:55 -05:00
Timothy Flynn
d992565f52 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.

(cherry picked from commit dae6200c1dab586258a8a970ba308c6b2f1cad9c)
2024-11-28 18:58:55 -05:00
Timothy Flynn
c97e740348 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.

(cherry picked from commit 8396afeb76b5229c385525d307a8d91efa45d6ff)
2024-11-28 18:58:55 -05:00
Andrew Kaster
1b3e190028 LibWebView+WebContent: Prefix AK::Duration with AK Namespace
(cherry picked from commit 28093fecaeaee4ed2ae8ea973e6cade5ce762402)
2024-11-28 18:58:55 -05:00
Timothy Flynn
d8080cf1a6 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.

(cherry picked from commit 048b51eb54d003af5dc202af1b16bb690b1348f9)
2024-11-28 18:58:55 -05:00
Timothy Flynn
2d24c5fbf8 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".

(cherry picked from commit 022e2b8a94497c01138840478f76af07ddcf51da)
2024-11-28 18:58:55 -05:00
Timothy Flynn
c2a4606c1f 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.

(cherry picked from commit a96a762305423965a9697c2b7038a229d96ac734)
2024-11-28 18:58:55 -05:00
Timothy Flynn
dfa9ed08ac LibWeb+WebContent: Implement the Element Clear endpoint
(cherry picked from commit 8598ed86fe9b07e55655d36fcce7ec1dfdbc4491)
2024-11-28 18:58:55 -05:00
Timothy Flynn
47845a32c4 LibWeb: Implement the form associated element clear algorithm
This is a method defined in the WebDriver spec, but requires access to a
bunch of private fields in these classes, so this is implemented in the
same manner as the reset algorithm.

(cherry picked from commit 516f5f70081526ddef2d4a88fc5a1ae916e12fab)
2024-11-28 18:58:55 -05:00
Timothy Flynn
e649cd9108 LibWeb: Begin implementing the Element Send Keys endpoint
(cherry picked from commit 23d134708c6ba20fcb6a18ee6552dc1b5ac0cd6d)
2024-11-28 18:58:55 -05:00
Timothy Flynn
6e4d7015bc 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.

(cherry picked from commit 922837f31b4cc66f6a3acd875962b54c6d547f65)
2024-11-28 18:58:55 -05:00
Timothy Flynn
5281349590 LibWeb: Support appending files to <input type=file>
This isn't exposed to the Web, but WebDriver requires this feature.

(cherry picked from commit 63b24e38faab768799a6597e1b7703f4b62cac02)
2024-11-28 18:58:55 -05:00
Timothy Flynn
fb11a8266c LibWeb: Implement dispatching WebDriver key down and key up actions
(cherry picked from commit d6a8fc00c3435bd9b4e61edeb364dec5c1bf65ea)
2024-11-28 18:58:55 -05:00
Timothy Flynn
d50fb09301 LibWeb: Support non-required numpad code names
These aren't required to comply with the UIEvents spec, but they are
required by WebDriver.

(cherry picked from commit 5b2633d90f81d0098d5d7cea1274b98c91851fae;
amended to change `MOD_KEYPAD` to 32 to match serenity's `Mod_Keypad`
in Kernel/API/KeyCode.h)
2024-11-28 18:58:55 -05:00
Timothy Flynn
45f89decac LibWeb: Allow multi-byte code point events to have their key field set
Multi-byte code point presses do not have a UIEvents::KeyCode value, so
we would previously set the event's key field to "Unidentified".

(cherry picked from commit a11e5055c7f225da3b96571e892042868fd2af18)
2024-11-28 18:58:55 -05:00
Timothy Flynn
496cccab85 LibWeb: Properly handle when (shift+)tab wraps around the page
We have support for using (shift+)tab to move focus to the next/previous
element on the page. However, there were several ways for this to crash
as written. This updates our implementation to check if we did not find
a node to move focus to, and to reset focus to the first/last node in
the document.

This doesn't seem to work when wrapping around from the first to the
last node. A FIXME has been added for that, as this would already not
work before this patch (the main focus here is not crashing).

(cherry picked from commit 96b5646fc116a98dac80559b9a4be2c149f2e157)
2024-11-28 18:58:55 -05:00
Timothy Flynn
1b8ace0d25 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.

(cherry picked from commit 13fe3477ab8ac253bd7346d50b3224baf891872e)
2024-11-28 18:58:55 -05:00
Timothy Flynn
5e555ee02b WebContent: Create an execution context when getting an element property
Calling Object::get requires a running execution context.

(cherry picked from commit cbf8f1495ccd553f4d9e0919ce707938912fca5f)
2024-11-28 18:58:55 -05:00
Timothy Flynn
965e1baa8c LibWeb+UI: Detect and handle left vs. right modifier keys
Our handling of left vs. right modifiers keys (shift, ctrl, etc.) was
largely not to spec. This patch adds explicit UIEvents::KeyCode values
for these keys, and updates the UI to match native key events to these
keys (as best as we are able).

(cherry picked from commit 4fcaeabe1a6acd9f4d5fd811a36f2e86748b2a72;
amended to make the rest of the system build and to keep `Mod_AltGr`
around in addition to adding it as a key)

Co-authored-by: Nico Weber <thakis@chromium.org>
2024-11-28 15:15:36 -05:00
Timothy Flynn
96ba151190 LibWeb: Only fire keypress events if the key press produced a character
For example, pressing just the shift key should not producde a keypress
event.

(cherry picked from commit 448754d95dc797b44d9b066c1e37dabec79d79e6;
amended to not use ICU in CharacterTypes.cpp)
2024-11-28 15:15:36 -05:00
Timothy Flynn
3e85b7bf53 LibWeb: Fire keydown and keypress events sooner
Fire the events before handling any close requests or selection changes.
Pages must have an opportunity to cancel the events.

(cherry picked from commit 3925317c118e23a9b87b65ca792c5d94a92c98a7)
2024-11-28 15:15:36 -05:00
Timothy Flynn
50fd33a531 UI/AppKit: Send keyboard events for modifier-only key presses/releases
If the user only presses the shift key, for example, we are required to
still send that event to WebContent and generate the corresponding JS
events. Unfortunately, NSApp does not inform us of these events via the
keyDown/keyUp methods. We have to implement the flagsChanged interface,
and track for ourselves what modifier keys were pressed or released.

(cherry picked from commit eabd5b0f2271e7a89727daf80dd28623711f3416)
2024-11-28 15:15:36 -05:00
Nico Weber
7a735481ba Meta: Add BeforeUnloadEvent to the GN build 2024-11-28 14:15:33 -05:00
Tim Ledbetter
310390eaf0 LibWeb: Implement the "check if unloading is canceled" AO
This method is responsible for firing `beforeunload` events.

(cherry picked from commit 1fa948f11444108bf1759d39b3dc14e76dd053c6)
2024-11-28 14:15:33 -05:00
Tim Ledbetter
d0651581f6 LibWeb: Ensure special error event handling applies to workers
(cherry picked from commit f807b2800e8c1e4fcf15bd44a181377b351f0a4c)
2024-11-28 14:15:33 -05:00
Tim Ledbetter
13f5bff2eb LibWeb: Implement BeforeUnloadEvent
This is required to support legacy behavior of the `returnValue`
attribute.

(cherry picked from commit 99ef078c9733f5dae04e29aa0c5393ec1acc7fb9)
2024-11-28 14:15:33 -05:00
Psychpsyo
425941cfb1 LibWeb: Add handling for 'an end tag whose tag name is sarcasm'
(cherry picked from commit e602578501924f9ea5cf4915a51fb60187b61fae)
2024-11-27 20:00:55 -05:00
Tim Ledbetter
cbbd5cb8ed LibWeb: Use [URL] extended attribute for HTMLInputElement.src
(cherry picked from commit cc0ad0d1ef653c7e56a527c310bb7192f153c76b)
2024-11-27 20:00:55 -05:00
Hendiadyoin1
be91f5c12f Kernel: Use TypedMapping<T volatile[]> in the RTL8168NetworkAdapter 2024-11-27 22:16:45 +01:00
Hendiadyoin1
72024008c0 Kernel: Use TypedMapping<T volatile[]> in the E1000[E]NetworkAdapters 2024-11-27 22:16:45 +01:00
Hendiadyoin1
c90111a8bc Kernel: Add support for Arrays to TypedMapping
This is quite useful, as it is a common pattern that a Kernel allocated
DMA buffer is just a simple array of some type.
2024-11-27 22:16:45 +01:00
Hendiadyoin1
16a5c8a181 Kernel: Remove unused ScatterGatherList.h include from VirtIO/Queue.h 2024-11-27 22:16:45 +01:00
Ninad Sachania
6d7bca7f1c Utilities/markdown-check: Use ByteString for file paths 2024-11-27 14:55:02 -05:00
Jelle Raaijmakers
a19bb3d808 LibWeb: Clear grapheme segmenter when invalidating TextNode text
We only set the grapheme segmenter's text once after creating a new
segmenter, so we also need to clear it whenever we invalidate the text.

(cherry picked from commit 25516e351e46104ff445216e7835aaab9f9b9535)
2024-11-27 12:57:15 -05:00
Timothy Flynn
bb8b24eef7 LibWeb: Move initial creation of Unicode segmenters to the Document
The expensive part of creating a segmenter is doing the locale and UCD
data lookups at creation time. Instead of doing this once per text node,
cache the segmenters on the document, and clone them as needed (cloning
is much, much cheaper).

On a profile loading Ladybird's GitHub repo, the following hot methods
changed as follows:

    ChunkIterator ctor: 6.08% -> 0.21%
    Segmenter factory:  5.86% ->    0%
    Segmenter clone:    N/A   -> 0.09%

(cherry picked from commit 5d7175874258f00763adcced230149dd1379e4a6;
mended as usual for Unicode::Segmenter -> Locale::Segmenter, and also
to resolve minor conflicts due to serenity not yet having
LadybirdBrowser/ladybird#1106. Also, due to serenity not using ICU,
this doesn't have a big performance effect over here, but it still
makes future cherry-picks easier)
2024-11-27 12:57:15 -05:00
Nico Weber
833147b7a6 LibUnicode: Fix a spec link in a comment 2024-11-27 12:09:20 -05:00
Timothy Flynn
886f9016ab LibWeb: Iterate over text chunks using a grapheme-aware segmenter
Our current text iterator is not aware of multi-code point graphemes.
Instead of simply incrementing an iterator one code point at a time, use
our Unicode grapheme segmenter to break text into fragments.

(cherry picked from commit f0105b473b9cc3446ec36359b559db9a8e78446d;
amended as usual for Unicode::Segmenter -> Locale::Segmenter, and to
tweak expected/multi-code-point-graphemes.txt for serenity's superior
emoji glyphs)
2024-11-27 11:43:26 -05:00
Nico Weber
b46bb32584 LibLocale: Make Segmenter store segment boundaries
Instead of recomputing boundaries on every iteration, this now
computes boundaries once and then searches that vector.

This is still O(n^2) for now, but already much faster (at the expense
of using O(n) memory): `BenchmarkSegmenter.for_each_boundary` stays
at around 3ms, but `forward` and `backward` go from ~13s to ~60ms
on my system.
2024-11-27 10:42:35 -05:00
Nico Weber
414500c462 Tests: Make TestSegmenter test next_boundary() and previous_boundary() 2024-11-27 10:42:35 -05:00
Nico Weber
7b19c3e9d6 Tests: Extract test_segmentation() function in TestSegmenter 2024-11-27 10:42:35 -05:00
Nico Weber
5d1a926b46 Tests: Add a benchmark for Locale::Segmenter 2024-11-27 10:42:35 -05:00
Nico Weber
7211ba30be Meta: Add more commits and PRs to lb-cherry-picks.py 2024-11-26 23:27:06 -05:00
Tim Ledbetter
aac1e1e289 LibWeb: Use correct integer parsing rules in HTMLOListElement::start()
(cherry picked from commit 9face18ab265376916aa18c0adce113596b99a1e)
2024-11-26 22:37:15 -05:00
Tim Ledbetter
0ea547dc2d LibWeb: Use correct integer parsing rules in HTMLLIElement::value()
(cherry picked from commit a61883ae88eb3fd4b35cc51db77a4c9405480fb5)
2024-11-26 22:37:15 -05:00
Tim Ledbetter
107ea0c79a LibWeb: Use [URL] extended attribute for HTMLVideoElement.poster
(cherry picked from commit 67d05b0104dab928fc5334fe63e46cd62d1e4e22)
2024-11-26 22:37:15 -05:00
Tim Ledbetter
255d0d6973 LibWeb: Update Screen IDL definition to not inherit from EventTarget
(cherry picked from commit 8ad3479e0ecfb55ed382a4932256020e98edb9e6)
2024-11-26 22:37:15 -05:00
Jelle Raaijmakers
d8c7460f32 LibWeb: Fix various local names for custom elements
This fixes the typo in `HTMLFieldSetElement` and adds valid local names
for `<meta>`, `<ol>` and `<optgroup>`.

(cherry picked from commit 06863479bed8d99865b40e10df1c2fbc3a43e090)
2024-11-26 22:37:15 -05:00