Commit graph

64392 commits

Author SHA1 Message Date
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
Ali Mohammad Pur
08ec58f347 AK: Add OrderedHashMap::take_first()
This is just a convenience shortcut for *take(begin()->key).
2024-10-24 20:55:08 +02:00
Timothy Flynn
0042bbb68d LibWeb: Dispatch WebDriver mouse events relative to the top-level frame
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, 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
There are many WPT subtests which validate how we behave against frames
that have been removed. They do this by adding an iframe element with a
button whose click action removes the iframe element. When the click is
dispatched, the spec would have us generate a mouse event relative to
that iframe, rather than the top-level frame, thus the click would miss
the target button.

Serendipitously, a spec issue and PR were just opened to generate mouse
events relative to the top-level frame. This patch implements that PR;
it has some editorial issues to be resolved, but is a clear improvement
for these tests.
2024-10-24 18:27:55 +02:00
Timothy Flynn
9bdf2e928c LibWeb: Begin implementing FontFaceSet.prototype.load
This implementation is incomplete in that we do not fully implement the
steps to match the given font against the fonts in the set.

This is used by fonts.google.com to load the fonts used for sample text.
2024-10-24 17:50:19 +02:00
Jonne Ransijn
78ecde9923 LibJS: Add HashMap for finding Bindings by name
`find_binding_and_index` was doing a linear search, and while most
environments are small, websites using JavaScript bundlers can have
functions with very large environments, like youtube.com, which has
environments with over 13K bindings, causing environment lookups to
take a noticeable amount of time, showing up high while profiling.

Adding a HashMap significantly increases performance on such websites.
2024-10-24 17:49:48 +02:00
Timothy Flynn
d2d861ca8a UI/AppKit: Only check the NSEvent isARepeat flag in key down/up events
We call ns_event_to_key_event for the NSFlagsChanged event as well. By
retrieving the isARepeat flag on those events, we are guaranteed to
throw an exception.

See:
https://developer.apple.com/documentation/appkit/nsevent/1528049-arepeat?language=objc

    Raises an NSInternalInconsistencyException if sent to an
    NSFlagsChanged event or other non-key event.
2024-10-24 08:52:56 -04:00
Ali Mohammad Pur
00c45243bd LibRegex: Don't blindly accept inverted charclasses for atomic rewrite 2024-10-24 07:36:51 -04:00
Pavel Shliak
0cc8ba305d LibJS: Fix base64 decoder typo
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
As the comments suggest, _ is supposed to be translated into /
but - is translated twice instead
2024-10-23 19:47:18 -04:00
Timothy Flynn
84ad36de06 LibJS: Update spec numbers for the Iterator Helpers proposal
This proposal has reached stage 4 and was merged into the ECMA-262 spec.
See: https://github.com/tc39/ecma262/commit/961f269
2024-10-23 17:26:33 -04:00
Timothy Flynn
896c2e2f0f LibJS: Close iterator records inside the Iterator{Next,Step} AOs
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/c4c55b6
2024-10-23 17:26:33 -04:00
Timothy Flynn
3aca12d2fa LibJS: Update spec numbers for the Promise.try proposal
This proposal has reached stage 4 and was merged into the ECMA-262 spec.
See: https://github.com/tc39/ecma262/commit/d72630f
2024-10-23 17:26:33 -04:00
Florian Cramer
1775021d71 LibXML: Allow empty pubid when parsing document type 2024-10-23 21:08:56 +02:00
Florian Cramer
89192ecc46 LibXML: Allow empty systemid when parsing document type
This fixes at least one WPT under /domparsing
2024-10-23 21:08:56 +02:00
Andrew Kaster
7372b2af48 LibIPC+Everywhere: Introduce an IPC Transport abstraction
This abstraction will help us to support multiple IPC transport
mechanisms going forward. For now, we only have a TransportSocket that
implements the same behavior we previously had, using Unix Sockets for
IPC.
2024-10-23 12:29:01 -06:00
Andrew Kaster
9a6eccc590 LibWebView+LibCore: Move IPCProcess into WebView::Process
Ladybird's HelperProcess.cpp was the only user of the IPCProcess class.
Moving the helper class from LibCore allows for some more interesting
LibIPC changes in the upcoming commits.
2024-10-23 12:29:01 -06:00
uysalibov
e537adad77 LibWeb: Add screenshot test for canvas-shadow 2024-10-23 11:42:56 -06:00
uysalibov
34f7bf979d LibWeb: Implemented shadows support for CanvasRenderingContext2D 2024-10-23 11:42:56 -06:00
Ben Wiederhake
6d68d6ddb2 LibWeb: Test subtleties in HKDF 'salt' interpretation
This also doubles as HKDF implementation test.
2024-10-23 11:33:58 -06:00
Ben Wiederhake
f670c68ded LibWeb: Implement and test SubtleCrypto interface for HKDF operations
This fixes several hundred if not thousands of WPT tests:
https://wpt.live/WebCryptoAPI/derive_bits_keys/hkdf.https.any.html?1-1000
2024-10-23 11:33:58 -06:00
Ben Wiederhake
6072ae5bae LibWeb: Simplify WebCrypto accesses to keys 2024-10-23 11:33:58 -06:00
Ben Wiederhake
8abd399a53 LibCrypto: Implement and test HKDF 2024-10-23 11:33:58 -06:00
Ben Wiederhake
e1c3e212de LibCrypto: Fix HMAC nullptr deref when key has length 0
While a key of length zero seems like a bad idea in general, the WPT
tests end up calling exactly this, so we need to support it one way or
another.
2024-10-23 11:33:58 -06:00
Andrew Kaster
85541f1e76 LibWeb: Add most of ServiceWorker Update algorithm
This misses the final, most important part of actually creating a
service worker object and sending the script over to it in a WebWorker
process.
2024-10-23 11:33:28 -06:00
Jonne Ransijn
d002254ada Meta: Add build instructions for Void Linux
`git` and `bash` are most likely already installed, `bash` is part of
`base-system`, and `git` is required to pull the repository in the
first place, but they are not included in `base-minimal` or
`base-container`, and they ARE required for a successful build,
so I have added them regardless.

`qt6-tools-devel` and `qt6-wayland-devel` were not required to compile
and link Ladybird on my machine, but I have included them as they are
installed on the other Linux distributions.
2024-10-23 11:33:03 -06:00
Jim Broadbent
7a66316297 LibWeb/Storage: Return undefined for non-existent key/index access
All tests at now pass: http://wpt.live/webstorage/defineProperty.window.html
2024-10-23 11:31:47 -06:00
Gingeh
c10cb8ac8d LibURL: Use UTF-8 for percent encoding URL fragments 2024-10-23 11:30:59 -06:00
Gingeh
8e342e3e23 LibWeb: Use Content-Type header to set document encoding
Co-authored-by: Shannon Booth <shannon@serenityos.org>
2024-10-23 11:30:59 -06:00
Shannon Booth
1096b64936 LibWeb: Put setting object's promise's in WindowOrWorkerGlobalScope
This aligns with an update to the HTML specification which instead
stores these promises on the global object instead of the settings
object.

It also makes progress towards implementing the ShadowRealm proposal
as these promises are not present in the 'synthetic' realm for that
proposal.
2024-10-23 11:29:53 -06:00
Shannon Booth
d1fc76bffd LibJS: Allow host to create ShadowRealm global object
This implements the proposed update to the ShadowRealm proposal for
integrating the ShadowRealm specification into the web platform.
2024-10-23 11:29:53 -06:00
Shannon Booth
0ec8af5b70 LibJS: Initialize ShadowRealm internal slots through setters
This allows us to align our implementation in the same order as the
specification.

No functional change with the current implementation of this AO.

However, this change is required in order to correctly implement a
proposed update of the shadow realm proposal for integration with
the HTML spec host bindings in order to give the ShadowRealm
object the correct 'intrinsic' realm.

This is due to that proposed change adding a step which manipulates the
currently executing Javascript execution context, making the ordering
important.
2024-10-23 11:29:53 -06:00
Daniel La Rocque
db6ec2792a LibWeb: Assert navigationParams' request and response are not null 2024-10-23 11:23:21 -06:00
Daniel La Rocque
219cb04865 LibWeb: Check if navigationParams is NullWithError
When we check whether navigationParams is null, we should check if it is
`NullWithError`, since `NullWithError` is equivalent to `Empty`, but is
used for error messages.
2024-10-23 11:23:21 -06:00
Jelle Raaijmakers
1f9295ca2e LibWeb: Remove unused members from ReplacedBox
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-23 11:05:39 +02:00
Timothy Flynn
b75a4d25b7 WebContent: Further validate cookie attributes set from WebDriver
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
Implement a few missing steps in the Add Cookie endpoint.
2024-10-23 09:05:33 +02:00
Timothy Flynn
8988e7ef8d LibWeb+LibWebView: Move the cookie domain matching algorithm to LibWeb
This will be needed outside of LibWebView.
2024-10-23 09:05:33 +02:00
Timothy Flynn
527218da19 LibWeb: Implement the document.cookie setter/getter according to spec
This ensures we cannot set or get cookies on non-HTTP(S) origins. Since
this would prevent our ability to test cookies during LibWeb tests, this
also adds an internals API to allow cookie access on file:// URLs.
2024-10-23 09:05:33 +02:00
Sam Atkins
86744449e3 Documentation: Flatten the Browser/ directory
Separating out the browser documentation doesn't make much sense now
that we are only a browser. :^)
2024-10-23 09:02:46 +02:00