Commit Graph

289 Commits

Author SHA1 Message Date
Zaggy1024
bc60768cb0 LibWeb: Rewrite audio elements without controls to display:none
This is part of the rendering spec, but we had neglected to do this
before. It causes one WPT check to fail, but other browsers get the
same result on that check, so I guess we can call that a win. :^)
2026-02-23 07:27:31 +01:00
Tim Ledbetter
a4aaed5e83 LibWeb: Propagate error from Notification contructor 2026-02-22 11:37:33 +01:00
Jelle Raaijmakers
83913fef84 LibWeb: Queue animation phase events as part of updating animations
Move the dispatch_events_for_animation_if_necessary() calls into step 1
of update_animations_and_send_events(), where the spec note says
updating timelines involves "Queueing animation events for any such
animations." Previously, these calls ran after step 7 (event dispatch),
causing newly queued events to be deferred by an extra rendering update.

This meant that e.g. a CSS transition triggered during an earlier
rendering step would not have its transitionrun event fired until the
next frame, instead of the current one.
2026-02-13 22:44:17 +01:00
Sam Atkins
db3a8caa7f LibWeb/HTML: Walk flat tree to compute heading offsets 2026-02-05 11:21:08 +01:00
Adam Colvin
ef3991f1ed LibWeb: Implement Document.hasFocus() per specification
Previously, Document::has_focus() always returned true, which was
incorrect. This caused documents without a browsing context (such as
those created via document.implementation.createHTMLDocument()) to
incorrectly report that they had focus.

The implementation now follows the spec:
1. Return false if the document has no navigable
2. Return false if the top-level traversable doesn't have system focus
3. Walk the focus chain from the top-level document to verify this
   document is actually focused

This fixes a WPT test: "The hasFocus() method must return false if the
Document has no browsing context"
2026-01-31 15:13:54 +01:00
Shannon Booth
3e0ea4f62e LibWeb/HTML: Check ongoing navigation before javascript: URL navigation
See: https://github.com/whatwg/html/commit/976d272

This fixes a timeout in the included test. In order for the
test to run properly in our test harness it is modified slightly
(as we are loading the HTML from a file:// URL).
2026-01-26 18:46:54 +01:00
Tim Ledbetter
0035690977 LibWeb: Return body from activeElement() when nothing is focused
This matches the behavior of other browsers.
2026-01-19 13:08:30 +01:00
Jelle Raaijmakers
bf77aeb3dc Tests/LibWeb: Support WPT variant meta tags in test-web
Add support for WPT test variants, which allow a single test file to be
run multiple times with different URL query parameters. Tests declare
variants using `<meta name="variant" content="?param=value">` tags.

When test-web encounters a test with variants, it expands that test into
multiple runs, each with its own expectation file using the naming
convention `testname@variant.txt` (e.g., `test@run_type=uri.txt`).

Implementation details:
- WebContent observes variant meta tags and communicates them to the
  test runner via a new `did_receive_test_variant_metadata` IPC call
- test-web dynamically expands tests with variants during execution,
  waking idle views after each test completion to pick up new work
- Use index-based test tracking to avoid dangling references when the
  test vector grows during variant expansion
- Introduce TestRunContext to group test run state, and store a static
  pointer to it for signal handler access

This enables proper testing of WPT tests that use variants, such as the
html5lib parsing tests (which test uri, write, and write_single modes)
and the editing/bold tests (which split across multiple ranges).
2026-01-16 16:44:13 +00:00
Tim Ledbetter
e16618bdd1 LibWeb: Apply textBaseline offset in Canvas measureText() 2026-01-15 10:31:23 +01:00
Tim Ledbetter
191e8218dc LibWeb: Use correct font metrics calculations in Canvas measureText() 2026-01-15 10:31:23 +01:00
Shannon Booth
1106496d1c LibWeb/HTML: Ensure data: URL workers are same-origin with themselves
See: https://github.com/whatwg/html/commit/baff3f5
2026-01-13 16:59:54 +01:00
Shannon Booth
9eabaa6833 LibWeb/HTML: Set correct length for cross-origin wrapper functions 2026-01-13 10:11:31 +01:00
Shannon Booth
399c62933a LibWeb/HTML: Set correct name for cross-origin wrapper functions 2026-01-13 10:11:31 +01:00
sideshowbarker
1b41659efd LibXML+LibWeb: Use existing HTML entities table for XML parsing too
For XHTML documents, resolve named character entities (e.g., &nbsp;)
using the HTML entity table via a getEntity SAX callback. This avoids
parsing a large embedded DTD on every document and matches the approach
used by Blink and WebKit.

This also removes the now-unused DTD infrastructure:

- Remove resolve_external_resource callback from Parser::Options
- Remove resolve_xml_resource() function and its ~60KB embedded DTD
- Remove all call sites passing the unused callback
2026-01-09 19:13:41 +00:00
Sam Atkins
08d2776860 Tests: Re-enable skipped html5lib parsing tests
These were disabled for hitting assertions when they were imported in
88a4a86ece, but that seems to no longer
be the case a year later. :^)
2026-01-09 08:11:11 +01:00
Shannon Booth
f67c15b2ff LibWeb/Bindings: Ensure identity for [LegacyUnforgeable] attributes
The WebIDL spec requires that attributes marked [LegacyUnforgeable]
share the same getter and setter function objects across all instances
within the same Realm.

Previously, we were creating new JS::NativeFunction wrappers during
every instance initialization, which caused identity checks to fail.
This change moves these functions into Bindings::Intrinsics so they
are created once per Realm and reused.
2026-01-08 12:57:17 +01:00
Shannon Booth
b557e77cf1 Tests/LibWeb: Import some legacy unforgable related WPT tests 2026-01-08 12:57:17 +01:00
CountBleck
a4051cca11 LibWeb: Serialize "auto" ByteLengths correctly in StructuredSerialize
When a "length-tracking" TypedArray/DataView is postMessage'd, the
view seen by the recipient should still be "length-tracking". However,
this wasn't the case, because the actual length was serialized, as
opposed to the JS::ByteLength, which includes the "auto" state to
signal the presence of this "length-tracking" behavior.

This fixes two subtests in...
https://wpt.live/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.html
2026-01-08 00:55:52 +01:00
Lorenz A
48f08ba09d LibWeb: Bump dom tree version to invalid cache on select select_options 2026-01-06 13:03:41 +01:00
Lorenz A
3e296a1b92 LibWeb: Mirror options collection on the select element 2026-01-06 13:03:41 +01:00
Shannon Booth
8a8383d59d LibWeb/HTML: Invalidate frozen ports array on initMessageEvent
In the case that initMessageEvent is called (even with the same
ports), we should return a new array object. This fixes an issue
where the cached m_ports_array was not cleared, causing the
attribute to return the old object identity.
2026-01-06 11:49:06 +01:00
Shannon Booth
82ae2a183c Tests/LibWeb: Import a message event constructor WPT test 2026-01-06 11:49:06 +01:00
CountBleck
d44b239621 LibJS: Crudely implement growable SharedArrayBuffers
We treat any mention of [[ArrayBufferByteLengthData]] and related
atomic operations as FIXMEs to be fixed at a later date. We also add the
HostGrowSharedArrayBuffer abstract operation, which will be overridden
by LibWeb to grow shared WebAssembly memories.
2026-01-04 07:47:55 +01:00
Gingeh
789ab3cc57 LibWeb: Declare namespace prefixes in parse_xml_fragment 2026-01-02 11:09:19 +01:00
Shannon Booth
f9a996650b LibWeb/HTML: Implement the Origin interface
See: https://github.com/whatwg/html/commit/68909b2
2025-12-30 12:40:27 +01:00
Shannon Booth
2a8b83a568 LibWeb/WebIDL: Upgrade QuotaExceededError to its own interface
See https://github.com/whatwg/webidl/commit/48eba6d
2025-12-29 17:15:11 +01:00
Sam Atkins
b0b0669187 LibWeb/CSS: Add :-webkit-autofill as a legacy alias of :autofill 2025-12-18 14:50:27 +01:00
Sam Atkins
36a9b653ae LibWeb/CSS: Add the :autofill pseudo-class
We don't support autofilling of form data yet, so this matches nothing
for now.
2025-12-18 14:50:27 +01:00
Sam Atkins
c906dbeaf7 Tests: Import :autofill pseudo-class test 2025-12-18 14:50:27 +01:00
Sam Atkins
f9f4c36f20 LibWeb: Implement the headingoffset and headingreset attributes
:heading() now matches based on a computed heading level, which is based
on the level of the tag (h1, h2, etc) and then modified by these two new
attributes.

I'm caching this heading level on HTMLHeadingElement, based on the dom
tree version. That's more invalidation than is actually needed, but it
saves us calculating it over and over when the document hasn't changed.

The failing test cases are:
- Implicit headingreset for modal dialogs which is apparently unspecced
  and controversial.
- Not walking the flat tree properly. A flat tree ancestor of a
  slot-assigned element is its slot, which is something we don't do
  anywhere that I could find. I've made a note to look into this later.

We also don't implement the `ReflectRange` IDL attribute yet, which
means we're not clamping the read value of `headingOffset`.

Corresponds to:
e774e8e318
2025-12-15 14:08:24 +00:00
bingyuan.ng
6353118809 LibWeb: Update svg type for root element checks when set/get title 2025-12-14 23:22:38 +00:00
Feng Yu
b58fcaeecf LibWeb: Add HTMLSelectedContentElement for customizable select
Introduce the HTMLSelectedContentElement and integrate it into
<select>, <option> and HTMLParser.

See whatwg/html#10548.

There are two bugs with WPT tests which causes the third subtest
in selectedcontent.html and selectedcontent-mutations.html fail.
See whatwg/html#11882, web-platform-tests/wpt#55849.
2025-12-12 12:06:24 +00:00
Feng Yu
89d50befb0 LibWeb: Sync <select> options handling with latest spec changes
- Rename HTMLOptionElement's `owner_select_element()` to
  `nearest_select_element()` to better match spec terminology.
- Update HTMLSelectElement's option list related algorithms.

This change is part of the customizable <select> spec work.
See whatwg/html#10548.
2025-12-12 12:06:24 +00:00
Carlos Sousa
9e3f4c7639 LibWeb: Return custom validity error message
Previously, validation_message() always returned a hardcoded "Invalid
form" string, now it correctly returns the custom validity error
message when the element is suffering from a custom error.
Other validation errors still return the "Invalid form" message.
2025-12-11 22:06:25 +00:00
Glenn Skrzypczak
d2cb8057c3 LibWeb/HTML: Account for floating point error in step mismatch check
This introduces a new `is_integral_multiple` method that replaces the
`fmod(...) != 0` check. This fixes some WPT-Tests, where the step
cannot be accurately represented as a double.
2025-12-11 16:17:56 +01:00
Callum Law
09b20f172f LibWeb: Set background-image presentational hint as StyleValueList
This fixes a crash introduced in a11666e
2025-12-09 12:08:40 +00:00
Lorenz A
924e4d2baa LibWeb: Add sorting to Table row HTMLCollection
Add an optional sorting function to HTMLCollection. We use
insertion_sort as a stable sorting algorithm so tree order can be
maintained.
2025-12-09 09:26:49 +00:00
Feng Yu
d2029b1814 LibWeb: Relax HTML parser to allow more tags inside <select>
This implements parsing part of customizable <select> spec update.
See whatwg/html PR #10548.

Two failing subtests in `html5lib_innerHTML_tests_innerHTML_1.html`
and `customizable-select/select-parsing.html` are due to the spec
still disallowing `<input>` inside `<select>`, even though Chrome
has already implemented this behavoir (see whatwg/html#11288).
2025-12-04 17:17:01 +00:00
Sam Atkins
e5ea4f9bdf LibWeb/HTML: Add source field to ToggleEventInit
Corresponds to:
95131eec8f

As we now have a field in that dictionary, I removed the separate
`source` parameter from ToggleEvent::create(). Also updated the
relevant test.
2025-12-01 14:58:20 +00:00
Prajjwal
50a79c6af8 LibWeb: Change SessionHistoryTraversalQueue to use Promises
If multiple cross-document navigations are queued on
SessionHistoryTraversalQueue, running the next entry before the current
document load is finished may result in a deadlock. If the new document
has a navigable element of its own, it will append steps to SHTQ and
hang in nested spin_until.
This change uses promises to ensure that the current document loads
before the next entry is executed.

Fixes timeouts in the imported tests.

Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-11-26 12:27:12 +01:00
aplefull
eed4dd3745 LibRegex: Add support for string literals in character classes 2025-11-26 11:34:38 +01:00
Glenn Skrzypczak
a0dbae02c8 LibWeb/HTML: Ignore form owner if earlier same-ID element isn't a form
Only set form owner when there is no non-form element with the same ID
as the control's form attribute earlier in tree order.
2025-11-24 09:51:50 +01:00
Tim Ledbetter
fdd3975104 LibWeb: Don't run update_the_image_data() algorithm if already started
This ensures that events are not fired if the image source is updated
while it is being fetched.
2025-11-15 12:39:37 +01:00
Lorenz A
bd56fdc57b LibWeb: Allow focusable for the first summary child of a detail element 2025-11-12 13:57:05 +01:00
Lorenz A
8ca59e7c7e LibWeb: AnchorElement should be focusable with tabindex 2025-11-12 13:57:05 +01:00
Lorenz A
3bc061d028 LibWeb: Allow all elements with tabindex attribute to be focusable 2025-11-12 13:57:05 +01:00
Lorenz A
f8330a2ec5 LibWeb: Do not execute unclosed SVG script tags 2025-11-09 01:43:46 +01:00
Lorenz A
f54793315c LibWeb: Adjust buttons computed display style 2025-11-01 13:02:44 +00:00
Tim Ledbetter
9da723b5c6 LibWeb: Ensure layout is up to date before resolving canvas colors 2025-10-27 16:56:01 -07:00
Tim Ledbetter
e1ff1e2095 LibWeb: Implement CanvasPattern.setTransform()
This method applies the given transformation matrix to a pattern.
2025-10-27 16:41:02 -07:00