Commit Graph
7394 Commits
Author SHA1 Message Date
Karl Seguin 07198b71ff fix comments 2026-09-02 07:28:25 +08:00
Halil Durak add8a8c003 Cookie: getter/setter changes for site-for-cookies
Also updates matchCookies/onCookieChanged from the hard-coded "same-site + navigation" to areSameSite(exec.siteForCookies(), host) and is_navigation=false.
2026-09-02 07:19:39 +08:00
Halil Durak 9ddf6ad02a Worker: inherit site-for-cookies from the creating document 2026-09-02 07:19:39 +08:00
Halil Durak 87308b5e23 compute site-for-cookies from ancestor chain of a Frame
The site for cookies were computed from the immediate parent `Frame`, which would allow sending a cookie that's `SameSite=Strict` from 2 levels deep under. Directly from RFC6265bis, this PR essentially implements (except for step 4, we skip host-less ancestors):

   Given a Document (document), the following algorithm returns its
   "site for cookies":

   1.  Let top-document be the active document in document's navigable's
       top-level traversable.

   2.  Let top-origin be the origin of top-document's URI if top-
       document's sandboxed origin browsing context flag is set, and
       top-document's origin otherwise.

   3.  Let documents be a list consisting of the active documents of
       document's inclusive ancestor navigables.

   4.  For each item in documents:

       1.  Let origin be the origin of item's URI if item's sandboxed
           origin browsing context flag is set, and item's origin
           otherwise.

       2.  If origin is not same-site with top-origin, return an origin
           set to an opaque origin.

   5.  Return top-origin.
2026-09-02 07:19:35 +08:00
Karl Seguin 3befda2acc Merge pull request #3360 from lightpanda-io/indexeddb-better-errors
indexeddb: Improve error handling
2026-09-02 07:13:24 +08:00
Karl Seguin 0b3e75ca08 Merge pull request #3361 from lightpanda-io/cdp-urlpattern
cdp: support request interception patterns
2026-09-02 07:13:02 +08:00
Karl Seguin b852b7b89a Merge pull request #3380 from lightpanda-io/RenderTree
chore: Extract common Markdown/Screenshot logic
2026-09-02 07:12:29 +08:00
Karl Seguin 4df0b5e5a3 Merge pull request #3374 from lightpanda-io/webapi-small-accessors
webapi: Headers.getSetCookie, customElements.getName, Element.part
2026-09-01 19:11:58 +08:00
Karl Seguin 41ae39789b zig fmt 2026-09-01 18:52:58 +08:00
Karl Seguin 96de22fc0a webapi: enhance header to block forbidden response headers 2026-09-01 18:51:39 +08:00
Karl Seguin d663afc0ee Merge pull request #3379 from lightpanda-io/input-value-as
webapi: input valueAsNumber, valueAsDate, stepUp/stepDown, showPicker
2026-09-01 18:43:32 +08:00
Karl Seguin 40fb080509 Merge pull request #3370 from lightpanda-io/svg-ctm
webapi: SVGGraphicsElement.getCTM and getScreenCTM
2026-09-01 18:13:54 +08:00
Adrià Arrufat 20ac0baa99 webapi: match browsers for step, time strings, empty patterns and tooLong
Checked the three test files in Firefox and Chrome:
- stepUp/stepDown use the HTML step base (min, else the value attribute)
  and snap off-ladder values to the next rung, counting the snap as the
  first step as browsers do; clamping lands on the last rung inside
  min/max.
- time strings keep a three-digit fraction.
- an empty pattern attribute is a pattern (matches only "").
- tooLong/tooShort only for values last changed by a user edit, so the
  text-entry path marks the value and script/attribute values never trip
  them; same for textarea.
- showPicker dropped: browsers throw NotAllowedError without a gesture,
  a no-op would be a lie.
- month/week assertions skipped where the browser has no such input.
2026-09-01 12:09:49 +02:00
Karl Seguin ddb0dc09b9 Merge pull request #3377 from lightpanda-io/image-decode
webapi: img.decode()
2026-09-01 17:21:23 +08:00
Karl Seguin 9d2b3cf456 Merge pull request #3376 from lightpanda-io/disabled-fieldset-state
webapi: a disabled fieldset disables its controls' activation and validation
2026-09-01 17:21:12 +08:00
Karl Seguin 17dde356f4 add option and optgroup to controls we need to check disabled on 2026-09-01 17:05:55 +08:00
Karl Seguin 8e9ecb4a64 Merge pull request #3375 from lightpanda-io/option-selected-single
webapi: option.selected = true deselects its siblings in a single select
2026-09-01 16:56:46 +08:00
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
Adrià Arrufat 396ec5fe18 webapi: input valueAsNumber, valueAsDate, stepUp/stepDown, showPicker
react-hook-form and date pickers read valueAsNumber/valueAsDate and got
undefined. The date types convert through the existing validators; the
same conversion now also drives min/max range validation for
date/time/month/week/datetime-local, which only number/range had.
2026-09-01 10:36:54 +02:00
Adrià Arrufat db64ced3fb webapi: img.decode()
Missing, so Next.js <Image> and React lazy images threw TypeError. No
decoding happens, so it resolves once the element exists.
2026-09-01 10:21:57 +02:00
Adrià Arrufat 33befd7caf webapi: a disabled fieldset disables its controls' activation and validation
click(), willValidate and the WebDriver click read only the control's own
attribute. They now use Element.isDisabled, which already walks fieldset
ancestors with the first-legend exception for :disabled. The disabled IDL
attribute keeps reflecting the attribute alone, per spec.
2026-09-01 10:21:20 +02:00
Adrià Arrufat 68e11c57f2 webapi: option.selected = true deselects its siblings in a single select
Two options ended up selected and select.value reported the stale one;
form-filling agents got silently wrong data.
2026-09-01 10:20:06 +02:00
Adrià Arrufat 223a7ef728 webapi: Headers.getSetCookie, customElements.getName, Element.part
Three one-accessor gaps: getSetCookie returns Set-Cookie values
unjoined, getName maps a constructor back to its tag, part is a
DOMTokenList over the part attribute like relList.
2026-09-01 10:17:14 +02:00
Adrià Arrufat 73b4dd09ac webapi: SVGGraphicsElement.getCTM and getScreenCTM
Composes transform attributes up to the nearest <svg> (getCTM) or through
every enclosing <svg>, offset by the outermost one's client rect
(getScreenCTM). Null when detached. d3-zoom, d3-brush and svg-pan-zoom
call these at init and threw.
2026-09-01 10:11:26 +02:00
Adrià Arrufat 18b0a0f479 webapi: navigator.sendBeacon returns true
The body returned true (#2821) but .noop made the bridge skip it, so JS
saw undefined and took the synchronous XHR fallback it guards against.
2026-09-01 10:07:41 +02:00
Karl Seguin 9c83bf3ef9 log: allow 'note' to be silence, log CLI tips
We currently have 1 note: it prints the server's listening address:port. Note
is a special un-ignorable level. This keeps the "note" level, but logs it under
a new scope: "note", so that it _can_ be silenced with a `--log-filter note`.

Add a new note, on startup, that displays tips. Currently, only displays when
--obey-robots is not enabled:

NOTE  note : config tips . . . . . . . . . . . . . . . . . . . [+0ms]
      robots = use '--obey-robots' to use a sites robots.txt
      meta = use '--log-filter note' to silence this message
2026-09-01 12:35:56 +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 a48cc7d643 indexeddb: Improve error handling
Three  small compliance (WPT) changes with respect to error handling.

1. When a unique index creation fails due to a constraint violation, the
   delivery of that failure is asynchronous.

2. When txn.abort() is called, any undelivered request should be aborted
   asynchronously (see the common theme here?)

3. An failure in an onupgradeneeded handler correctly fires an AbortError AND
   rollsback the version
2026-09-01 10:08:08 +08:00
Karl Seguin b7d790561f cdp: support request interception patterns
The Fetch.enable call takes `patterns` which can limit the path and type of
request that should be intercepted. This adds the wildcard support.

As before, RI is currently only enabled for Requests, not response. A warning
is printed if RI for responses is requested.

Fixes: https://github.com/lightpanda-io/browser/issues/3349
2026-09-01 10:06:55 +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