Commit graph

4120 commits

Author SHA1 Message Date
Jelle Raaijmakers
4f76cec096 LibWeb: Implement document.execCommand("insertParagraph") 2024-12-04 06:51:59 +01:00
Jonne Ransijn
d7596a0a61 AK: Don't implicitly convert Optional<T&> to Optional<T>
C++ will jovially select the implicit conversion operator, even if it's
complete bogus, such as for unknown-size types or non-destructible
types. Therefore, all such conversions (which incur a copy) must
(unfortunately) be explicit so that non-copyable types continue to work.

NOTE: We make an exception for trivially copyable types, since they
are, well, trivially copyable.

Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2024-12-04 01:58:22 +01:00
Jonne Ransijn
55383998b1 AK: Use Noncopyable.h in Optional<T&>
This makes them trivially copyable/movable, silencing

> "parameter is copied for each invocation"

warnings on `Optional<T&>`, which are unnecessairy,
since `Optional<T&>` is just a trivially copyable pointer.

This creates a slight change in behaviour when moving out of an
`Optional<T&>`, since the moved-from optional no longer gets cleared.

Moved-from values should be considered to be in an undefined state,
and if clearing a moved-from `Optional<T&>` is desired, you should be
using `Optional<T&>::release_value()` instead.
2024-12-04 01:58:22 +01:00
Aliaksandr Kalenik
bfdf52701f LibWeb: Treat min{max}-height as none if available is intrinsic [GFC]
Fixes infinite recursion in following cases:
- max-height: fit-content
- max-height: min-content
- max-height: max-content
2024-12-03 23:10:08 +01:00
Konstantin Konstantin
9dad8f55a4 LibWeb: Implement transfer for Resizable/ArrayBuffer
Implement transfer logic for ArrayBuffer and ResizableArrayBuffer.

Change TransferDataHolder data type to Vector<u32> to reuse existing
serialization infrastructure.

Fix 5 WPT tests in `window-postmessage.window.html` that relates to
transport.
Fix `LibWeb/Text/input/Worker/Worker-postMessage-transfer.html`.
The latter is currently ignored due to flakiness, no rebaseline is
needed.

During serialization with transfer, initialize memory with known index
and initialize Serializer at position that dependent on the memory.
This is mandatory to make ArrayBuffer transport to work. It also happens
to fix 4 WPT tests, that are related to curcular references during
serialization.
2024-12-03 21:32:01 +00:00
Tim Ledbetter
163b8a69e3 LibWeb: Assert that nodes share shadow-including root in BP calculation
Previously, it was assumed that nodes must share the same root, prior
to the calculation of their relative boundary point positions. This is
no longer the case, since `Selection.setBaseAndExtent()` now accepts
anchor and focus nodes that may be in different shadow trees.
2024-12-03 15:31:41 +01:00
Andreas Kling
a7b3360fb6 LibWeb: Make HTMLIFrameElement.sandbox.supports() not throw
We have to list the set of allowed values for the DOMTokenList to not
throw when asking if one is supported.

This fixes an issue where YouTube embeds would hang indefinitely trying
to report an endless series of exceptions, seen on https://null.com/
2024-12-03 15:30:18 +01:00
Andreas Kling
b1796ebd2c Tests: Import a WPT test that uses HTMLIFrameElement.sandbox.supports() 2024-12-03 15:30:18 +01:00
devgianlu
dace140b0d LibCrypto+LibWeb: Implement ECDSA.sign
Gained ~20 tests, failing only on P-521.
2024-12-03 13:20:51 +01:00
devgianlu
0c60f7c995 LibWeb: Migrate ECDSA.generateKey and ECDSA.verify away from ByteBuffer
Use instances of `ECPublicKey` and `ECPrivateKey` instead of
`ByteBuffer` for ECDSA. Fixes another ~200 tests.
2024-12-03 13:20:51 +01:00
devgianlu
f0fbd50c66 LibWeb: Implement ECDSA.importKey and ECDSA.exportKey
Very similar implementation to ECDH. Fixes ~700 tests!
2024-12-03 13:20:51 +01:00
Andreas Kling
940cdc7cf9 Tests: Rebaseline tests after changes to imported WPT harness 2024-12-03 00:26:03 +01:00
Andreas Kling
0ed5278772 Tests: Rebaseline a recently-added editing test 2024-12-03 00:19:15 +01:00
Shannon Booth
6ac018bcb6 LibWeb: Fix crash accessing 'empty' PromiseRejectionEvent reason
The 'reason' was getting initialized to 'empty' state when not
provided through the constructor, which results in a crash when
accessed through throw_dom_exception_if_needed in the generated
IDL getter.
2024-12-03 00:18:11 +01:00
Jelle Raaijmakers
217567981a LibWeb: Implement "plaintext-only" state for contenteditable 2024-12-03 00:18:03 +01:00
Tim Ledbetter
cc1ea02949 LibWeb: Disable test output for imported WPT tests
This reduces the runtime of all imported WPT tests from 8.2 seconds to
4.5 seconds on my local machine.
2024-12-02 22:41:51 +00:00
Tim Ledbetter
61ae388140 Tests: Create imported WPT test output from completion callback data
This allows us to disable test output, which performs expensive assert
tracking. This was making our imported tests run significantly slower
than tests run via `WPT.sh`.

Formatting the output ourselves also allows us to remove unnecessary
information from the test output.

This commit also rebaselines all existing imported WPT tests to follow
the new format.
2024-12-02 22:41:51 +00:00
Gingeh
0afd7f166a LibWeb: Improve grid-template-area parsing and serialization 2024-12-02 16:19:47 +00:00
Tim Ledbetter
44cf457fd2 LibWeb: Limit HTMLTableColElement span to allowed values
This change ensures that `span` is clamped to the maximum value of 1000
if the given value is larger than 2147483647.
2024-12-02 10:25:27 +01:00
Tim Ledbetter
9fc2a63131 LibWeb: Limit HTMLTableCellElement rowSpan to allowed values
This change ensures that `rowSpan` is clamped to the maximum value of
65534 if the given value is larger than 2147483647.
2024-12-02 10:25:27 +01:00
Tim Ledbetter
4630b1a44b LibWeb: Limit HTMLTableCellElement colSpan to allowed values
This change ensures that `colSpan` is clamped to the maximum value of
1000 if the given value is larger than 2147483647.
2024-12-02 10:25:27 +01:00
Tim Ledbetter
7097152ebc LibWeb: Restrict HTMLTextAreaElement::min_length to the range of i32 2024-12-02 10:25:27 +01:00
Tim Ledbetter
ac7fad52f6 LibWeb: Restrict HTMLTextAreaElement::max_length to the range of i32 2024-12-02 10:25:27 +01:00
Tim Ledbetter
bc484258c2 LibWeb: Restrict HTMLInputElement::min_length to the range of i32 2024-12-02 10:25:27 +01:00
Tim Ledbetter
40d6b9d44e LibWeb: Restrict HTMLInputElement::max_length to the range of i32 2024-12-02 10:25:27 +01:00
Konstantin Konstantin
1915574165 LibWeb: Fix NavigationType enum to string conversion
Convert NavigationType to lowercase strings, as described in the spec.

Import related WPT test.
2024-12-02 06:47:49 +00:00
Pavel Shliak
4d5acc7a00 LibWeb: Remove IDBRequest.idl FIXME 2024-12-01 22:04:05 +01:00
Pavel Shliak
e02fd4ca8c Tests: Reimport Event-constants WPT
I reimported and rebaselined it using the latest version
of our WPT importer. Now it passes.
2024-12-01 22:01:48 +01:00
Tim Ledbetter
a486c86eee LibWeb: Limit HTMLCanvasElement width and height to allowed values
Setting the `width` or `height` properties of `HTMLCanvasElement` to a
value greater than 2147483647 will now cause the property to be set to
its default value.
2024-12-01 15:12:04 +00:00
Tim Ledbetter
b05bc71002 LibWeb: Limit HTMLImageElement width and height to allowed values
Setting the `width` or `height` properties of `HTMLImageElement` to a
value greater than 2147483647 will now cause the property to be set to
0.
2024-12-01 15:12:04 +00:00
Shannon Booth
30c8510725 LibWeb: Ensure requests modules is not empty before indexing into it
Regression from 5af613aa65

Fixes: #2676
2024-12-01 15:49:16 +01:00
Timothy Flynn
3947c6d4ed LibWeb: Disable Text/input/wpt-import/css/cssom/serialize-values.html
It's currently too slow for sanitized CI runs.
2024-11-30 12:10:12 -05:00
Netanel Haber
d743fcb376 LibWeb: Take namespace into account when matching attribute 2024-11-30 16:47:14 +00:00
Jelle Raaijmakers
033cd9cab3 LibWeb: Add test for document.execCommand("delete")
Anchor the minimum functionality for this. WPT has an extensive suite
to test editing functionalities, but they all take a long time to
execute - so let's have a simple regression test in-tree for now.
2024-11-30 17:35:45 +01:00
Sam Atkins
900c131178 LibURL: Make URL::serialized_host() infallible
This can no longer fail, so update the return type to match.

This makes a few more methods now unable to return errors, but one thing
at a time. 😅
2024-11-30 12:07:39 +01:00
Sam Atkins
90e763de4c LibURL: Replace Host's Empty state with making Url's Host optional
A couple of reasons:
- Origin's Host (when in the tuple state) can't be null
- There's an "empty host" concept in the spec which is NOT the same as a
  null Host, and that was confusing me.
2024-11-30 12:07:39 +01:00
Shannon Booth
91007eb476 LibWeb: Ensure principal realm returned for nested Shadow Realms
Recently reported against the shadow realm proposal after running into
issues with WPT tests.

In a nested shadow realm, the associated realm is a shadow realm, not
the principal realm. One such issue this fixes is a crash when a nested
shadow realm performs an operation which requires the principal settings
object.
2024-11-30 11:55:11 +01:00
Shannon Booth
218ac86b67 LibWeb: Use relevant principal settings for HighResolutionTime
Fixes a crash when setting the timestamps when creating a DOM event
within a ShadowRealm.
2024-11-30 11:55:11 +01:00
Shannon Booth
6a668f27c7 LibWeb: Push promise rejection handling onto UniversalGlobalScopeMixin
This is needed for shadow realms which don't have a window or worker
global object. Fixes a crash for the attached test.
2024-11-30 11:55:11 +01:00
devgianlu
399b3d2430 LibCrypto+LibWeb: Parse EC public key in parse_subject_public_key_info
Replicate what we are doing with RSA and parse both the private and
public key when parsing the ASN1.

The only thing that changed in the tests is the error message.
2024-11-30 11:17:44 +01:00
devgianlu
1f7586ce14 LibCrypto: Use ASN1 macros for RSA key parsing
Improve error handling in `RSA::parse_rsa_key` by using ASN1 macros and
generalizing the parsing to both private and public keys.
2024-11-30 11:17:44 +01:00
devgianlu
ee50a8c0f7 LibCrypto: Do not parse PKCS#8 in RSA::parse_rsa_key
The decoding inside `RSA::parse_rsa_key` is quite complex because it
tries to understand if it's decoding PKCS#8 or PKCS#1. Simplify the code
 by moving the burden to the PEM decoder.
2024-11-30 11:17:44 +01:00
devgianlu
51f69be51f LibCrypto: Move ASN1 constants to Crypto::ASN1
Makes more sense to have them in `Crypto::ASN1` rather than in
`Crypto::Certificate`.
2024-11-30 11:17:44 +01:00
devgianlu
ab2960e49f LibCrypto+LibWeb: Reorganize OID ASN1 constants
I have divided ANS1 constants by length so that they don't have
trailing zeros that need to be removed.

Also moved OIDs lists to the only place they are used for clarity.

Fixed a couple of WPT tests by adding SECP521r1 to the list of known
curves.
2024-11-30 11:17:44 +01:00
Tim Ledbetter
b39fdcfec2 LibWeb: Implement the HTMLInputElement.height attribute
This allows the height of an image button input to be set and queried.
2024-11-30 11:01:33 +01:00
Tim Ledbetter
45a2823e08 LibWeb: Implement the HTMLInputElement.width attribute
This allows the width of an image button input to be set and queried.
2024-11-30 11:01:33 +01:00
Sam Atkins
8e3adbe082 LibWeb: Serialize text-decoration closer to spec
This gets us 32 WPT subtest passes that I'm aware of. :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
671d3e8a48 LibWeb/CSS: Sort text-decoration-line values in spec order
This wins us 49 WPT subtest passes! :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
fa1e102f3c Tests: Import text-decoration WPT tests 2024-11-30 11:01:12 +01:00
Sam Atkins
9453c25925 LibWeb/CSS: Don't repeat CSS-wide keywords when serializing shorthands
Regardless of what the shorthand property is, if all its longhands are
the same CSS-wide keyword such as "initial" or "inherit", then it's the
same as the shorthand being that value.

This gets us 2 WPT subtest passes.
2024-11-30 11:01:12 +01:00