Commit Graph

2313 Commits

Author SHA1 Message Date
Tim Ledbetter
f05bc7c0cd LibWeb: Implement dominant-baseline for SVG text
This property determines the default baseline used to align content
within the given box.
2026-02-26 09:23:23 +01:00
Shannon Booth
9e7aa878bc LibWeb: Properly determine if running in SecureContext for Workers
Fixes the included imported test. Note that this required a minor
edit of the WPT import to work with our test harness setup to
try and create a non secure context setup as both file:// and
localhost are considered secure contexts.
2026-02-26 07:22:50 +01:00
Jonathan Gamble
6e03c2168c LibWeb: Reduce navigation test's workload so it doesn't timeout on CI
In high concurrency, sometimes 400+ blob urls and iframe loads take
longer than 30 seconds, especially on sanitizer runs when memory is
tight. Reduce the number of urls and iframes to 84.
2026-02-25 12:33:35 -06:00
Andreas Kling
7b0d818f8e LibWeb: Update layout before accessing paintables in viewport scroll
perform_a_scroll_of_the_viewport() accesses paintable_box() without
ensuring layout is up to date. This can lead to a null dereference
if the paintable tree was torn down (e.g. by adding a dialog to the top
layer via showModal()) between the last layout update and the scroll.

One concrete path: Window::scroll() has an optimization that skips
update_layout when scrolling to (0, 0), but still calls
perform_a_scroll_of_the_viewport if the viewport is at a non-zero
position.

Fix by adding an update_layout call at the top of
perform_a_scroll_of_the_viewport.
2026-02-25 10:18:08 +01:00
Aliaksandr Kalenik
9231b54d49 LibWeb: Pre-populate viewport in SVG subtree relayout
During SVG subtree relayout, position:fixed elements inside
<foreignObject> use the viewport as their containing block. Since the
viewport is outside the SVG subtree, it was not pre-populated in the
LayoutState, causing a VERIFY failure in ensure_used_values_for().

Fix this by unconditionally pre-populating the viewport node from its
paintable in relayout_svg_root().
2026-02-25 09:05:10 +01:00
Luke Wilde
21713377e2 LibWeb: Paint SVG-in-img with a nested display list
This makes SVG-in-img appear sharp no matter the current
(pinch-to-)zoom level.
2026-02-24 19:13:23 +01:00
Tim Ledbetter
84043cd82d LibWeb: Track deleted state on IndexedDb Index and ObjectStore
An `InvalidStateError` is now thrown when an attempt is made to
interact with an index or object store that has been deleted.
2026-02-24 17:37:04 +01:00
Sam Atkins
000f902522 Tests: Import WPT test for document.fonts.ready 2026-02-24 15:44:32 +00:00
Aliaksandr Kalenik
beb7971762 Tests: Add display list test for zero-area clip commands 2026-02-24 16:41:20 +01:00
Aliaksandr Kalenik
5a073fdbf1 Tests: Add display list test for overflow on SVG inner elements
This test captures the current (incorrect) behavior where setting
`overflow: hidden` on an SVG `<g>` element produces a clip in the
display list. Per the CSS Overflow spec, overflow properties only apply
to block containers, flex containers, and grid containers — not SVG
graphics elements.
2026-02-24 12:28:55 +01:00
Sam Atkins
f657a4b71b LibWeb/CSS: Parse @font-face { font-weight } with two values
WPT has coverage for matching but not parsing, so the test is homemade.
2026-02-24 10:05:09 +00:00
Aliaksandr Kalenik
19d3ca90b2 Tests: Add display list test for SVG foreignObject mask after relayout
This test verifies that SVG mask application on foreignObject is
preserved after partial SVG relayout. Currently the mask is not applied
to the foreignObject content after relayout because the stacking context
tree is not rebuilt.
2026-02-24 06:15:07 +01:00
Luke Wilde
8017f8a7ed Tests/LibWeb: Import Fullscreen WPT tests 2026-02-23 18:44:26 +00:00
Jonathan Gamble
34742681de LibWeb: Avoid spin_until in HTMLImageElement::decode_image
Improve performance of overlapping decodes. Reject on src changes
during the operation.
2026-02-23 10:11:04 +01:00
devgianlu
3d7b02333f LibWeb: Import some CredentialsContainer WPT tests 2026-02-22 14:55:30 -05:00
Aliaksandr Kalenik
9f36972e06 LibWeb: Include zero-area boxes when measuring scrollable overflow
The CSS Overflow spec says scrollable overflow should include "the
scrollable overflow areas of all of the above boxes (including
zero-area boxes)", but we were skipping zero-area boxes entirely via
an early return. This meant elements like a position:relative container
that collapses to zero height (because its only child is absolutely
positioned) would never have their children's overflow counted.
2026-02-22 14:23:44 +01:00
Andreas Kling
90cfa2597d Tests: Import WPT tests for clientLeft and clientTop
Import several WPT tests covering client* properties:
- client-props-input.html (border offsets on input/textarea)
- client-props-root.html (root element client properties)
- client-props-zoom.html (client properties with zoom)
- client-props-inline-list-item.html (inline list-item display)
- client-props-root-display-none-crash.html (crash test)
- table-client-props.html (table element client properties)
2026-02-22 13:24:05 +01:00
Andreas Kling
20cc055ec9 LibWeb: Don't require layout node when setting canvas 2D strokeStyle
Use update_style_if_needed_for_element() and resolve colors via
computed properties instead of forcing a full layout update.
2026-02-22 12:43:01 +01:00
Andreas Kling
c7bf2021bc LibWeb: Don't require layout node when setting canvas 2D fillStyle
Use update_style_if_needed_for_element() and resolve colors via
computed properties instead of forcing a full layout update.
2026-02-22 12:43:01 +01:00
Andreas Kling
ca72156497 LibWeb: Don't require layout node when setting canvas 2D shadowColor
Use update_style_if_needed_for_element() and resolve colors via
computed properties instead of forcing a full layout update.
2026-02-22 12:43:01 +01:00
Andreas Kling
cbf8b70d42 LibWeb: Don't require layout node when setting canvas 2D filter
Setting the filter property on a CanvasRenderingContext2D would crash
with a null pointer dereference if the canvas element had no layout
node (e.g. a detached canvas not in the document).

Instead of forcing a full layout update and requiring a layout node,
we now only update style if needed and resolve lengths via the
element's computed properties when available, falling back to
document-level defaults otherwise. This matches the pattern used by
CanvasTextDrawingStyles.
2026-02-22 12:43:01 +01:00
Tim Ledbetter
a4aaed5e83 LibWeb: Propagate error from Notification contructor 2026-02-22 11:37:33 +01:00
Shannon Booth
3a9a8e38f8 LibWeb/Fetch: Prevent file:// URLs from calling fetch() API
Thanks to Oscar Uribe for the report.

Co-Authored-By: Jelle Raaijmakers <jelle@ladybird.org>
2026-02-21 23:00:57 +01:00
Shannon Booth
1be69479a6 LibURL+Elsewhere: Consider file:// origins opaque by default
This aligns our behaviour closer to other browsers, which
_mostly_ consider file scheme URLs as opaque. For test
purposes, allow overriding this behaviour with a commandline
flag.
2026-02-21 23:00:57 +01:00
Shannon Booth
d6d80e5d52 LibWeb: Load cookies test from HTTP server
Allowing us to remove the internals hook.
2026-02-21 23:00:57 +01:00
Shannon Booth
5bbd3c9d31 Tests/LibWeb: Split cookies test into two
To allow for a future change where one test will be loaded over
HTTP (allowing us to remove the internals hook), and another test
which verifies cookies do not work for file URLs.
2026-02-21 23:00:57 +01:00
Shannon Booth
4a79bd98d2 Tests/LibWeb: Support opaque file origins for error stack test
When files have an opaque origin, the "file" scheme is omitted from the
blob URL serialization in the stack trace.

This change normalizes the output in the test so that both tuple
file origins and opaque file origins (which may serialize as
'blob:ladybird/') is accepted, ensuring the test passes in
both scenarios.
2026-02-21 23:00:57 +01:00
Shannon Booth
078e4e4616 Tests/LibWeb: Support opaque file origins in Window-postMessage
The result of this is implementation defined, either result is
fine for the purposes of this test.
2026-02-21 23:00:57 +01:00
Aliaksandr Kalenik
a0768e9bac Tests: Add getElementById mutation and shadow-root routing tests
Add focused coverage for the ElementByIdMap that is easy to regress
while optimizing lookup paths.

The dynamic mutations test verifies duplicate id tree order semantics
remain correct after reordering, id changes, removals, and
reintroduction.

The shadow root routing test verifies lookups stay routed to the correct
scope when an element with an id is removed and moved across shadow
roots and into the document.
2026-02-21 13:56:00 +01:00
Tim Ledbetter
3991555439 LibWeb: Block opaque origins in CSP frame-ancestors check
This matches the behavior of other engines.
2026-02-21 12:30:48 +01:00
Andreas Kling
86838c48f4 LibWeb: Add test for dynamic editability flag propagation
Stress-test the isContentEditable property across various scenarios:
dynamic contenteditable changes, node moves between editable/noneditable
subtrees, insertion/removal, design mode toggle, deep nesting, nested
contenteditable overrides, and plaintext-only mode.
2026-02-21 03:51:28 +01:00
Timothy Flynn
a112eb4881 LibWeb: Ensure empty contenteditable boxes contain the hit test position
There are actually a couple of bugs here:

1. As of commit ebda8fcf11, editing hosts
   are now excluded from Node::is_editable. Since this special hit test
   handling is specifically for contenteditable nodes, we would not
   enter this branch for these nodes.

2. We were not checking if the contenteditable node actually contained
   the hit testing position. So if a page had multiple empty editable
   nodes, we would just return whichever was hit test first.

These bugs were exposed by 7c9b3c08fa.
This commit resulted in the text cursor hit test node being set as the
document focus node. If we returned the wrong result, we would not set
the correct node.

This was seen on discord, where clicking the message box would result in
the search box being focused.
2026-02-21 01:02:06 +00:00
Callum Law
e6669482e6 LibWeb: Parse font-variant-alternates functions 2026-02-20 22:01:44 +00:00
Callum Law
04fd7e00e9 LibWeb: Disallow disjointed numeric component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e.
`ordinal slashed-zero small-caps` is valid but
`ordinal small-caps slashed-zero` is not.

We also reuse the logic for parsing from the longhand
`font-variant-numeric` property for simplicity.
2026-02-20 22:01:44 +00:00
Callum Law
d97098ec80 LibWeb: Disallow disjointed ligatures component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e.
`common-ligatures no-contextual small-caps` is valid but
`common-ligatures small-caps no-contextual` is not.

We also reuse the logic for parsing from the longhand
`font-variant-ligatures` property for simplicity.
2026-02-20 22:01:44 +00:00
Callum Law
75dd7b767f LibWeb: Disallow disjointed east asian component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e. `jis78 full-width small-caps` is
valid but `jis78 small-caps full-width` is not.

We also reuse the logic for parsing from the longhand
`font-variant-east-asian` property for simplicity.
2026-02-20 22:01:44 +00:00
Timothy Flynn
932be463c9 Tests/LibWeb: Use correct format for byte range request
Our HTTP test server supports a limited amount of byte range request
formats. The format we were using was incorrect, causing the server to
fail an assertion. We now ensure the response body is piped as expected
to catch issues like this in the future.
2026-02-20 11:41:28 -05:00
Tim Ledbetter
fd24ca898c LibWeb: Skip hit-testing for elements with non-invertible transforms 2026-02-19 14:33:31 +00:00
Luke Wilde
fc13f15193 LibWeb/CSP: Apply strict-dynamic to inline scripts
This implements https://github.com/w3c/webappsec-csp/pull/787 that
fixed the linked spec issue.
2026-02-19 14:58:09 +01:00
Luke Wilde
84db5d8c1c Meta+test-web: Support per-test .headers files
If a test requires custom response headers, we now serve it via the
http-test-server, which will read the headers file and add them to the
response.
2026-02-19 14:58:09 +01:00
Aliaksandr Kalenik
65704e57fb LibWeb: Fix abspos replaced element constraint equations
The constraint equations for absolutely positioned replaced elements
only subtracted content width/height from the containing block size,
omitting padding and border.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/7820
2026-02-19 12:56:40 +01:00
Callum Law
6705bd187c LibWeb: Account for generic font families in FontFaceSet::load()
Fixes a regression in d998a0a which was crashing the imported test
2026-02-19 12:00:52 +01:00
Jonathan Gamble
d065f6bf00 LibWeb: Perform a microtask checkpoint - VERIFY after reentrancy return
The HTML event loop spec explicitly provides guidance for reentrancy in
the "perform a microtask checkpoint" algorithm, so we cannot VERIFY
for empty execution context before this early exit (as much as we'd
like to).

https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint

See the microtask-checkpoint-reentrancy-via-responsexml-script test for
an example of how this can happen from user scripts.
2026-02-19 08:12:31 +01:00
Aliaksandr Kalenik
35cf4ad79f Tests/LibWeb: Add test for grid min-content height with overflow:hidden
This test verifies that a grid container with height: min-content
correctly sizes its rows when grid items have overflow: hidden.
2026-02-19 03:07:15 +01:00
Aliaksandr Kalenik
94d7c76226 LibWeb: Add test for z-index change causing double paint in display list
When z-index changes from 0 to a positive value on a positioned element,
the stacking context tree is not rebuilt, causing the element to be
painted twice. This test captures the current (incorrect) behavior.
2026-02-17 20:44:46 +01:00
Timothy Flynn
7c9b3c08fa LibWeb: Allow selecting text in dialog and label elements
We were previously not allowing the user to select text when the clicked
position represented a click-focusable area. This included text within
dialogs (as the dialog element is click-focusable) and labels (as the
associated input element would be considered click-focusable).

We now no longer consider associated input elements when clicking on a
label. This is handled separately already by the label's activation
behavior steps, so there is no loss of functionality here. In those
steps, though, we now no longer propagate the click event to the input
element if a selection was made during the click. This matches the
behavior of Firefox and Chrome.

With label elements no longer considered here, we can then enter the
character selection mode when click-focusable areas are clicked.
2026-02-17 18:36:54 +01:00
Aliaksandr Kalenik
b3231ea2a0 LibWeb: Make foreignObject establish a containing block for abspos
Absolutely positioned elements inside SVG foreignObject were being
positioned relative to an ancestor containing block outside the SVG,
instead of relative to the foreignObject itself. Per a W3C resolution
and the behavior of other browsers, foreignObject should establish a
containing block for absolutely and fixed positioned elements.

With this fix, the `has_abspos_with_external_containing_block` check
in `set_needs_layout_update()` and the abspos preservation loop in
`relayout_svg_root()` become dead code — remove both and simplify the
ancestor loops. Rename related tests to reflect the new behavior.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/3241
2026-02-17 15:59:59 +01:00
Callum Law
f36d0407ec Tests: Import some @font-feature-values tests 2026-02-17 12:25:27 +00:00
Jelle Raaijmakers
d5173fe6ca LibWeb: Inflate range rect by font ascenders/descenders
Chrome and Firefox inflate this rect to accommodate for the font's
ascenders and descenders, while the absolute rect for the fragment
remains unaffected. This fixes ascenders/descenders in text being
clipped when selecting text.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
8654e2caf4 LibWeb: Apply letter-spacing for selection rects and grapheme bounds
Fixes the selection rect on the title text of https://modern-css.com/
being misaligned with the actual characters.
2026-02-17 10:51:48 +01:00