Commit Graph
16 Commits
Author SHA1 Message Date
Karl Seguin 07198b71ff fix comments 2026-09-02 07:28:25 +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 0b3e75ca08 Merge pull request #3361 from lightpanda-io/cdp-urlpattern
cdp: support request interception patterns
2026-09-02 07:13:02 +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 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 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
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