Commit graph

64578 commits

Author SHA1 Message Date
Ben Wiederhake
eb193251b8 LibWeb: Implement WebCrypto AES-CBC encrypt operation
This lets us pass an additional (roughly) 20 WPT tests:
WebCryptoAPI/encrypt_decrypt/aes_cbc.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
d86dcac4f7 LibWeb: Implement WebCrypto AES-CBC generateKey operation
This is progress towards passing more WPT tests, although none of them
gets green due to this commit.
2024-10-26 17:50:22 +02:00
Ben Wiederhake
9255a1ac2e LibWeb: Implement WebCrypto AES-CBC exportKey operation
This lets us pass an additional (roughly) 40 WPT tests:
WebCryptoAPI/import_export/symmetric_importKey.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
6f88376e24 LibWeb: Implement WebCrypto AES-CBC importKey operation
This alone lets us pass around 40 WPT tests:
WebCryptoAPI/import_export/symmetric_importKey.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
92d4cb7b09 LibCrypto: Fix and test CBC with CMS and ZeroLen padding 2024-10-26 17:50:22 +02:00
Kostya Farber
3e7faae647 Qt: Add box icon to line box debug menu action 2024-10-26 17:41:16 +02:00
Jonne Ransijn
6e86ad65e9 LibGfx: Use FlyString for family name
This value gets converted to FlyString a lot, so let's just make it
a FlyString in the first place!
2024-10-26 17:40:56 +02:00
samu698
7865fbfe6d LibJS: Don't generate useless jumps for if statement
If statements without an else clause generated jumps to the next
instruction, this commit fixes the if statement generation so that it
dosen't produce them anymore.

This is an example of JS code that generates the useless jumps
(a => if(a){}) ();
2024-10-26 17:39:37 +02:00
Andreas Kling
257ebea364 LibJS: Store RegExp flags as a bitmask
This avoids having to do O(n) contains() in the various flag accessors.

Yields a ~20% speed-up on the following microbenchmark:

    const re = /foo/dgimsvy;
    for (let i = 0; i < 1_000_000; ++i)
        re.flags;
2024-10-26 15:42:57 +02:00
sideshowbarker
6b82ab06fd Meta: Make WPT.sh echo the “wpt run” invocation
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
To help people in troubleshooting problems when running the WPT.sh
script, this change makes the script echo to stdout the complete
“wpt run” invocation (including all the flags and path args).
2024-10-26 11:27:33 +02:00
Jelle Raaijmakers
8fd59899fc LibWeb: Paint drop shadow filters 2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
c99fad77e1 LibWeb: Fix filter: drop-shadow argument parsing
We were not discarding enough whitespace to actually get to the radius
and color values.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
2d544a0d8c LibWeb: Remove LibGfx-specific blur radius modification 2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
6c642d168d LibWeb: Apply correct clamping for each individual color filter
We were always clamping the amount, but this is actually defined per
filter. This allows the brightness filter to go beyond 100%, for
example.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
1b9c50b664 LibWeb: Implement CSS filter painting
We can reuse our implementation for `backdrop-filter` and use it as a
painting filter for each stacking context.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
29974de852 LibWeb: Parse and store filter property
This shares its implementation with `backdrop-filter`.
2024-10-26 11:26:42 +02:00
Timothy Flynn
ea9abe26e1 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.
2024-10-26 11:25:42 +02:00
Timothy Flynn
0722a3b1c0 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.
2024-10-26 11:25:42 +02:00
Timothy Flynn
bf0bc62654 WebContent+WebDriver: Asynchronously wait for navigations to complete
Similar to commit c2cf65adac, 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).
2024-10-26 11:25:42 +02:00
Timothy Flynn
8598d4670d LibWeb: Move WebDriver's HeapTimer helper class to its own file
And generalize it a tiny bit to be reusable outside of ExecuteScript.
2024-10-26 11:25:42 +02:00
Timothy Flynn
74ef9dc393 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.
2024-10-26 11:25:42 +02:00
Timothy Flynn
247307a2a2 LibWeb: Allow removing DocumentObserver hooks
Some callers (namely WebDriver) will want to stop receiving updates from
the DocumentObserver.
2024-10-26 11:25:42 +02:00
Timothy Flynn
0bbe836f8c LibWeb: Add a DocumentObserver hook to be notified of readyState changes 2024-10-26 11:25:42 +02:00
Kostya Farber
44b1c4f2b5 LibWeb: Parse the word-break css property
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-26 00:18:02 +02:00
Ben Wiederhake
124bd115a1 LibWeb: Fix crash when importing malformed RSAOAEP key
This fixes a crash in WPT:
WebCryptoAPI/import_export/rsa_importKey.https.any

This allows us to pass 240 tests!
2024-10-26 00:14:42 +02:00
Ben Wiederhake
efad0b5676 LibWeb: Remove dead write in HKDF/PBKDF importKey operation
This corresponds to a recent change in the spec:
https://github.com/w3c/webcrypto/pull/379
2024-10-25 23:50:31 +02:00
Ben Wiederhake
ee3b86c3f8 LibWeb: Remove superfluous step in HKDF deriveBits operation
This corresponds to a recent change in the spec:
https://github.com/w3c/webcrypto/pull/372
Inspired by the following review comment:
https://github.com/LadybirdBrowser/ladybird/pull/1877#discussion_r1807648283
2024-10-25 23:50:31 +02:00
Andrew Kaster
2c3531ab78 LibWeb: Move JS::Promise <-> WebIDL conversion into IDL
This change also removes as much direct use of JS::Promise in LibWeb
as possible. When specs refer to `Promise<T>` they should be assumed
to be referring to the WebIDL Promise type, not the JS::Promise type.

The one exception is the HostPromiseRejectionTracker hook on the JS
VM. This facility and its associated sets and events are intended to
expose the exact opaque object handles that were rejected to author
code. This is not possible with the WebIDL Promise type, so we have
to use JS::Promise or JS::Object to hold onto the promises.

It also exposes which specs need some updates in the area of
promises. WebDriver stands out in this regard. WebAudio could use
some more cross-references to WebIDL as well to clarify things.
2024-10-25 14:04:21 -06:00
Andrew Kaster
52c449293a LibWeb: Update PromiseRejectionEvent's promise field to be object
This change was made in the HTML spec to address a comment from the
Gecko team for the Streams API in
a20ca78975

It also opens the door for some more Promise related refactors.
2024-10-25 14:04:21 -06:00
Jelle Raaijmakers
352a66390f LibWeb: Do not resolve inline block height early if height is definite
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
This condition was included to implement flex containers with auto
height, but it actually can reset the definitive height to 0 for inline
blocks with only replaced elements such as an SVG. Removing the
condition does not break any in-tree test, so let's improve the
situation on the SVG side of things for now.
2024-10-25 15:13:30 +02:00
Andreas Kling
b6e28ff807 AK: Add ASCII fast path in StringBuilder::append(Utf16View)
And let's at least try to pre-allocate an appropriate amount of
buffer space in the builder instead of appending and growing one
code point at a time.
2024-10-25 15:10:12 +02:00
stelar7
d16414b61e LibJS: Extend supported date string formats 2024-10-25 07:24:22 -04:00
Jonne Ransijn
cc0fce3983 LibWeb: Fix infinite loop in Storage::internal_own_property_keys
Since `Storage::item_value` never returns an empty Optional,
and since `PlatformObject::is_supported_property_index` only
returns false when `item_value` returns an empty Optional,
the loop in `PlatformObject::internal_own_property_keys` will
never terminate when executed on a `Storage` instance.

This fix allows youtube.com to load successfully :^)
2024-10-25 12:42:29 +02:00
Andreas Kling
3536ba9a88 LibWeb: Use Document::hidden() instead of comparing state to "hidden"
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
Just noticed this unnecessary string comparison in the rendering task.
2024-10-25 10:21:12 +02:00
Andreas Kling
5c6b879715 LibWeb: Don't allocate a new HeapFunction 60 times per second
We can reuse the same HeapFunction when queueing up a rendering task
on the HTML event loop. No need to create extra work for the garbage
collector like this.
2024-10-25 10:21:12 +02:00
Ali Mohammad Pur
1b127ac082 LibRegex: Apply atomic loop rewrite in one more case
This commit makes LibRegex's atomic loop rewrite opt also accept cases
where the follow block jumps to the end of the forking block
(which is essentially a loop without a proper header in fancy clothes)

This makes patterns like /([^x]*)x/ where the loop is not _immediately_
followed by a block significantly faster.
2024-10-25 09:15:51 +02:00
Jelle Raaijmakers
0de403fede AK+LibJS: Add [[nodiscard]] to operator* in common types
The order of precedence with the `*` operator sometimes makes it a bit
harder to detect whether or not the result is actually used. Let's fail
compilation if anyone tries to discard the result.
2024-10-25 09:15:28 +02:00
Jelle Raaijmakers
5ab07f277c LibWeb: Actually resolve promises in AudioContext
...instead of just dereferencing the function.

Co-authored-by: Andrew Kaster <andrew@ladybird.org>
2024-10-25 09:15:28 +02:00
Ben Wiederhake
352acd7771 Tests: Prevent executable images or html files during lint 2024-10-25 09:00:52 +02:00
Ben Wiederhake
5249faeeb9 Tests: Mark test-files (images and html) as non-executable
These files seem to have been marked as executable by error.

Found by running the command:

    find \( -name WPT -or -name Toolchain -or -name Build \) \
        -prune -or -executable \! -type d -print \
        | grep -Pv '\.(sh|py)$'
2024-10-25 09:00:52 +02:00
Timothy Flynn
9d12ec7cb9 headless-browser: Force-enable font config via code rather than CMake
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
It is easy to forget to set this flag on macOS, where doing so causes
many tests to fail. So let's just set it via code along with other
options to make it a bit more foolproof.
2024-10-24 20:41:30 -04:00
Timothy Flynn
dc74ecac55 LibWeb: Don't re-invent println for sticky element test 2024-10-24 20:41:30 -04:00
Andreas Kling
206479b2b5 LibJS: Cache UTF-16 strings on the VM
We were already caching UTF-8 and byte strings, so let's add a cache
for UTF-16 strings as well. This is particularly profitable whenever we
run regular expressions, since the output of regex execution is a set of
UTF-16 strings.

Note that this is a weak cache like the other JS string caches, meaning
that strings are removed from the cache as they are garbage collected.

This avoids billions of PrimitiveString allocations across a run of WPT,
significantly reducing GC activity.
2024-10-24 19:00:00 -04:00
Timothy Flynn
e89d889219 LibWeb+WebContent: Ensure elements are in view before clicking them
This implements a couple of missing steps in the Element Click endpoint.
2024-10-24 18:59:51 -04:00
Timothy Flynn
0286eb4e3e LibWeb: Return a MarkedVector from Document::elements_from_point
A plain vector is not protected from GC.
2024-10-24 18:59:51 -04:00
Timothy Flynn
9682b150ac WebContent: Do not raise errors from invoking element.scrollIntoView
The spec does not say to do this. We must instead implement methods to
validate the element after attempting to scroll.
2024-10-24 18:59:51 -04:00
Timothy Flynn
9f872d9aab WebContent: Do not use NodeIterator to iterate DOM nodes backwards
A NodeIterator rooted at some element cannot produce an element before
that root. That is, in a DOM tree such as:

    <div id=one><div id=two><div id=three></div></div></div>

If we create a NodeIterator rooted at element `three`, then invoking the
previousNode() method on that iterator is guaranteed to return null.

There was also a bug here where if we ever did enter the while() loop,
we would have looped indefinitely, as we were not updating the current
node.
2024-10-24 18:59:51 -04:00
Timothy Flynn
a9c858fc78 LibWeb: Implement WebDriver element references according to the spec
Our currently ad-hoc method of tracking element references is basically
a process-wide map, rather than grouping elements according to their
browsing context groups. This prevents us from recognizing when an
element reference is invalid due to its browsing context having been
closed.

This implements the WebDriver spec concept of element references grouped
according to their browsing context groups.

This patch is a bit noisy because we now need to plumb the current BC
through to the element reference AOs.
2024-10-24 18:59:51 -04:00
sideshowbarker
ede6924db8 LibWeb: Complete support for all ARIA properties in current spec
This change completes handling for all ARIA properties defined in the
current ARIA spec — by adding handling for the following properties:

- aria-braillelabel
- aria-brailleroledescription
- aria-colindextext
- aria-description
- aria-rowindextext
2024-10-24 22:21:46 +02:00
Ali Mohammad Pur
536e4d1d36 LibRegex: Cache 1 MiB worth of bytecode for each parser
While LibJS does cache regex literals, there's more than one way to
create regex objects, this cache is hit regularly just browsing the web,
though no real measurement has been done on its potential speedups.
2024-10-24 20:55:08 +02:00