Commit Graph

181 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
4762c4fa5c LibWeb: Add incremental HTML parsing
Introduce IncrementalDocumentParser, which streams the response body
through a TextCodec::StreamingDecoder into the HTMLTokenizer one chunk
at a time. The tokenizer pauses when it runs out of input and resumes
once the next chunk is appended; when the body closes we close the
tokenizer's input stream so it can finish the parse.

DocumentLoading routes HTML responses through the new parser instead of
buffering the full body before handing it to HTMLParser.
2026-04-29 04:12:44 +02:00
Johan Dahlin
0de26af387 Tests/LibWeb: Add tests for @font-face load behavior 2026-04-25 17:06:28 +02:00
Jonathan Gamble
baefb51902 LibWeb: Add Media Capture and Stream APIs 2026-04-21 16:40:46 -05:00
Zaggy1024
19a5c719ca Tests: Skip indexeddb-gc-closes-unreachable-connection for now 2026-04-08 16:13:22 -05:00
Callum Law
58801f40c3 Tests: Import a bunch of canvas context font tests 2026-04-08 14:31:43 +01:00
Andreas Kling
199fcaa0e8 Tests: Skip flaky sizes attribute parsing tests for now 2026-04-07 00:50:31 +02:00
Shannon Booth
a2e735b94c LibWeb: Fire unhandled dedicated worker exceptions on the parent global
When a dedicated worker has an unhandled exception, we should propogate
that exception to be fired at the parent global. Fixes a timeout
in the included WPT test.
2026-04-05 23:38:38 +02:00
Shannon Booth
f27bc38aa7 Everywhere: Remove ShadowRealm support
The proposal has not seemed to progress for a while, and there is
a open issue about module imports which breaks HTML integration.
While we could probably make an AD-HOC change to fix that issue,
it is deep enough in the JS engine that I am not particularly
keen on making that change.

Until other browsers begin to make positive signals about shipping
ShadowRealms, let's remove our implementation for now.

There is still some cleanup that can be done with regard to the
HTML integration, but there are a few more items that need to be
untangled there.
2026-04-05 13:57:58 +02:00
Andreas Kling
0b5ef8fa22 LibWeb: Invalidate styles after constructable sheet updates
Constructed stylesheets updated their rule lists, but adopted documents
and shadow roots were not restyled when replace(), replaceSync(),
or disabled-state changes modified the sheet.  That left several CSSOM
tests passing stale computed styles.

Invalidate stylesheet owners after those updates so adopted sheets
recompute promptly. Also set replace()-produced rules' parent
stylesheet so non-import rules keep their stylesheet context.

The imported baseURL test assumes a tuple origin, so move it to the
HTTP fixture now that replaceSync() actually triggers a restyle.
2026-04-05 12:34:28 +02:00
Shannon Booth
91e7218c22 LibWeb/HTML: Enforce CORS-mode fetch when fetching Worker script
At some point, the FIXME mentioned has been fixed.
2026-04-05 09:52:25 +02:00
Shannon Booth
c1f29993cf Tests/LibWeb: Run two cross origin fetching Worker tests from WPT server
Workers are expected to perform fetches in CORS mode, which we currently
do not implement. These tests fetch scripts from local files, which are
treated as cross-origin under file:// scheme (other browsers also
exhibit this behaviour).

Without this change, the tests time out once CORS-mode fetching is
correctly enforced.
2026-04-05 09:52:25 +02:00
Tim Ledbetter
5b584fde1d LibWeb: Register JS-created FontFace objects for font matching
Previously, FontFace objects created via the JS and added to
`document.fonts` were stored in the FontFaceSet but never participated
in font matching during style resolution. We now store both
CSS-connected and JS-created font faces in a unified map on
`FontComputer`, keyed by family name, and include them all as
candidates in the font matching algorithm.
2026-04-05 00:13:35 +02:00
Tim Ledbetter
eb8943cd55 Tests: Remove imported WPT tests that have been deleted upstream 2026-04-04 23:36:58 +02:00
Zaggy1024
666ce0f854 LibMedia: Deal with tracks being toggled during seeks properly
This fixes a crash when a track is enabled and then disabled while a
seek is in progress.

The logic in SeekingStateHandler is reworked to keep track of the
tracks that are currently being seeked, and when a track is disabled,
it is no longer counted against the seek completion. Any seek
completion callback that was instated is cleared by calling seek with
a null callback.

It may be worth making a separate function on the data providers to
clear the current seek instead, to avoid the extra work of seeking, but
this scenario is a very rare one unless someone intentionally triggers
it, and the cost is minimal unless the toggles are spammed.

A crash test is included, which both tests for the crash, and would
also time out if the failing VERIFY in on_track_enabled() was avoided
with the previous seeking implementation, due to the originally-enabled
video track's seek callback being clobbered by on_track_enabled()'s
seek.
2026-04-03 20:13:15 -05:00
Glenn Skrzypczak
e5dab9e1c7 LibWeb: Support WASM modules
This adds support for importing WASM modules in JavaScript and vice
versa.
2026-04-03 21:21:09 +02:00
Glenn Skrzypczak
7392d2a2f4 LibWeb: Support JSON modules
This adds support for importing JSON objects from JSON files in
javascript.
2026-04-03 21:21:09 +02:00
Glenn Skrzypczak
f1d3244b22 LibWeb: Support CSS modules
This adds support for importing CSS stylesheets from CSS files in
javascript.
2026-04-03 21:21:09 +02:00
Timothy Flynn
b3bc5e7956 Tests/LibWeb: Import basic cache storage tests 2026-04-03 11:04:12 +02:00
Timothy Flynn
523e32bbbb LibWeb: Permit storage keys to use non-opaque origins for file:// URLs
Features like localStorage, sessionStorage, and CacheStorage all work on
file:// URLs in other browsers. The spec is a bit uncertain as to when
such URLs should be treated as non-opaque, and leave it "as an exercise
to the reader".

Note that we perform this check in obtain-a-storage-key rather than in
the non-storage method, as the latter is also used for e.g. blob://
URL storage.
2026-04-02 10:21:15 +02:00
Psychpsyo
44ef574902 LibWeb: Properly set visibility state for nested documents
This cannot happen inside the Make Active algorithm, since that gets
called during document creation, which commonly happens before the
document's navigable is created.

Aligns us with a recent spec change and rids us of some AD_HOC
behavior.
2026-04-01 17:26:46 +02:00
Zaggy1024
bb2578b88f Tests: Add a test to exercise MSE buffered ranges
Our test file conveniently has a cluster not beginning with a keyframe,
so we can test our discarding of frames until a RAP with this test.
2026-04-01 02:54:22 -05:00
Zaggy1024
59bc23f309 Tests: Add a test to demonstrate MSE progress 2026-04-01 02:54:22 -05:00
Sam Atkins
bd5424f435 Tests: Import WPT base64() test
This no longer crashes with the StringView fix in the previous commit.
2026-03-31 19:01:10 +02:00
Aliaksandr Kalenik
a4fa630941 Tests: Fix flaky form-disabled-callback WPT test
The test submits a form to /common/blank.html via an iframe. Under
file://, this resolves to file:///common/blank.html which doesn't
exist. The failed navigation sometimes leaves the iframe cross-origin,
causing a SecurityError when accessing iframe.contentWindow.location,
which prevents the promise from resolving and causes a timeout.

Serve the test over HTTP so the form submission resolves to the echo
server's WPT tree, where /common/blank.html exists.
2026-03-30 14:46:31 +02:00
Andreas Kling
fd3a09a8ce LibWeb: Don't paint render-blocked iframe documents
Parent document paints could still record and paint a nested iframe's
contents even while the child document was render-blocked. That let
unstyled iframe content leak into the parent display list before the
child's blocking stylesheet had loaded, which matched the FOUC seen in
Speedometer's TodoMVC suites.

Skip painting hosted documents from NavigableContainerViewportPaintable
while they are render-blocked. Add a reftest that keeps an iframe child
render-blocked with a delayed stylesheet and forces a parent repaint;
without the fix the child's inline FAIL text becomes visible.

The new reftest passes with this change, and the existing render-
blocking requestAnimationFrame tests still pass.
2026-03-29 23:50:47 +02:00
Tim Ledbetter
f601c0cd4b LibWeb: Disable Navigation API after document.open() on about:blank
This matches the behavior of other engines.
2026-03-29 16:39:03 +02:00
Jenn Barosa
8808a54f37 LibWeb: Fix session history replacement for superseded navigations 2026-03-29 03:11:14 +02:00
Sam Atkins
fe3c6a1f9f Tests: Import WPT custom-elements/registries tests
Includes reimporting the test we already had, which has changed
significantly.

Most of these fail, but importing them now to track progress.
2026-03-27 19:49:55 +00:00
Shannon Booth
346fa16b1e LibWeb: Don't cancel pending navigations in navigate to a javascript URL
Other browsers appear to only do this for form submission, not for
all javascript URL navigations. Let's remove the handling in the
general javascript URL navigation handling so that our behaviour
diference to other browsers is limited specifically to form
elements, instead of the general case.

Unfortunately this does (expectedly) cause the test added in
3e0ea4f62 to start timing out, so that test is marked as skipped.
2026-03-25 22:05:25 +01:00
Tim Ledbetter
ce97fe2ad0 Tests: Unskip overflow-scroll-float-paint-order.html
This test now passes.
2026-03-25 21:28:57 +01:00
Tim Ledbetter
d69d74e7ce LibWeb: Always shift line boxes below floats when content does not fit
Previously, this wasn't done when placing the first inline content in a
block, which caused long unbreakable words to overlap with floats
instead of being moved below them.
2026-03-25 21:28:57 +01:00
Callum Law
02db1b942b LibWeb: Improve handling of calculated values in <ratio>
We no longer try to resolve calculated values at parse time which means
we support relative lengths.

We now clamp negative values rather than rejecting them at parse time.

Parsing has been inlined into `parse_ratio_value` and `parse_ratio` has
been removed since `parse_ratio_value` was the only caller
2026-03-24 14:00:01 +00:00
Shannon Booth
fa1c046e68 Tests/LibWeb: Import some MessageEvent Origin API tests 2026-03-23 22:32:43 +01:00
Shannon Booth
48ef283d61 Tests/LibWeb: Run a bunch more tests from file:// scheme
All of these failures seem to have been ladybird not allowing file://
scheme pages to load fonts from file:// URLs. f2976807da changed
the behaviour to allow this, so we can now run all of these tests
from local file (which is preferred as this runs faster).
2026-03-23 09:48:09 +01:00
Shannon Booth
45a87b1dbe LibWeb: Update document URL to the entry document URL in document.open()
When document.open() is called from another window, the opened
document's URL should be updated to match the calling document's URL.
2026-03-23 09:00:39 +01:00
Jelle Raaijmakers
f6f7e75ac9 LibWeb: Report actual network error for failed XHRs
Seeing "NetworkError: Network error" when an XHR failed was not that
useful - use the actual error message when available.
2026-03-22 18:58:49 +01:00
Callum Law
5b07dcbd5d LibWeb: Respect @font-feature-values rules 2026-03-20 16:08:32 -05:00
Shannon Booth
cc711a6060 LibWeb/HTML: Fire storage events to windows without a Storage
Storage objects are created lazily when window.localStorage or
window.sessionStorage is first accessed. Previously, broadcast()
iterated over already-created Storage objects, so windows that had never
accessed these properties would not receive storage events.

Fix this by iterating over all active windows and initializing Storage
objects as part of the broadcast loop so all eligible windows receive
the event regardless of whether they had previously accessed
their storage property.
2026-03-16 13:55:07 +01:00
Tim Ledbetter
e7a625185a Tests: Use HTTP server when running grid-gutters-and-tracks-001.html
Using [LoadFromHttpServer] is required to load the Ahem font used by
this test.
2026-03-14 17:32:39 +01:00
Jelle Raaijmakers
ec286d96ec Tests/LibWeb: Import WPT canvas text baseline tests 2026-03-10 11:33:35 +01:00
Zaggy1024
30e21c2790 Tests: Unskip idbfactory_open.any.html
This doesn't seem to be timing out anymore.
2026-03-05 17:12:55 -06:00
Zaggy1024
856174b60e test-web: Allow TestConfig.ini to refer to entire directories
When a path in TestConfig.ini ends in a /, treat it as a directory and
recursively enumerate all tests within it to the requisite collection
of paths.

We can immediately use this to drop a bunch of lines from the config
that specify individual IndexedDB tests should use the HTTP server.
2026-03-05 17:12:55 -06:00
Jelle Raaijmakers
e99ff65a58 LibWeb: Use glyph positions & widths instead of Harfbuzz for range rects
We use Harfbuzz to lay out glyphs at their right positions, but we
should not do so for substrings as we were doing for selection/range
rects: their positioning is dependent on their full context to properly
determine kerning and ligatures, for example.

Instead, use the stored glyph positions & widths directly to calculate
the range rect for a partial fragment selection. This makes the
selection rect visually stable - it no longer jitters when expanding the
selection character by character.
2026-03-02 17:52:47 +01:00
Shannon Booth
8c8b8338b7 Tests/LibWeb: Load tests relying on tuple file origins from HTTP server
These tests do not work when run from an opaque origin file:// URL.
2026-03-01 01:04:10 +01:00
Shannon Booth
9e198ff523 Tests/LibWeb: Run less Origin testcases from web server
Only the two remaining tests are making assumptions about the
origin of the initial document's global being a tuple origin.
2026-03-01 01:04:10 +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
Timothy Flynn
432be813ce Tests/LibWeb: Disable a couple tests 2026-02-24 21:46:25 -05:00
Sam Atkins
afdc0df70b Tests: Re-enable some tests which rely on font loading
These should no longer be flaky, now that we wait for fonts to load.
2026-02-24 15:44:32 +00:00
Tim Ledbetter
91b7525e18 LibWeb: Ensure favicon URL is valid before fetching it
Previously, we would crash when attempting to fetch the favicon if
the `<base>` element had an invalid URL.
2026-02-24 15:05:31 +01:00
Luke Wilde
8017f8a7ed Tests/LibWeb: Import Fullscreen WPT tests 2026-02-23 18:44:26 +00:00