Commit Graph
9066 Commits
Author SHA1 Message Date
Karl Seguin c564e4e2db chore: Extract common Markdown/Screenshot logic
https://github.com/lightpanda-io/browser/pull/3333 improved markdown rendering
for flexbox items. But screenshot generation didn't benefit from that change.
This commit introduces a RenderTree that extracts and shares functionality
between markdown and screenshots.
2026-09-01 16:37:32 +08:00
Karl Seguin 1c12eb73a8 Merge pull request #3366 from lightpanda-io/ci-fix
cdp: remove race between terminate/disconnect
2026-09-01 12:35:05 +08:00
Karl Seguin a68697921e cdp: remove race between terminate/disconnect
A client that disconnects might get treated as a harsher terminate failure (e.g.
watchdog). This doesn't have a huge impact, but it makes the CI flaky and it
produces more logs than is necessary.

In a terminate state, the driver will now check its inbox to see if this is a
client disconnection.
2026-09-01 12:11:07 +08:00
Karl Seguin 053ea6aac0 Merge pull request #3331 from lightpanda-io/repl-markdown-render
agent: route REPL output per tool and align page tables of any size
2026-09-01 10:09:43 +08:00
Karl Seguin 4a8fb6c2f9 Merge pull request #3363 from lightpanda-io/bidi-e2e
ci: enable bidi protocol for all e2e tests
2026-09-01 10:05:58 +08:00
Karl Seguin 857a8ea643 ci: enable bidi protocol for all e2e tests 2026-09-01 09:51:27 +08:00
Karl Seguin 3bab59c6a4 Merge pull request #3209 from lightpanda-io/bidi
WebDriver BiDi
0.4.0
2026-08-31 23:06:33 +08:00
Adrià Arrufat d8e804cdb4 Merge branch 'main' into repl-markdown-render
# Conflicts:
#	src/agent/Agent.zig
2026-08-31 16:48:43 +02:00
Karl Seguin 731774ab67 ops: Allow serving both cdp and bidi on the same port
--protocol can now be specified multiple times. This just makes ops/dev easier
by only requiring 1 instance.
2026-08-31 22:45:15 +08:00
Karl Seguin 766c0d05d6 bidi: protocol selection CLI, start of [classic] WebDriver
In order to support Selenium the way people are used to, it looks  like we need
to support both WebDriver classic (WebDriver) and WebDriver BiDi (BiDi). Typical
scripts look like a mix of the two, e.g. using WebDriver to control the browser
and using BiDi  to receive notifications. This commit:

1 - adds a --protocol (cdp|webdriver) CLI argument to the `serve` command to
    enable one or the other protocol (defaulting to CDP)

2 - adds basic WebDriver endpoint to let a Selenium client connect. This
    implementation is hackish and sits on top of our simple Handshake handler.

The handshake handler is well past its original design. Serving /json/version
and /metrics from it was one thing. But Driving the entire browser session? This
will get a follow up PR.
2026-08-31 22:45:15 +08:00
Karl Seguin 5c0ed733d2 update v8 dep
Address various feedback, largely around potential uaf / double free  on error
cases
2026-08-31 22:45:15 +08:00
Karl Seguin 877316a3e8 bidi: user input 2026-08-31 22:45:14 +08:00
Karl Seguin a1f6382977 bidi: locateNodes 2026-08-31 22:45:14 +08:00
Karl Seguin 8aef077438 resolve pending bidi results 2026-08-31 22:45:14 +08:00
Karl Seguin deb1b936a1 metrics: cdp_* -> serve_* capture cdp vs bidi as serve_* labels 2026-08-31 22:45:14 +08:00
Karl Seguin a97e8ec43c bidi: basic script support 2026-08-31 22:45:14 +08:00
Karl Seguin 7c51dfff05 bidi: add skeleton for bidi
1. Abstract "Driver". Non-CDP things that referenced *CDP now reference a Driver
2. Move the NodeRegistry out of CDP. This created an artificial link between
   agent / mcp and CDP
3. Add BiDi driver with enough to navigate to a page
2026-08-31 22:44:59 +08:00
Karl Seguin 23891004dc Merge pull request #3327 from lightpanda-io/anchor-target-blank-popup
browser: open target=_blank links as popups and let tools follow them
2026-08-31 19:31:25 +08:00
Karl Seguin efb20f65b4 Merge pull request #3353 from lightpanda-io/body-client-dimensions
render: clientHeight/clientWidth returns the viewport for the body
2026-08-31 19:28:56 +08:00
Karl Seguin f4c8cd5fb2 Merge pull request #3354 from lightpanda-io/remove-duplicate-dupe
minor: remove potentially wasteful id dupe on removeId
2026-08-31 19:28:41 +08:00
Karl Seguin 3591aa575c Merge pull request #3356 from lightpanda-io/configure-http-version
cli: add --http-version 1.1 / auto flag
2026-08-31 18:51:45 +08:00
Karl Seguin 0250f77be6 Merge pull request #3357 from lightpanda-io/indexeddb-eager-serialization
indexeddb: serialize value at entry
2026-08-31 18:51:22 +08:00
Karl Seguin 8bf8532fb1 Merge pull request #3358 from lightpanda-io/cdp-network-enable-limits
CDP: enforce Network.enable limits
2026-08-31 18:51:09 +08:00
Karl Seguin 469677054c Merge pull request #3355 from rohitsux/fix/media-error-init
refactor(webapi): remove unused MediaError.init
2026-08-31 17:23:58 +08:00
Karl Seguin dad2ed42c9 CDP: enforce Network.enable limits
This enforces a limit on the captures responses based on the Network.enable's
maxTotalBufferSize and maxResourceBufferSize fields. It also limits the size of
the post body we echo (e.g. in requestWillBeSent) based on the `maxPostDataSize`
field.
2026-08-31 17:20:55 +08:00
Karl Seguin 89c217c610 indexeddb: serialize value at entry
When writing a value, we used to store js.Value.Global in the transaction's
queue and then serialize it at write-time. We're supposed to capture the value
at call-time. The result is that, if JS code alters the value, we can end up
storing the wrong value. We now serialize the value at call time, so that any
subsequent changes to the value are not captured by the operation.

Also improve how we map large integers. Because JavaScript can't represent the
full u64/i64, we need to treat large numbers as floats and truncate. This is
done both from JS -> Zig and from Zig -> JS.
2026-08-31 16:24:03 +08:00
Karl Seguin 7dd4496b0f cli: add --http-version 1.1 / auto flag
https://github.com/lightpanda-io/browser/issues/3348

When set to 1.1, libcurl is configured to only offer HTTP 1.1. By default, or
when set to "auto", it's up to libcurl to decide how to connect. This maps to
libcurl's CURL_HTTP_VERSION_1_1 and CURL_HTTP_VERSION_NONE.

LP.configureCDP now takes an `httpVersion` field which can be "1.1" or "auto"
to control that specific browser session. Ideally this is called prior to any
navigation.
2026-08-31 16:16:47 +08:00
Rohit d6952ec5a4 refactor(webapi): remove unused MediaError.init
MediaError.init had no caller and MediaError has no JS constructor
exposed (new MediaError() is not valid JS), so the helper was
unreachable dead code. It also had a latent bug: it passed a struct
VALUE to std.mem.Allocator.create, which expects a TYPE. That bug
never surfaced because Zig lazily skips analyzing unreferenced
function bodies.

Remove init per maintainer review, along with its now-unused Frame
import. HTMLMediaElement.error still returns null today, so this
does not change runtime behavior.

Verified: zig fmt --check clean, scoped build+test green (1 of 1,
the remaining constants test).
2026-08-31 13:44:58 +05:30
Adrià Arrufat 95e8dfa400 browser: make resolveTargetFrame's _blank explicit; submit target=_blank forms into a popup
resolveTargetFrame returned null for _blank, so every caller carried the
meaning of that null. It now returns a tagged union and callsites switch
on it. <form target=_blank> takes the same path as links: the popup is
opened only once the submission is going ahead, so validation or
preventDefault can't leave a stray window. The opener rule (withheld
unless rel=opener) lives in one Frame.openBlankTarget helper.

awaitQueuedNavigation took a frame id, but Runner waits are keyed by
Page root, so a followed popup's id resolved to FrameNotFound and every
navigation from inside a popup failed. It now takes the Frame and waits
on its Page root, read before processing since a synthetic root
navigation frees the Page in place.
2026-08-31 09:32:59 +02:00
Karl Seguin c8c54f2067 minor: remove potentially wasteful id dupe on removeId
We currently unconditionally dupe the remove_ids key. But it _could_ already
exist in the map. Swapping the unconditional put with a getOrPut.
2026-08-31 14:55:43 +08:00
Karl Seguin 482d0951a0 render: clientHeight/clientWidth returns the viewport for the body
Meant to improve https://github.com/lightpanda-io/browser/issues/3251

There's a script on taobao and tmall which tries to tile the visible porition
or the root element. Well, the root element's fake height is 100,000,000 so the
page stalls.

This changes is so that the body's clientHeight/Width returns the viewport
dimensions.
2026-08-31 12:37:37 +08:00
Karl Seguin fad4b97079 Merge pull request #3343 from staylor/fix/errored-module-reimport
js: reject module evaluation before instantiation
2026-08-31 12:24:08 +08:00
Karl Seguin 1d813f7602 Merge pull request #3345 from lightpanda-io/robots-telemetry
telemetry: track if --obey-robots is used
2026-08-31 12:21:00 +08:00
Karl Seguin a0718e0d2a Continue to fail in DEBUG
Log err in release.
2026-08-31 11:41:45 +08:00
Karl Seguin dfaf8679c5 Merge pull request #3342 from staylor/fix/macos-framework-sdk
build: honor macOS SDK root for frameworks
2026-08-31 08:51:51 +08:00
Karl Seguin fdd092bb2e Merge pull request #3333 from lightpanda-io/markdown-flex-separators
markdown: separate flex and grid items in the dump
2026-08-31 07:55:40 +08:00
Karl Seguin e7e160f39b Merge pull request #3344 from lightpanda-io/fix-readablestream-cross-context
crash: fix null dereference when ReadableStream is used cross-context
2026-08-31 07:53:36 +08:00
Adrià Arrufat 24bf00cf3b markdown: optimize element rendering by removing duplicate checks 2026-08-30 21:38:25 +02:00
Karl Seguin e00108260f telemetry: track if --obey-robots is used
Re-purposes the "proxy" integer as a CLI bitmask flag. Requires a server update.
2026-08-30 14:10:40 +08:00
Karl Seguin 983950a75a crash: fix null dereference when ReadableStream is used cross-context
ReadableStream's assumed collectBodyBytes was being called on the same context
that it was created, so that in a cross-context call, the expected LocalScope
was null. This creates an explicit local scope.

Fixes crash on WPT /service-workers/service-worker/fetch-event.https.h2.html
2026-08-30 11:32:22 +08:00
Scott Taylor 05a56ece91 js: reject module evaluation before instantiation
Assisted-By: devx/6fc48df3-67c4-46f2-9e14-98e4ac4bc21d
2026-08-29 12:53:19 -04:00
Scott Taylor 8072fc0827 build: honor macOS SDK root for frameworks
Assisted-By: devx/6fc48df3-67c4-46f2-9e14-98e4ac4bc21d
2026-08-29 12:28:29 -04:00
Karl Seguin 27831c20bf Merge pull request #3341 from lightpanda-io/remove-debug-unknown-property
debug: remove unknown property logging
2026-08-29 17:18:30 +08:00
Karl Seguin 78a96ff0aa Merge pull request #3340 from lightpanda-io/remove-cdp-runtime-log
chore: remove debug-only CDP runtime disk-logging
2026-08-29 17:18:22 +08:00
Karl Seguin 9f68f0314c Merge pull request #3338 from lightpanda-io/xhr-blog-content-type
webapi: Report correct content-type for blob
2026-08-29 17:18:11 +08:00
Karl Seguin ed949ebbfc Merge pull request #3337 from lightpanda-io/fix-element-unsafe-cast
crash: fix unsafe element cast
2026-08-29 17:18:00 +08:00
Karl Seguin 5d5459fc8b Merge pull request #3339 from lightpanda-io/lower-MAX_VmHWM
CI: Lower MAX_VmHWM to 24 (down from 28)
2026-08-29 12:32:48 +08:00
Karl Seguin eabc865338 debug: remove unknown property logging
Commented it out for now, but plan on remove the code at some point in the
future. This was useful when sites would break because of an unimplemented
API, but (a) those are rare now and (b) AI is good at finding issues without
this. As-is, it just makes --log-level debug useless in Debug builds. The
logging could never tell between an site-specific global and a real API, and
sites have _a lot_ of globals, so it's a lot of noise.
2026-08-29 12:01:00 +08:00
Karl Seguin 28180bc9df chore: remove debug-only CDP runtime disk-logging 2026-08-29 11:56:18 +08:00
Karl Seguin 313803c354 CI: Lower MAX_VmHWM to 24 (down from 28)
orderfile PRs (https://github.com/lightpanda-io/browser/pull/3271 and
https://github.com/lightpanda-io/browser/pull/3285) has dropped memory usage to
~23.6. Rather than hitting 28MB in 2-3 months time and not knowing how we got
there, I'd rather get slow/incremental notices.
2026-08-29 11:41:12 +08:00