Commit Graph

4412 Commits

Author SHA1 Message Date
Karl Seguin
e7be3c8b14 still trying to get this test to pass 2026-04-20 18:57:45 +08:00
Karl Seguin
55d7bae943 more busy timeout tricks 2026-04-20 18:42:55 +08:00
Karl Seguin
fcd3d1cd14 Use unsafe journal_mode during Pool test
Can't use WAL, as it thread sanitizer reports false positives. The default,
delete, causes busy timeouts. Let's try the unsafe memory!
2026-04-20 18:14:29 +08:00
Karl Seguin
b226a9ed52 Disable WAL mode for Sqlite pool test
It seems like there are known false positives with thread sanitizer and sqlite.

(There are various references to this in sqlite's wal.c and also possibly
related https://bugzilla.mozilla.org/show_bug.cgi?id=1153409
2026-04-20 17:16:42 +08:00
Karl Seguin
6d0003ad2b Sqlite
This adds an app.storage which is a union around configurable storage engine
(currently, only sqlite).

It is _not_ being used anywhere right now. The goal is to get feedback on
the implementation and then move cache to it.

This doesn't expose a generic query API. The goal is that the storage will
expose high level methods, e.g. `cacheGet(req: CacheGetRequest)` and every
storage engine will translate the `storage.CacheGetRequest` as needed.

A thin wrapper around the Sqlite C api is included, e.g. exec(SQL, .{args}) a
`rows` and `row` fetcher. A connection pool is included. By default, an
in-memory DB is currently created. And a `migrations` table with an id of `1`
is created/inserted. I don't imagine needing fancy migratations.
2026-04-20 17:13:06 +08:00
Karl Seguin
b08ae07598 build with sqlite3, just to see how it behaves in the CI 2026-04-20 15:43:49 +08:00
Karl Seguin
c159be503a Merge pull request #2194 from lightpanda-io/import_log
Change all @import("...../log.zig") to const log = lp.log;
2026-04-20 15:07:15 +08:00
Karl Seguin
6e02e41ad3 zig fmt 2026-04-20 14:22:48 +08:00
Karl Seguin
3e8b63aa1b Merge pull request #2184 from lightpanda-io/perf-axnode-scratch-arena
ax: route AXNode.Writer scratch allocations through a dedicated arena
2026-04-20 14:22:04 +08:00
Adrià Arrufat
983e592b43 cdp: use page arena pool for AXNode writer 2026-04-20 07:42:08 +02:00
Karl Seguin
2d20e57f80 Change all @import("...../log.zig") to const log = lp.log;
@import("lightpanda") where needed.

Would also like to do this for String, Page, Session and js which all stand out
as types that are use across the codebase.

I know that a few devs are doing this in new work and I haven't heard anyone
voice an objection.
2026-04-20 12:40:04 +08:00
Karl Seguin
1c8c68f3d9 Fix document.writeln test
Broken scoping.
2026-04-20 10:25:58 +08:00
Karl Seguin
3ceb28eab3 Merge pull request #2190 from lightpanda-io/async_test
Remove remaining "legacy" async tests.
2026-04-20 10:25:19 +08:00
Karl Seguin
98abe3fc92 Merge pull request #2191 from lightpanda-io/feat/timer-string-handler
Feat/timer string handler
2026-04-20 10:11:34 +08:00
Karl Seguin
728f2f2945 uncomment and fix some animation tests 2026-04-20 10:11:00 +08:00
Karl Seguin
20531b0f87 try to fix flaky CI test 2026-04-20 10:06:09 +08:00
Karl Seguin
9a6875f1b5 Prefer union over js.Value type checking
Allow mapping js input to a js.String (previously, had to be either a []const u8,
an SSO, or a js.Value). Allow compileFunction to be called directly with a
js.String.
2026-04-20 09:51:42 +08:00
Karl Seguin
6e989ad5b8 Remove remaining "legacy" async tests.
Follow up on https://github.com/lightpanda-io/browser/pull/2179 to remove
the remaining "legacy" async tests (I didn't realize there were only 2 more
files, should have done it all in that commit). Also, slightly improve how
these async tests work in Chrome/FF.
2026-04-20 09:35:33 +08:00
Karl Seguin
3ad683121b Merge pull request #2183 from lightpanda-io/wpt_extensions
Add WPT extensions
2026-04-19 07:08:34 +08:00
Pierre Tachoire
b4cd263459 Merge pull request #2188 from luckyyyyy/feat/document-writeln
feat(document): implement document.writeln
2026-04-18 14:19:42 -04:00
Karl Seguin
24b86a847c Merge pull request #2179 from lightpanda-io/websocket_fixes
Websocket fixes.
2026-04-18 10:06:12 +08:00
Karl Seguin
0b598cfcc5 Merge pull request #2180 from lightpanda-io/update_html5ever
This updates html5ever and the other Rust dependencies.
2026-04-18 10:02:24 +08:00
Karl Seguin
fb9e1d91a5 Merge pull request #2181 from lightpanda-io/blob_constructor
Support more types in new Blob(...)
2026-04-18 10:02:20 +08:00
Karl Seguin
4b701aa978 Merge pull request #2185 from lightpanda-io/cookies_and_friends_fix
Improve Cookie parsing rules
2026-04-18 09:40:50 +08:00
William Chan
5041450fcf feat(window): accept DOMString handler in setTimeout/setInterval
The HTML spec defines `TimerHandler` as `Function or DOMString`, and
the string form is still widely used by legacy sites and server-rendered
pages (e.g. clocks that do `setInterval("updateTime()", 1000)`).

Previously the binding signature required `js.Function.Temp`, so passing
a string threw `TypeError: invalid argument` and aborted page scripts.

Accept `js.Value.Temp` instead, then resolve the handler per spec:
  * Function -> persist as-is (unchanged behavior).
  * String   -> compile as the body of an anonymous function via
                `Local.compileFunction`, mirroring what the existing
                `Context.stringToPersistedFunction` helper does for
                HTML attribute event handlers.
  * otherwise -> `InvalidArgument` (TypeError, same as before).

Tests added to window/timers.html:
  * setTimeout(string) runs the compiled code.
  * setInterval(string) fires at least once and is cancellable.
  * non-function / non-string handler still throws TypeError.

Spec: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
2026-04-18 07:26:12 +08:00
William Chan
5b8592de5a feat(document): implement document.writeln
Document.writeln was not registered on the DOM prototype, so legacy
scripts that rely on it (e.g. script loaders that inject <script> tags
via `document.writeln`) crashed with `document.writeln is not a
function` and prevented the rest of the page from running.

Per HTML spec, writeln runs the document write steps with the joined
argument text followed by a U+000A LINE FEED character. Implement it
by sharing the existing write pipeline so all InvalidStateError and
parser behavior is identical to write().

Tests added to document/write.html covering:
- writeln appends a trailing newline text node after the written nodes
- multiple arguments are concatenated before the newline is appended

Spec: https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln
2026-04-18 07:24:30 +08:00
Adrià Arrufat
3e49b3feae cdp: centralize scratch arena reset in AXNode 2026-04-17 15:22:45 +02:00
Karl Seguin
e6a190c72d Improve Cookie parsing rules
This commit was focused on making small changes to cookie parsing in order to
improve a handful of WPT cases.

Protects against nameless cookies that have a value with certain prefixes (e.g.
`__Secure-`) which could be pased into an incorrect prefix.

It allows tabs in cookie names/values.

It enforces that certain prefix have certain settings.

Along the way:
- Added window.origin
- Ensure URL passed to Request is escaped
- Added log on fetch error
- made --dump wpt only list non-passing results
2026-04-17 19:12:19 +08:00
Adrià Arrufat
b42251d750 ax: route AXNode.Writer scratch allocations through a dedicated arena 2026-04-17 12:53:43 +02:00
Adrià Arrufat
36c1218486 ax: add lazy label index for name resolution 2026-04-17 12:20:10 +02:00
Adrià Arrufat
5352bf50fd StyleManager: add check_display 2026-04-17 12:08:08 +02:00
Adrià Arrufat
40b22f72a9 cdp: use in_aria_hidden instead of literal value 2026-04-17 11:54:32 +02:00
Karl Seguin
23e98a4ce0 Add WPT extensions
Some WPT tests need to interact with the browser in a way that isn't possible
with web apis. Browsers need to expose a way for tests to do this and then use
the testdriver-vendor.js to hook into these special WPT actions.

This commit sets up the infrastructure for supporting this and includes
the delete_all_cookies functionality needed by various cookie tests (e.g.
/cookies/attributes/attributes-ctl.sub.html).

A new compilation flag, `-Dwpt_extensions`, can be specified. When specified
a `window.webdriver` accessor is defined and a `WebDriver` type is exposed.

Note that, while I only implemented delete_all_cookies for now, I've seen other
tests fail because of missing vendor-specific implementation.
2026-04-17 15:59:06 +08:00
Adrià Arrufat
1e1c19d543 css: implement URL tokenization
Implements unquoted URL tokenization per CSS Syntax Level 3 §4.3.6.
Adds bad URL recovery and an AX tree test fixture.
2026-04-17 09:06:36 +02:00
Karl Seguin
ba947b8c76 Support more types in new Blob(...)
Gives the same treatment to Blob as https://github.com/lightpanda-io/browser/pull/2171
gave to Response.

Creating a blob from JS and creating a blob internally is different enough that
they now share little, and the ergonomics for creating a blob internally are
better / simpler.

Conversely, initializing a Response and Blob from a js.Value now share a
`js_val.toStringSmart()` which can probably be used in other places. Unlike
`toString()` which behaves like JavaScript (e.g. array_buffer.toString() ->
"[object ArrayBuffer]"), `toStringSmart` understands buffers and blobs.
2026-04-17 14:37:37 +08:00
Adrià Arrufat
cee72cabb9 cdp: improve AX tree visibility and label resolution
Prunes hidden subtrees from the accessibility tree and implements
accessible name resolution via labels. Adds the `labels` property
to labellable HTML elements.
2026-04-17 08:33:13 +02:00
Karl Seguin
e7c44d34f4 This updates html5ever and the other Rust dependencies.
Inspired by:
https://github.com/lightpanda-io/browser/security/dependabot/1
2026-04-17 12:39:15 +08:00
Karl Seguin
9b93ac690e Migrate more tests to new async (failing in CI)
Also improve test report failure on async failure.
2026-04-17 12:10:35 +08:00
Karl Seguin
aac0a6e6b6 Websocket fixes.
This commit fixes a few serious issues with the Websocket implementation.

1 - libcurl recursive api calls
Creating a Websocket instance from within a libcurl callback results in libcurl
failing with a RecursiveApiCall error. I fixed this more generally by adding a
`ready_queue` which connections can use when the `HttpClient` is performing
actions. Once `perform` ends, this new `ready_queue` is processed. There might
be a more holistic solution to this (we seem to run into RecursiveApiCall
everywhere), but since HttpClient is going through heavy changes, this seemed
like the smallest possible change to fix it.

2 - "load" blocking
Load and IdleNetwork notifications should not block on Websocket connections. To
solve this, `HttpClient` now ha `http_active` and `ws_active` to replace `active`.
Only `http_active` is used for things like "load" triggering.

3 - The above change made the Runner's job more complicated. It used to be
binary: you either have active connections or not. Now there are different types
of active connections. To keep it simple, and I think probably more correct,
the "done-ness" (based on the `wait` parameter) is now independent of active
(or not) network activity. If the page's `load_state == .complete`, then the
`wait == .done` is considered successful, whether or not we have active
connections.

4 - As a consequence of the above, and seemingly unrelated to all of these
changes, a number of html tests now use the "new" robust async framework. Most
of these tests were using the `testing.onload` (aka `testing.eventually`) which
had somewhat...unclear semantics. These tests passed more of a consequence of
how we processed a page and being very simple (e.g. just needing 1 micro or
macrotask tick). But `eventually` never worked for more complicated cases, and
the previous `testing.async` didn't work well. Now, the test runner waits for
.load (which, as per #3, can fire more aggressively), which caused many
`eventually` tests to fail. Moving these tests to the new `async` is more
robust and works with the new aggressive "load".
2026-04-17 11:20:27 +08:00
Karl Seguin
6caca237fd Merge pull request #2172 from lightpanda-io/replaceChild_safety
Improve safety of Node.replaceChild and Element.replaceWith
2026-04-17 07:05:48 +08:00
Karl Seguin
13f5406d1d Merge pull request #2171 from lightpanda-io/Response_init_body
Expand body types new Response(...) can be created with
2026-04-17 07:05:37 +08:00
Karl Seguin
838b79d19a Merge pull request #2170 from lightpanda-io/decoder_double_free
Avoid double free on decoder error
2026-04-17 07:05:25 +08:00
Pierre Tachoire
8de5267cd0 Merge pull request #2169 from lightpanda-io/feat/cookies-file
Feat/cookies file
2026-04-16 08:21:53 -04:00
Karl Seguin
1bffde8808 Improve safety of Node.replaceChild and Element.replaceWith
We've seen this sort of thing before - an assumption we make about the state of
the DOM through a transition is broken by CustomElement callbacks.

Here we see replaceChild which (a) inserts the new nodes and (b) removes the
old one. As part of removing, our page.removeNode has an assertion that the
child belongs to the parent. This is a guarantee that the Page is asking the
caller (Node.replaceChild in this case) to make. But, if the node being inserted
is a custom element, it can have a callback so step (a) can cause changes to
the document, including removing/moving the node being replaced.

TL;DR - CustomElement callbacks means that we have to check that the child to
be replaced is still a child of the parent after our insert.
2026-04-16 16:09:01 +08:00
Karl Seguin
d66cdcbf71 Merge pull request #2164 from lightpanda-io/Page_createIsolatedWorld
Fix Page.createIsolatedWorld
2026-04-16 15:16:51 +08:00
Karl Seguin
7da63432ec Expand body types new Response(...) can be created with
Was originally just a []const u8, but now allows for Blob, BufferArray (and
related) and Stream.

I saw this being used on http://www.github.com/ (homepage). Unfortunately its
using the data for webgl stuff that we don't support, but it does move the
processing a step further.
2026-04-16 14:48:59 +08:00
Karl Seguin
84bb395c02 Avoid double free on decoder error
Fixes WPT crash: /encoding/textdecoder-fatal-streaming.any.html
2026-04-16 11:10:41 +08:00
Karl Seguin
3ca1f230b9 Serialize sameSite
Tweak ergonomics (public functions log internally and are infallible). Use
readFileAlloc directly. Fix possible memory leak with cookie arena - I don't
think you can make a copy of the arena, and then dupe with the original.
2026-04-16 10:35:34 +08:00
Karl Seguin
09dab74ed0 Merge pull request #2167 from lightpanda-io/finalizer_fingers_crossed
Improve finalizer code
2026-04-16 07:20:52 +08:00
Karl Seguin
51a3835a4a Use flag to protect against resolve_ptr_reuse
The point of this change is that v8 might call these finalizers after we've
cleared things (e.g. because it's already queued it). We need to make the
FC.Identity self-contained and not rely on any external state (like the
finalizer_callback lookup) which might have new entries.
2026-04-16 07:00:26 +08:00