Commit graph

4413 commits

Author SHA1 Message Date
Tim Ledbetter
ded19eaab8 Tests: Convert existing text test to crash test 2025-01-17 09:08:15 +01:00
Timothy Flynn
e6b7c8cde2 LibUnicode: Consistently reject out-of-bounds segmenter indices
In the UTF-8 implementation, this prevents out-of-bounds access of the
underlying text data, as the ICU macro would essentially do something
akin to `text[text.length()]`.

The UTF-16 implementation already checks for out-of-bounds, but would
previously return 0. We now return an empty Optional in both impls. This
doesn't affect LibJS (the user of the UTF-16 impl), as it already does
bounds checking before invoking LibUnicode APIs.
2025-01-16 23:22:48 +01:00
Tim Ledbetter
f01ccf5424 LibWeb: Align AudioContext constructor with current spec steps 2025-01-16 13:56:18 +00:00
Tim Ledbetter
3d20587911 LibWeb: Fetch source file when HTMLTrackElement src attribute changes
This commit begins to implement the track processing model. When the
`src` attribute is updated, we now fetch the given source file.
Currently, we always fire an `error` event once fetching is completed,
as we don't support processing the fetched data.
2025-01-15 20:59:18 +01:00
Shannon Booth
51102254b5 LibWeb/HTML: Scroll to the fragment before loading the document
Otherwise nowhere ends up scrolling to the fragment specified by the
fragment in document's URL. This fixes ladybird scrolling to the
correct location in the document when navigating to a link that
has a fragment, e.g:

https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment

As well as use of the :target selector.
2025-01-15 12:43:48 +00:00
Shannon Booth
e74ca82083 LibWeb/XHR: Isomorphic decode accessing XMLHttpRequest response headers
Fixes a crash on:

https://wpt.live/html/browsers/browsing-the-web/navigating-across-documents/refresh/subresource.any.html
2025-01-15 12:35:56 +00:00
Shannon Booth
7b637b1eee LibWeb/HTML: Only use maxlength <input> attribute when applicable 2025-01-15 11:41:39 +01:00
stelar7
439245b14a LibWeb: Import WPT tests for IDBKeyRange 2025-01-14 23:46:09 +01:00
Psychpsyo
8cd2fe3d08 LibWeb: Fix CSS clip-path ignoring scroll position 2025-01-13 20:03:28 -07:00
Aliaksandr Kalenik
98691810b1 LibWeb: Fix insert/delete rule invalidation for adopted style sheets
Invalidation for adopted style sheets was broken because we had an
assumption that "active" style sheet is always attached to
StyleSheetList which is not true for adopted style sheets. This change
addresses that by keeping track of all documents/shadow roots that own
a style sheet and notifying them about invalidation instead of going
through the StyleSheetList.
2025-01-13 23:03:07 +01:00
devgianlu
a59b48cffc LibCrypto+LibWeb: Replace RSA_OAEP-EME implementation
This replaces the old `OAEP` implementation with one backed by OpenSSL.
The changes also include some added modularity to the RSA class by
making the `RSA_EME` and `RSA_EMSE` for encryption/decryption and
signing/verifying respectively.
2025-01-13 17:00:18 +01:00
devgianlu
70bc26e32a LibCrypto+LibTLS: Replace RSA_PKCS1-EMSA implementation
This commit replaces the old implementation of `EMSA_PKCS1_V1_5` with
one backed by OpenSSL. In doing so, the `sign` and `verify` methods of
RSA have been modified to behave like expected and not just be
encryption and decryption.

I was not able to split this commit because the changes to `verify` and
`sign` break pretty much everything.
2025-01-13 17:00:18 +01:00
devgianlu
4b832b67fb LibWeb: Add RSA-OAEP WPT tests
This serve as a regression check for the next commits
2025-01-13 17:00:18 +01:00
devgianlu
0fc02d4d00 LibCrypto: Make PKSystem methods return a ByteBuffer directly
It used to be that the caller would supply a buffer to write the output
to. This created an anti-pattern in multiple places where the caller
would allocate a `ByteBuffer` and then use `.bytes()` to provide it to
the `PKSystem` method. Then the callee would resize the output buffer
and reassign it, but because the resize was on `Bytes` and not on
`ByteBuffer`, the caller using the latter would cause a bug.

Additionally, in pretty much all cases the buffer was pre-allocated
shortly before.
2025-01-13 17:00:18 +01:00
Noah Bright
18b4dc2153 LibWeb: Update add_libweb_test.py to support Screenshot, Ref, and Layout
Changed the usage from `add_libweb_test.py test_name.html` to
`add_libweb_test.py test_name.html test_type` with no default,
and supports automatically generating input/output files in the
right directories for test types Screenshot, Text, Ref, and Layout.

Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-01-13 14:25:26 +00:00
Psychpsyo
bb5d1ac4a3 LibWeb: Fix CSS tag seletor case sensitivity for SVG elements
They can appear in HTML documents but must not be matched
according to the HTML spec.
2025-01-13 12:11:34 +00:00
Psychpsyo
7757df5bb5 LibWeb: Implement CSS 'isolation' property 2025-01-13 11:07:55 +00:00
Tim Ledbetter
619df0bc2c LibWeb: Don't crash when upgrading custom element with a bad constructor
Previously, a crash would occur when attempting to throw an error in
this case because the method used to create the exception tried to get
the current realm from the execution context stack, which is empty. The
realm is now passed explicitly when constructing the error, avoiding
the crash.
2025-01-13 10:55:46 +00:00
Gingeh
9f2ce259ad LibWeb: Check for missing node or invalid query in obtain_theme_color 2025-01-12 19:47:01 +00:00
Shannon Booth
57479c2d4b LibWeb/HTML: Include better information in 'report an exception' event
Instead of always reporting a colno and lineno of zero try and use the
values from the Error object that may be provided, falling back to the
source location of the invocation if not provided. We can definitely
improve the reporting even more, but this is a start!

Also update this function to latest spec while we're in the area.
2025-01-12 18:49:55 +00:00
Shannon Booth
f388d3c88c LibWeb/HTML: Fix crash creating canvas pattern without context
This isn't a full fix, as the paint function does not handle this
either. But instead of getting the bitmap from the image source
immediately, follow the spec a bit more closely by creating the
CanvasPatern object with the ImageSource directly.

Fixes a crash for the 5 included WPT tests.
2025-01-12 18:40:37 +00:00
devgianlu
df05cc8478 LibCrypto: Make PKSystem methods return ErrorOr
Make `encrypt`, `decrypt`, `sign` and `verify` return `ErrorOr` for
better error propagation.
2025-01-12 01:13:19 +01:00
devgianlu
9e08f71fd9 LibCrypto: Make RSA::generate_key_pair return ErrorOr
Not currently needed as it cannot fail, but useful for future commits.
2025-01-12 01:13:19 +01:00
Tim Ledbetter
1e9e2b6564 LibWeb: Clone all attribute properties when cloning a single node
Previously, the namespace of the attributes on the cloned element was
not being set.
2025-01-11 23:10:09 +01:00
Shannon Booth
5bed8f4055 LibURL+LibWeb: Make URL::basic_parse return an Optional<URL>
URL::basic_parse has a subtle bug where the resulting URL is not set
to valid when StateOveride is provided and the URL parser early returns
a valid URL.

This has not surfaced as a problem so far, as the only users of the
state override API provide an already valid URL buffer and also ignore
the result of basic parsing with a state override.

However, this bug surfaces implementing the URL pattern spec, which as
part of URL canonicalization:
 * Provides a dummy URL record
 * Basic URL parses that URL with state override
 * Checks the result of the URL parser to validate the URL

While we could set URL validity on every early return of the URL parser
during state override, it has been a long standing FIXME around the code
to try and remove the awkward validity state of the URL class. So this
commit makes the first stage of this change by migrating the basic
parser API to return Optional, which also happens to make this subtle
issue not a problem any more.
2025-01-11 10:08:29 -05:00
Tim Ledbetter
b6ec055bf9 IDLGenerators: Set Iterator @@toStringTag with correct descriptor 2025-01-11 10:02:48 -05:00
Tim Ledbetter
5b6f2bb23a LibWeb: Set dirty checkedness flag when setting checked IDL attribute
This matches the behavior of other browsers, which always set the dirty
checkedness flag when setting checkedness, except when setting the
`checked` content attribute.
2025-01-11 11:13:32 +01:00
devgianlu
b9ba1b3f72 LibWeb: Add Ed448 support in WebCryptoAPI
Add full support for Ed448 and import relevant tests.
2025-01-11 11:13:06 +01:00
Tim Ledbetter
e03fec2a15 LibWeb: Use DocumentLoadTimingInfo values in PerformanceTiming interface 2025-01-11 11:11:52 +01:00
Tim Ledbetter
8b5e9c2a1d LibWeb: Emit comment token for unterminated bogus comments on EOF 2025-01-11 11:09:47 +01:00
Shannon Booth
627b7dd936 LibWeb/Bindings: Define constructor properties in the correct order 2025-01-11 01:43:31 +00:00
Tim Ledbetter
3261f873c5 LibWeb: Validate parameters for source node start() and stop() methods 2025-01-10 23:35:20 +01:00
Jelle Raaijmakers
70af48c18b LibWeb: Implement the "selectAll" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
03bcfb9b8c LibWeb: Implement the "outdent" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
fbc0d40d2c LibWeb: Implement the "justifyCenter/Full/Left/Right" editing commands 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1c3251e2d5 LibWeb: Implement the "insertUnorderedList" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
26cadf06d2 LibWeb: Implement the "insertText" editing command
Minus the autolinking algorithm.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
199eaf0d3e LibWeb: Implement the "insertOrderedList" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
01ce9cb151 LibWeb: Implement the "insertImage" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
20fb7b1a49 LibWeb: Implement the "insertHTML" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
cb05ab6515 LibWeb: Implement the "insertHorizontalRule" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
c6cde85534 LibWeb: Implement the "indent" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
a12d887eb4 LibWeb: Implement the "formatBlock" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e686328cbd LibWeb: Implement the "unlink" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
043a28baeb LibWeb: Implement the "underline" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
679fbb5eda LibWeb: Implement the "superscript" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
ef8af01e1d LibWeb: Implement the "subscript" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
8c51d6863f LibWeb: Implement the "strikethrough" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
aee8a75c40 LibWeb: Implement the "removeFormat" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
ae12f7036b LibWeb: Implement the "italic" editing command 2025-01-10 23:33:35 +01:00