Commit graph

65266 commits

Author SHA1 Message Date
Jelle Raaijmakers
b895a135d5 LibWeb: Update spec implementation for SubtleCrypto.deriveKey()
Our spec issue got resolved, including a bonus fix!

See: https://github.com/w3c/webcrypto/pull/384
2024-11-15 18:51:15 +01:00
Andrew Kaster
137db0e38e Meta: Add -Wlogical-op to the default compile options 2024-11-15 10:50:45 -07:00
Aliaksandr Kalenik
71eded0471 LibCore: Recognize .xht as XHTML in MIME parser for file names
Fixes a bug when https://wpt.live/css/CSS2/positioning/abspos-001.xht
saved as file fails because we incorrectly recognized its MIME type
as HTML, leading to incorrect self-closing tag handling and thus
incorrect rendering.
2024-11-15 18:50:38 +01:00
Luke Wilde
079c28d5e6 LibWeb: Make MessageEvents from {Window,MessagePort}.postMessage trusted
The MessagePort one in particular is required by Cloudflare Turnstile,
as the method it takes to run JS in a worker is to `eval` the contents
of `MessageEvent.data`. However, it will only do this if
`MessageEvent.isTrusted` is true, `MessageEvent.origin` is the empty
string and `MessageEvent.source` is `null`.

The Window version is a quick fix whilst in the vicinity, as its
MessageEvent should also be trusted.
2024-11-15 18:50:08 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Andreas Kling
ce23efc5f6 LibWeb: Make CSS display serialization match other engines
The spec just says to follow "most backwards-compatible, then shortest"
when serializing these (and it does so in a very hand-wavy fashion).

By omitting some keywords when they are implied, we end up matching
other engines and pass a bunch of WPT tests.
2024-11-15 14:46:09 +01:00
Andreas Kling
70695e4fce LibWeb: Import a bunch of /css/css-display tests from WPT 2024-11-15 14:46:09 +01:00
Tim Ledbetter
02268e9c60 Meta: Use headless-browser by default when running tests with WPT.sh
This change removes the `--headless` option, which is now the default
behavior and adds the `--show-window` option to force tests to run in a
visible browser window.
2024-11-15 07:14:07 -05:00
Andreas Kling
3ecc843cff LibWeb: Handle undefined arguments correctly in the Option constructor
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
The hand-rolled factory function wasn't handling undefined values
entirely correctly.
2024-11-15 12:54:41 +01:00
Andreas Kling
77d30a0cb7 LibWeb: Don't include SVG script element in HTMLOptionElement.text
We had an old FIXME for this from times before SVGScriptElement was
a thing in our codebase.
2024-11-15 12:54:41 +01:00
Andreas Kling
4c2d4cdf50 LibWeb: Implement HTMLOptionElement.label more correctly
This shouldn't just be a simple reflection of the label attribute.
It also needs fallback to the HTMLOptionElement.text property if the
label attribute is absent.
2024-11-15 12:54:41 +01:00
Jelle Raaijmakers
f7993495bd LibWeb: Set key extractability in SubtleCrypto::derive_key()
None of the algorithms actually set the `extractable` internal slot in
their implementations, and looking at `SubtleCrypto::import_key()` it
seems likely that a step is missing here.
2024-11-15 12:32:04 +01:00
Jelle Raaijmakers
f8c853712e LibWeb: Add some missing spec links to Crypto 2024-11-15 12:32:04 +01:00
Jelle Raaijmakers
b290c180e0 LibWeb: Move PBKDF2::import_key() up in the file
Let's try to keep algorithm implementations together. No functional
changes.
2024-11-15 12:32:04 +01:00
justus2510
a6e9f107eb LibWeb: Fix Canvas.toDataURL and Canvas.toBlob signatures
Fix the function signatures of Canvas.toDataURL() and Canvas.toBlob()
and make both functions accept non-numbers as the quality parameter, in
which case it will just use the default quality instead of raising an
exception.
This makes toDataURL.arguments.1.html, toDataURL.arguments.2.html and
toDataURL.jpeg.quality.notnumber.html in
wpt/html/semantics/embedded-content/the-canvas-element pass :^)
2024-11-15 10:46:24 +01:00
Jonne Ransijn
d842d04be4 AK: Remove DeprecatedStringCodePointIterator
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
The functionality in this class is no longer used, we can just use
`Utf8View` instead.
2024-11-14 23:06:42 +01:00
Andreas Kling
dc9179bb1b LibWeb: Keep track of the order in which option elements are selected
This allows us to locate the most-recently-selected when running the
selectedness update algorithm.
2024-11-14 23:06:30 +01:00
Andreas Kling
581597cb34 Tests: Import WPT tests for select, optgroup and option elements 2024-11-14 23:06:30 +01:00
Sam Atkins
c747b1c6b5 LibWeb: Calculate hidden password text using code-point count
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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 means that an `<input type=password>` will show the correct number
of *s in it when non-ASCII characters are entered.

We also don't need to perform text-transform on these as that doesn't
affect the output length, so I've moved it earlier.
2024-11-14 20:23:58 +01:00
Sam Atkins
3a71b8cda3 LibWeb/CSS: Reject invalid :has() contents after absolutizing nesting
After we absolutize the contents of :has(), we check that those child
selectors don't contain anything that :has() rejects.

This is a separate path than the checks inside the parser, which is
unfortunate.

Fixes a WPT ref test. :^)
2024-11-14 19:51:45 +01:00
Sam Atkins
da31c10ce1 LibWeb/CSS: Allow Selector::absolutized() to return null
It's possible for absolutizing a selector to return an invalid selector
(eg, it could cause `:has()` inside `:has()`) so we need to be able to
express that.
2024-11-14 19:51:45 +01:00
Sam Atkins
3a43fa9e35 LibWeb/CSS: Tag forgiving selector lists while parsing 2024-11-14 19:51:45 +01:00
Sam Atkins
7f803c5c3d LibWeb/CSS: Disallow :has() and pseudo-elements in :has() when parsing 2024-11-14 19:51:45 +01:00
Sam Atkins
ad1f93504e LibWeb/CSS: Make :has() take a <relative-selector-list>
The spec changed this at some point.
2024-11-14 19:51:45 +01:00
Luke Wilde
a94282e0e8 LibWeb: Make CSSStyleDeclaration a legacy platform object with indices
CSSStyleDeclaration has an indexed property getter, which returns
properties associated with the object in the order they were specified
in.
2024-11-14 19:50:22 +01:00
Luke Wilde
aacf9b08ed LibWeb: Generate IDL attributes for all supported CSS properties
The CSSOM spec tells us to potentially add up to three different IDL
attributes to CSSStyleDeclaration for every CSS property we support:
- A camelCased attribute, where a dash indicates the next character
  should be uppercase
- A camelCased attribute for every -webkit- prefixed property, with the
  first letter always being lowercase
- A dashed-attribute for every property with a dash in it.

Additionally, every attribute must have the CEReactions and
LegacyNullToEmptyString extended attributes specified on it.

Since we specify every property we support with Properties.json, we can
use that file to generate the IDL file and it's implementation.

We import it from the Build directory with the help of multiple import
base paths. Then, we add it to CSSStyleDeclaration via the mixin
functionality and inheriting the generated class in
CSSStyleDeclaration.
2024-11-14 19:50:22 +01:00
Luke Wilde
d95ae629ee LibIDL: Allow overwriting the generated attribute callback name
This will allow the CSSStyleDeclaration IDL attribute generator to
implement it's own C++ acceptable identifier sanitization and
deduplication.
2024-11-14 19:50:22 +01:00
Luke Wilde
300f212044 LibIDL: Support multiple import base paths for resolving imports
This allows us to specify multiple base paths to look for imported IDL
files in. This will allow us to import IDL files from sources and from
the Build directory (i.e. for generated IDL files).
2024-11-14 19:50:22 +01:00
Luke Wilde
5aacb053a3 LibWeb: Fix OBOE in bounds check of ResolvedCSSStyleDeclaration#item
Without this, it would return "(invalid CSS::PropertyID)" when
requesting item(decl.length).
2024-11-14 19:50:22 +01:00
Aliaksandr Kalenik
1a1fb14e26 LibWeb: Recompute selection state in Document::update_layout()
Fixes a bug when text selection disappears after relayout.
2024-11-14 19:48:43 +01:00
Aliaksandr Kalenik
d7caa426a0 LibWeb: Delete m_selected flag from Paintable
This was redundant when Paintable already has `m_selection_state` that
could be none.
2024-11-14 19:48:43 +01:00
stelar7
5b67f17551 LibWeb: Sset the key_usages on X25519 export in a better way 2024-11-14 19:48:06 +01:00
stelar7
19ee8ddec2 LibWeb: Correctly set the key_usages on HMAC export 2024-11-14 19:48:06 +01:00
stasoid
1c77135948 LibCore: Port EventLoop to Windows 2024-11-14 11:18:38 -07:00
Timothy Flynn
d4f8b598cb LibWeb: Consolidate the attribute change handlers
We currently have 2 virtual methods to inform DOM::Element subclasses
when an attribute has changed, one of which is spec-compliant. This
patch removes the non-compliant variant.
2024-11-14 15:39:02 +01:00
Shannon Booth
c2988a7dd5 LibJS: Don't directly teach the heap about the javascript VM or Realm
Instead, smuggle it in as a `void*` private data and let Javascript
aware code cast out that pointer to a VM&.

In order to make this split, rename JS::Cell to JS::CellImpl. Once we
have a LibGC, this will become GC::Cell. CellImpl then has no specific
knowledge of the VM& and Realm&. That knowledge is instead put into
JS::Cell, which inherits from CellImpl. JS::Cell is responsible for
JavaScript's realm initialization, as well as converting of the void*
private data to what it knows should be the VM&.
2024-11-14 15:38:45 +01:00
Shannon Booth
ae6d105f41 LibJS: Use a Function to indirectly let Heap visit VM's GC roots
This allows the heap to mark cells that it needs to mark as roots
without needing to directly reference the VM.
2024-11-14 15:38:45 +01:00
Shannon Booth
0bf2a8362a LibJS: Make Value inherit from a NanBoxedValue
NanBoxedValue is intended to be a GC-allocatable type which is not
specific to javascript, towards the effort of factoring out the GC
implementation from LibJS.
2024-11-14 15:38:45 +01:00
Shannon Booth
c0bcebeb08 LibJS: Add const versions of Cell::visit 2024-11-14 15:38:45 +01:00
Sam Atkins
1bcc6764ae Tests: Skip flaky text-as-flexitem-size test 2024-11-14 14:35:30 +00:00
Sam Atkins
5a1eb9e220 LibWeb/CSS: Keep invalid parts of <forgiving-selector-list>s around
Attempt 2! Reverts 2a5dbedad4

This time, set up a different combinator when producing a relative
invalid selector rather than a standalone one. This fixes the crash.

Original description below for simplicity because it still applies.

---

Selectors like `:is(.valid, &!?!?!invalid)` need to keep the invalid
part around, even though it will never match, for a couple of reasons:

- Serialization needs to include them
- For nesting, we care if a `&` appeared anywhere in the selector, even
  in an invalid part.

So this patch introduces an `Invalid` simple selector type, which simply
holds its original ComponentValues. We search through these looking for
`&`, and we dump them out directly when asked to serialize.
2024-11-14 13:20:01 +01:00
Jelle Raaijmakers
329cd946ac LibWeb: Implement Web Crypto HMAC algorithm
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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-11-14 11:52:18 +01:00
Jelle Raaijmakers
884a4163a0 LibWeb: Centralize validating a JWK's key_ops field
This gets rid of a couple FIXMEs and allows reusing the logic of
validating this field between different algorithms. While we're here,
expand its logic to match the constraints as outlined in RFC 7517.
2024-11-14 11:52:18 +01:00
Jelle Raaijmakers
f73a434177 LibWeb: Centralize getting the hash algorithm identifier for crypto 2024-11-14 11:52:18 +01:00
Timothy Flynn
4e1dab477a LibWebView+UI: Handle common WebView client initialization in LibWebView
No need to have every UI manually implement these common steps.
2024-11-14 11:47:32 +01:00
Timothy Flynn
44d6601dc5 LibWebView+UI: Handle worker agent requests from within LibWebView
There is no longer any UI-specific facilities needed to launch a worker
agent.
2024-11-14 11:47:32 +01:00
Timothy Flynn
652dde5022 LibWebView+UI: Acquire the paths to helper processes inside LibWebView
We no longer need to acquire these paths from the UI and pass them into
LibWebView - we can figure out these paths internally.
2024-11-14 11:47:32 +01:00
Timothy Flynn
bb7dff7dfe LibWebView+UI: Move ownership of application services to LibWebView
LibWebView now knows how to launch RequestServer and ImageDecoderServer
without help from the UI, so let's move ownership of these services over
to LibWebView for de-duplication.
2024-11-14 11:47:32 +01:00
Lucas CHOLLET
1b38ebcc7f LibWeb/CSS: Resolve percentage values against 1 in CSSColor
This was a silly mistake on my end and percentages values are not
covered by device-independent color space, so I had to add support for
srgb to run a WPT test that made me realize the mistake.

This makes the following test pass:
 - css/css-color/predefined-002.html
2024-11-14 09:26:28 +00:00
Lucas CHOLLET
a3ef24e30a LibWeb/CSS: Add support for the srgb color space in color()
It makes the following WPT tests pass:
 - css/css-color/predefined-001.html
 - css/css-color/xyz-003.html
 - css/css-color/xyz-d50-003.html
 - css/css-color/xyz-d50-004.html
 - css/css-color/xyz-d65-003.html

Also we now render the reference of color-mix-currentcolor-nested-for-
color-property.html properly. Which means that it's now different from
the actual test, that is still rendered incorrectly. In other word, the
false positive for this test is now turned into a true negative.
2024-11-14 09:26:28 +00:00