Commit Graph

6087 Commits

Author SHA1 Message Date
Pierre Tachoire
caee513701 abort all http navigation before starting the pending one 2026-05-07 18:09:27 +02:00
Karl Seguin
d4a210c5f1 Merge pull request #2385 from lightpanda-io/avoid_script_error_double_free
On error, don't free headers
2026-05-07 22:11:58 +08:00
Karl Seguin
61497ffe3a Merge pull request #2383 from lightpanda-io/css_static_binding
Fix binding for static (in general) and specifically for CSS.escape
2026-05-07 20:30:40 +08:00
Karl Seguin
a4cf214040 Merge pull request #2382 from lightpanda-io/xhr_fix_teardown_order
Fix the XHR teardown order
2026-05-07 20:05:55 +08:00
Karl Seguin
87b0c33344 Merge pull request #2384 from lightpanda-io/silence_test_warns
Silence test warnings
2026-05-07 19:50:57 +08:00
Karl Seguin
a74c5cc54c On error, don't free headers
There's ambiguity in the http_client.request() call on whether or not the caller
is responsible for freeing the header. It depends how request() fails, and it's
impossible for the caller to know. This needs a fundamental fix, but, in the
meantime, we get to pick between: a possible leak or a double free.

This commit opts for a possible leak. Why? Because overwhelmingly, if request
fails, it'll fail at a point where it will handle the free. In those cases
where it doesn't then the system is probably in trouble anyways (OOM).

(Also, as I was debugging, I noticed that the function.src() debug helper
wasn't working, so I fixed it).
2026-05-07 19:47:29 +08:00
Karl Seguin
459c7a532a Silence test warnings
https://github.com/lightpanda-io/browser/pull/2368  added more warnings on JS
callback failure. The test for these naturally trigger the logging. Silence them
during testing.
2026-05-07 18:59:46 +08:00
Karl Seguin
dd49e51f7a Fix binding for static (in general) and specifically for CSS.escape
Fixes rendering issue on:
https://jobs.gem.com/inception/am9icG9zdDpZ-UzWsyEeC6ZVEZ8l0t4s
2026-05-07 18:49:28 +08:00
Karl Seguin
783bfd3813 Fix the XHR teardown order
`releaseRef` can free the XHR instance, so anything we want to set, has to
happen before then. (It might seem like the set is meaningful if we're just
going to destroy the instance, but `releaseRef` might also _not_ destroy the
instance, and the guard is for those cases).
2026-05-07 17:48:34 +08:00
Karl Seguin
03ee1f61d0 Merge pull request #2376 from webcoyote/fix-ws-port
Fix /json/version advertising ws://host:0/ when --port 0
2026-05-07 08:19:18 +08:00
Karl Seguin
4f7db8e974 Merge pull request #2375 from lightpanda-io/worker_location
add WorkerLocation
2026-05-07 08:18:51 +08:00
Karl Seguin
f13ca0f44a Merge pull request #2371 from lightpanda-io/cdp_navigate_fast_path
On an unloaded-page, fast-path navigation
2026-05-07 06:47:43 +08:00
Karl Seguin
608650533a Merge pull request #2374 from lightpanda-io/frame_deinit_order
Abort http_client _before_ destroying context
2026-05-07 06:47:26 +08:00
Karl Seguin
740f95e142 Merge pull request #2372 from lightpanda-io/worker_subtle_crypto
Make SubtleCrypto work on Worker
2026-05-07 06:47:12 +08:00
Patrick Wyatt
f352c49a3a Fix /json/version advertising ws://host:0/ when --port 0
buildJSONVersionResponse read the port from app.config.port(), which
is the configured value (still 0 with --port 0). Pass the OS-assigned
port from the bound address instead, so webSocketDebuggerUrl matches
the actual listener.

The integration test previously asserted a literal ws://127.0.0.1:9222/
that happened to match the test config's default port but not the
harness's hardcoded bind address (9583) — drop the URL assertion; the
buildJSONVersionResponse unit test already covers URL formatting.
2026-05-06 12:44:38 -07:00
Karl Seguin
15021b7302 add WorkerLocation
This is a distinct type from Location, a read-only subset.
2026-05-06 18:57:31 +08:00
Karl Seguin
042df590a2 Abort http_client _before_ destroying context
XHR, for example, needs the context to properly shutdown. It get the page via
exec.context.page. Now, we could store the page on the XHR instance, sure. But
the point is the js.Context should never need the HttpClient, so it should
always be safe to abort inflight requests before canceling the context.

Fixes some flaky WPT crashes.
2026-05-06 18:42:06 +08:00
Karl Seguin
95f647d4ae Make SubtleCrypto work on Worker
This is a source of many WPT crashes right now. worker.crypto is exposed, and
therefore worker.crypto.subtle also is.
2026-05-06 16:12:41 +08:00
Karl Seguin
0c87fd6771 Merge pull request #2370 from lightpanda-io/fix-a34-fetch-xhr-formdata-multipart
Fix a34 fetch xhr formdata multipart
2026-05-06 12:50:34 +08:00
Karl Seguin
47792378ee On an unloaded-page, fast-path navigation
This re-implements the CDP navigate action fast-path when a page is in a
waiting state. It was removed for https://github.com/lightpanda-io/browser/pull/2297.

I believe this fast-path is still safe to do given that a page in _waiting has
had no navigation event yet and thus has nothing to preserve. The upside is
being able to re-use the existing [bare] v8::Context.
2026-05-06 12:38:12 +08:00
Karl Seguin
7e0dc678c4 Improve BodyInit
Replace boundary allocation with a fixed-size buffer. Follow file naming for
non-struct-as-file file.
2026-05-06 12:06:54 +08:00
Karl Seguin
6136443764 Merge pull request #2369 from lightpanda-io/fix-a33-dispatch-listener-throw
Tweak: events: report listener exceptions instead of halting dispatch
2026-05-06 10:17:09 +08:00
Karl Seguin
bf7cac2b68 Extract repeated listener switch/execution into helper 2026-05-06 09:07:38 +08:00
Karl Seguin
00d0a9f3b0 Merge pull request #2366 from lightpanda-io/custom_element_callbacks_again
Protect DOM mutations against custom element callbacks.
2026-05-06 08:02:16 +08:00
Karl Seguin
ca4444e389 Merge pull request #2362 from lightpanda-io/slience_test_log
silence an unecessary test log
2026-05-06 07:53:40 +08:00
Karl Seguin
a3891c4f68 Merge pull request #2364 from lightpanda-io/response_double_free
Protect against response double-free
2026-05-06 07:53:26 +08:00
Karl Seguin
0ca3f2d8ec Merge pull request #2365 from lightpanda-io/dom_version_node_frame
Track DOM version based on the node's owning frame
2026-05-06 07:53:13 +08:00
Navid EMAD
b573e44fe1 events: report listener exceptions instead of halting dispatch
Per DOM §2.9 step 4 substep 8 ("Inner invoke"), an exception thrown by a
listener callback must be reported to the realm's global, not propagated
out of `dispatchEvent`. Subsequent listeners on the same target and the
rest of the capture/bubble walk must still run.

Both `EventManager.dispatchPhase` (DOM targets) and
`EventManagerBase.dispatchDirect` (Window/XHR/AbortSignal/etc.) wrapped
the V8 callback invocation in raw `try`, so a listener throw aborted the
whole dispatch and surfaced as an uncaught exception at the
`Runtime.evaluate` boundary. The inline-handler invocation a few lines
above already used `catch |err| log.warn(...)`; this just extends the
same shape to the listener switch.

Closes #2367
2026-05-05 18:16:52 +02:00
Karl Seguin
5112adc69f Protect DOM mutations against custom element callbacks.
Same issue as https://github.com/lightpanda-io/browser/pull/2313

DOM mutations have certain expectations that custom element callbacks can
violate.
2026-05-05 19:22:34 +08:00
Pierre Tachoire
b506e7998f Merge pull request #2360 from lightpanda-io/wp/mrdimidium/fix-crash
Fix v8 crash
2026-05-05 12:43:36 +02:00
Karl Seguin
becbd54f4e Track DOM version based on the node's owning frame
This fixes 2 separate issues, driven by the [very] broken
/dom/ranges/Range-insertNode.html WPT test.

The first, and simplest, is that when a script element is cloned, its executing
_executed and _force_async flags need to be copied. This prevents double-
execution.

The second is more complicated: dom version tracking (as a caching mechanism
used in various live collection) has to be against the node's owning frame, not
the frame that's executing the JavaScript. This includes both the version
checking and version change (on dom mutation). This introduces a relatively
expensive node -> document -> frame on every mutation and cache read. This is
potentially worth optimizing somehow, in a follow up PR. Two options come to
mind:

1 - Track a single dom version on the Page. Mutation in frame1 invalidates
    frame2.
2 - Optimize for the frame-less case. If a page has no frame, then the calling
    context should be equal to the owning document's frame.
2026-05-05 18:41:13 +08:00
Karl Seguin
8ee644d9bf Protect against response double-free
When Fetch.httpErrorCallback rejects the promise, microtasks are run. Those
microtasks could do anything, including triggering a frame shutdown (e.g. via
a navigation event). The result is that we end up with

httpErrorCallback
  httpShutdownCallback

And the code simply isn't designed to handle that. httpErrorCallback now takes
control of the cleanup, capturing the `self._owns_response` in a local, and
disabling so that any nested `httpShutdownCallback` are noops.
2026-05-05 15:19:10 +08:00
Karl Seguin
bdc9013241 silence an unecessary test log 2026-05-05 07:52:37 +08:00
Karl Seguin
d360fcc07b Merge pull request #2352 from navidemad/fix-input-pattern-validation
forms: implement HTMLInputElement.pattern + patternMismatch validity
2026-05-05 07:49:18 +08:00
Karl Seguin
91074ea834 Merge pull request #2361 from lightpanda-io/worker_deinit_order
Fix potential use-after-free by clearing worker AFTER frame context
2026-05-05 07:34:42 +08:00
Karl Seguin
d1d85e9f5d Fix potential use-after-free by clearing worker AFTER frame context 2026-05-05 07:21:37 +08:00
Karl Seguin
bc081247e7 update v8 dep 2026-05-05 07:04:02 +08:00
Nikolay Govorov
e5a9f8ba2e Fix ony more crash 2026-05-04 18:12:47 +01:00
Nikolay Govorov
5cc8a0daff Fix v8 crash 2026-05-04 17:21:15 +01:00
Nikolay Govorov
9c669974e4 Merge pull request #2359 from lightpanda-io/wp/mrdimidium/spli-cdp-http
Reorganize Server, Client, CDP and HttpClient
2026-05-04 17:03:19 +01:00
Nikolay Govorov
9a312a4177 Refactor server/client/cdp structure 2026-05-04 16:41:22 +01:00
Pierre Tachoire
0794fbdc68 upgrade zig-v8-fork 2026-05-04 17:27:44 +02:00
Navid EMAD
a639ae2047 net: multipart-encode FormData bodies in fetch and XMLHttpRequest
Wire the existing multipart encoder (FormData.multipartEncode) into the
fetch and XHR body paths. Previously both entry points typed their body
parameter as ?[]const u8, so the JS->Zig bridge silently coerced any
FormData JSValue via toString() and emitted "[object FormData]" with
Content-Type: application/x-www-form-urlencoded.

Introduces a BodyInit tagged union covering FormData, URLSearchParams,
Blob, and bytes. A small extract() helper returns the serialized bytes
plus the spec-mandated default Content-Type (Fetch §6.5 step 8 / XHR
§4.7.6 step 4). Both Request.init and XMLHttpRequest.send apply the
default Content-Type only when the caller hasn't already set one.

Closes #2357
2026-05-04 15:08:52 +02:00
Pierre Tachoire
cf7dbc98de use v8 RegExp for Input.suffersPatternMismatch 2026-05-04 14:41:38 +02:00
Karl Seguin
112d4d1603 Merge pull request #2356 from lightpanda-io/cdp-audits
cdp: rename Audit into Audits
2026-05-04 19:03:35 +08:00
Pierre Tachoire
080e1e6415 cdp: rename Audit into Audits 2026-05-04 12:42:55 +02:00
Karl Seguin
6b896ba243 Merge pull request #2355 from lightpanda-io/worker_timers
Extract Window Scheduling and re-use it in Worker
2026-05-04 18:18:31 +08:00
Karl Seguin
d1bf44b686 Extract Window Scheduling and re-use it in Worker
Add worker.setInterval, clearInterval, setTimeout, clearTimeout by extracting
the scheduling logic from Window and making it use Execution rather than Frame.
2026-05-04 17:57:05 +08:00
Pierre Tachoire
5aa47f0837 Merge pull request #2354 from lightpanda-io/brew-AUR
README: add hombrew and AUR install
2026-05-04 11:42:07 +02:00
Pierre Tachoire
584d817d2e Merge pull request #2353 from lightpanda-io/remove-archlinux-pkg
ci: remove archlinux packaging
2026-05-04 11:40:43 +02:00