Commit graph

64304 commits

Author SHA1 Message Date
Aliaksandr Kalenik
ff456de493 LibWeb: Fix "input" events being dispatched twice when cancelled
(cherry picked from commit 648fac7215e1841e3714d4c72c7aee75152da522)
2024-11-29 20:25:25 -05:00
Ninad Sachania
cb99ab912b Utilities/cut: Show error instead of crashing for invalid UTF-8 lines 2024-11-29 16:35:10 -05:00
Andreas Kling
073b3b992d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.

(cherry picked from commit dd419b5a8df3b9a32478c4a8f0ea9f70334214cd;
amended to update the rest of the system. No conflicts though!)
2024-11-29 16:03:30 -05:00
Gingeh
fa5b2e8661 LibWeb: Compute mimetype when loading a document
computed type != supplied type

(cherry picked from commit 47992f7b39a69cbb927d281cdfd3e818af068bde)
2024-11-29 15:05:55 -05:00
implicitfield
d9eaaee6e0 CI: Check filesystem consistency after running tests 2024-11-29 10:59:24 -05:00
implicitfield
caefb208f0 Meta: Stop requesting 128-byte inodes when creating the root filesystem
We now have full support for large inodes, so we don't need to rely on
the deprecated 128-byte inodes anymore. Note that genext2fs doesn't
support large inodes, so we have to account for that when using that
utility.
2024-11-29 10:59:24 -05:00
implicitfield
0e368bb71a Kernel/Ext2FS: Add full support for large inodes
128-byte inodes are more-or-less deprecated since they store timestamps
as unsigned 32-bit integer offsets from the UNIX epoch. Large inodes, on
the other hand, contain records that may specify a different epoch, and
are thus less susceptible to overflows. These very same records also
have the capability to store timestamps with nanosecond precision, which
this commit adds full support for as well.
2024-11-29 10:59:24 -05:00
implicitfield
2a205768b6 Kernel/Ext2FS: Backport a missing large inode member 2024-11-29 10:59:24 -05:00
implicitfield
e7baffaba0 Ext2FS: Serialize timestamps as signed offsets
The header would have you believe these are unsigned, but they should
really be treated as signed.
2024-11-29 10:59:24 -05:00
Andreas Kling
a8e73f3d9f LibWeb: Remove unnecessary use of TRY_OR_THROW_OOM in XMLHttpRequest
(cherry picked from commit 279d229f71b52e1fd91100a74aa314c90db968da)
2024-11-28 22:42:14 -05:00
Andreas Kling
3b60d2af5b LibWeb: Make XMLHttpRequests functions related to MimeType infallible
(cherry picked from commit fa1c5a3e85e5d479b3ce4975b06b271a67df0be5)
2024-11-28 22:42:14 -05:00
Andreas Kling
e85f364f52 LibWeb: Make MimeSniff::Resource::sniff() infallible
Everyone was already using this API as if it were infallible anyway.

(cherry picked from commit 600cb5ccbaba019954f17c7d317ba6fe54a24117;
amended to fix another conflict in StyleComputer.cpp due to serenity
still not having the third commit of LadybirdBrowser/ladybird#1278)
2024-11-28 22:42:14 -05:00
Andreas Kling
cf0516b616 LibWeb: Make MimeSniff::MimeType::parse() infallible
It already returns an empty Optional for failures, so there's no need to
wrap it in an ErrorOr as well.

(cherry picked from commit 5c20bc2afc23b04ccd8037d414592e4ee841a053;
amended to fix conflict in StyleComputer.cpp due to serenity not having
the third commit of LadybirdBrowser/ladybird#1278)
2024-11-28 22:42:14 -05:00
Andreas Kling
d8c9ff6c09 LibWeb: Make more MimeSniff::MimeType APIs infallible
(cherry picked from commit 88e7688940ceae92263b410dfb1722311ae27aee)
2024-11-28 22:42:14 -05:00
Andreas Kling
d4abeba027 LibWeb: Make MimeSniff::MimeType::create() infallible
(cherry picked from commit 9a8db40a239e3641bba138d6ec6c564c0cc0e2c5)
2024-11-28 22:42:14 -05:00
Nico Weber
1948dbaaf1 Meta: Add UIEvents/InputTypes.cpp to the GN build 2024-11-28 21:31:42 -05:00
Timothy Flynn
1c4996ff34 LibWeb: Move some classes from the DOM namespace to the HTML namespace
The following classes are in the HTML spec and thus belong in the HTML
namespace:

* BeforeUnloadEvent
* HTMLFormControlsCollection
* RadioNodeList

(cherry picked from commit 13b7355ec10c21be90df997c66022e246c57656d)
2024-11-28 21:31:42 -05:00
Aliaksandr Kalenik
e0cc97d2a9 LibWeb: Stub InputEvent.getTargetRanges()
We need this, because https://www.slatejs.org/ that is used by Discord
checks this function to decide whether a browser has "beforeinput" event
support.

(cherry picked from commit 3e8b2454fbcb80891b902ef725dd9549f8880233)
2024-11-28 21:31:42 -05:00
Aliaksandr Kalenik
647bfd63a5 LibWeb: Implement dispatching of "beforeinput" event
(cherry picked from commit 63f502ab0acb8da9fd0db16924df938758110447)
2024-11-28 21:31:42 -05:00
Aliaksandr Kalenik
f613fb9921 LibWeb: Implement dispatching of "input" event
(cherry picked from commit 0de61b0f65ee472d3cf4853b108eb1f9501e6275)
2024-11-28 21:31:42 -05:00
Aliaksandr Kalenik
a1d17acb7c LibWeb: Put cursor in last text node when contenteditable is focused
With this change we match behavior of other engines a bit more closer.

(cherry picked from commit d88e6bee5d14d05cd34bfd13926c6399326ac042)
2024-11-28 21:31:42 -05:00
Andreas Kling
3fe7d96fa7 LibWeb: Support Document.onvisibilitychange
We don't have a way to trigger this from a test, but the fix is so
simple that we might as well get it in. :^)

(cherry picked from commit 274411db9756a9dffe44e21b4da09c7808e9f465)
2024-11-28 21:31:42 -05:00
Andreas Kling
a5e6fd3b5f LibWeb: Support Document.onreadystatechange
This is just a standard IDL event attribute handler.

Fixes at least one WPT test:
https://wpt.live/html/dom/documents/resource-metadata-management/document-readyState.html

(cherry picked from commit 26be8f865ab6bba8e1b2f9f071c0949bcfaca512)
2024-11-28 21:31:42 -05:00
Timothy Flynn
849a3a531f LibWeb: Wait for the iframe load before completing the beforeunload test
This test caused some flakiness due to the about:blank load it triggers.
It causes headless-browser to receive a load event for about:blank. If
we have moved onto the next test before that event arrived, that test
would ultimately time out, as its own load will have been dropped while
the about:blank load is still ongoing.

This patch makes us wait for that iframe load event before completing
the test.

We may want to consider never sending subframe load events to the UI
process as well. We really only care about top-level page loads in the
receivers of that event.

(cherry picked from commit be9071834eb0c836ccd821adaa0134820e3f6297)
2024-11-28 21:31:42 -05:00
Andreas Kling
04474ef84a LibWeb: Bail from various navigable operations when no active window
If we end up in a situation where the navigable no longer has an active
window, we can't perform navigation or many other navigable operations.

These are all ad-hoc, since the navigables spec is basically all written
as if there's always an active window. Unfortunately, the active window
comes from the active document's browsing context, which is a nullable
concept even in the spec, so we do need to deal with null here.

This removes all the locally reproducible crashes when running WPT over
the legacy Japanese encoding directory on my computer.

Yes, this is a bit of a monkey patch, but it should be harmless since
we're (as I understand it) dealing with navigables that are still
hanging around with related tasks queued on them. Once all these tasks
have been completed, the navigables will go away anyway.

(cherry picked from commit aae191aa33c88edba97f872707a5d0f9705cb0aa)
2024-11-28 21:31:42 -05:00
Ninad Sachania
2f3ad5ca28 LibCore: Make get_salt() fallible so we get an error instead of crashing 2024-11-28 20:08:33 -05:00
Nico Weber
61ebfdab56 Meta: Remove Ladybird dep on LibGUI in GN build
Ladybird's cmake dependency on LibGUI was removed in #21782, and
LibWeb's in #24526. This updates the GN build to match.
2024-11-28 20:07:48 -05:00
Nico Weber
50b7fff178 Meta: Add HTML/NavigationObserver.cpp, WebDriver/HeapTimer.cpp to GN 2024-11-28 18:58:55 -05:00
Timothy Flynn
dda405e652 UI/Qt: Execute dialogs opened from the page asynchronously
Invoking exec() entirely blocks the UI application's main thread. Qt
explicitly recommends against this. In practice, it seems prevents some
IPC messages from being handled by the UI until the dialog is closed by
the user.

Instead, use open() (which is non-blocking) and set up a signal handler
to deal with the result.

(cherry picked from commit ea9abe26e1c40c0d2e96007bf7d69afb49a7052a)
2024-11-28 18:58:55 -05:00
Timothy Flynn
5fe499b493 LibWeb+WebContent+WebDriver: Asynchronously wait for dialog dismissal
There was a timing issue here where WebDriver would dismiss a dialog,
and then invoke another endpoint before the dialog was actually closed.
This is because the dismissal first has to hop over to the UI process to
close the graphical dialog, which then asynchronously informs WebContent
of the result. It's not until WebContent receives that result that the
dialog is considered closed, thus those subsequent endpoints would abort
due a dialog being "open".

We now wait for dialogs to be fully closed before returning from the
dismissal endpoints.

(cherry picked from commit 0722a3b1c091adbafc056686ebedbf5c2db84207)
2024-11-28 18:58:55 -05:00
Timothy Flynn
ace8231970 WebContent+WebDriver: Asynchronously wait for navigations to complete
Similar to commit c2cf65adac78912883996153fb608dafe389b6e0, we should
avoid spinning the event loop from the WebContent-side of the WebDriver
connection. This can result in deadlocks if another component in LibWeb
also spins the event loop.

The AO to await navigations has two event loop spinners - waiting for
the navigation to complete and for the document to reach the target
readiness state. We now use NavigationObserver and DocumentObserver to
be notified when these conditions are met. And we use the same async IPC
mechanism as script execution to notify the WebDriver process when all
conditions are met (or timed out).

(cherry picked from commit bf0bc62654803565a6f39ade63d9172cc48c085a)
2024-11-28 18:58:55 -05:00
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