Commit Graph

6690 Commits

Author SHA1 Message Date
Karl Seguin
3143b6e519 On Illegal Constructor, try to capture name (for logs)
Just improves the log a little to try and capture the name of what was
constructed. We see this often in WPT tests, which is probably WPT testing the
illegal constructor behavior, but it's hard to be sure. Having the name logged
gives us enough detail to see if the behavior is correct or not.

Also, downgraded the log level from warn -> info.
2026-05-07 10:29:53 +08:00
Karl Seguin
5615ba762d Give setters an arity of 1
Static functions don't take a 'self' so their arity isn't + 1.

Fixes a handful of IDL test cases.
2026-05-07 10:11:56 +08:00
Karl Seguin
5a0c7eff66 Protect assertion when reload from about:blank
(and hopefully all other cases) where a commit happens on a previously blank
slate.
2026-05-07 09:14:07 +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
2de56622d5 Track DOM version on the page
This is a follow up to https://github.com/lightpanda-io/browser/pull/2365 which
implements a different fix with different performance tradeoffs.

To recap, #2365 fixed an issue where the frame used to track the dom version
was the frame here the JS was being executed, not necessarily where the node
existed. This would cause the caching to break. #2365 fixed this by always
using the node's frame. But this is relatively expensive, requiring that we
find the owning document of a node in order to get its frame. This traversal
has to happen on every dom manipulation (to update the version) and every cached
read (to verify the dom version hasn't changed). We _could_ store the owning
frame on every Node, but that's relatively memory expensive to do.

This commit moves the dom version from the Frame to the Page. This allows us
to use the executing Frame to get the page (`frame._page`) which is much faster
than traversing the parent nodes to find the document. The downside is that a
mutation in Frame1 will invalidate the cache in Frame2. Given that many sites
have a single frame, this seems like a clear win.
2026-05-07 08:14:03 +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
Pierre Tachoire
7df0f8d5d5 cdp: use a specific enum for console message 2026-05-06 19:15:44 +02:00
Pierre Tachoire
d6c9a5fb83 cdp: add runtime.consoleAPICalled 2026-05-06 18:34:30 +02:00
Pierre Tachoire
2c28023168 implement jsonStringify for js.Value 2026-05-06 18:34:29 +02:00
Pierre Tachoire
595b774f1d cdp: implement Console.messageAdded event 2026-05-06 18:34:29 +02: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
c3fe5346c2 cdp: add console enable/disable commands 2026-05-04 14:59:17 +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