Commit Graph
7854 Commits
Author SHA1 Message Date
Celine Debled 431e41f865 cdp: report the initial about:blank as loaded to lifecycle events 2026-09-22 16:47:47 +02:00
Karl Seguin d873e1bd7b Merge pull request #3595 from cdebled/cdp-reply-session-id
cdp: echo the sessionId in replies to browser-level commands
2026-09-22 20:11:07 +08:00
Celine Debled ce5f6195db cdp: test that replies echo the sessionId 2026-09-22 12:28:37 +02:00
Celine Debled c98afa4beb cdp: echo the sessionId in replies to browser-level commands 2026-09-22 12:28:37 +02:00
Karl Seguin b84e5b7397 Merge pull request #3591 from lightpanda-io/dont-reuse-bad-connections
http: dont' re-use connections which are likely in a bad state.
2026-09-22 15:43:30 +08:00
Karl Seguin 239a7937e0 Merge pull request #3592 from lightpanda-io/element-focus
webapi: element.focus() only on focusable elements
2026-09-22 15:04:28 +08:00
Karl Seguin 92c48a68a7 Merge pull request #3534 from lightpanda-io/wasm-streaming
Implement WebAssembly.compileStreaming and instantiateStreaming
2026-09-22 14:19:52 +08:00
Adrià Arrufat 6209893a5b wasm: don't re-enter V8 when an exception is already pending
TryCatchRethrow, JsException and ExecutionTerminated all mean V8 already
has something pending: creating an error value and aborting the stream
would replace the exception the script is meant to see, or hand a killed
script a catchable Error. Drop the streaming handle instead, matching the
early exit in Caller.handleError.
2026-09-22 07:53:44 +02:00
Karl Seguin 0ffca7fa0a webapi: element.focus() only on focusable elements
Element.focus() would "focus" the element even when it shouldn't. We already
have the logic to determine if an element is focusable in `user_input.zig`, so
this was moved to Element and is now used in el.focus().
2026-09-22 11:25:52 +08:00
Karl Seguin 0b66a5ed05 http: dont' re-use connections which are likely in a bad state.
Some status-codes should never have a body except for a single trailing blank
line. If we don't handle these, then we end up with a dirty connection in our
connection pool:

1 - read the header, but not the body
2 - put the connection back in the pool
3 - try to read the header, but actually get the body from #1

WPT /fetch/api/basic/response-null-body.any.html exercises this path and is
flaky (because it depends whether the request goes back out on a keep-alive
connection)..but for a given run,you'll almost always get 1-3 failures.

This commit processes the request, but tells libcurl not to re-use the
connection.
2026-09-22 10:08:41 +08:00
Karl Seguin e96c31f157 Merge pull request #3572 from lightpanda-io/nikneym/cdp-isolated-world-origin
`cdp`: move a kept isolated-world context onto the navigated origin
2026-09-22 07:47:46 +08:00
Karl Seguin 709567e2d8 Merge pull request #3585 from lightpanda-io/webdriver-element
webdriver: add element endpoints
2026-09-22 07:47:06 +08:00
Karl Seguin d3262ada54 Merge pull request #3583 from lightpanda-io/improved-cache
http: improve caching
2026-09-21 21:36:47 +08:00
nikneym 238d4a53a3 cdp: move a kept isolated-world context onto the navigated origin 2026-09-21 16:28:00 +03:00
Karl Seguin dba2fdf5fc Merge pull request #3578 from lightpanda-io/response-null-body
webapi: improve fetch/response correctness with null bodies
2026-09-21 18:56:12 +08:00
Karl Seguin 6b28f986e6 Merge pull request #3586 from lightpanda-io/webdriver-http-limit
webdriver: increase http default / max limit
2026-09-21 18:55:53 +08:00
Karl Seguin 7f3cf5793f cache use s-maxcache only to reduce total cache time
Tricky since we act as both the user agent and a shared cache. This is the
safest of the two.
2026-09-21 18:52:13 +08:00
Karl Seguin ee4d54928d webdriver: increase http default / max limit
The http max default was 4K with a 16KB hard limit. The default limit is now 1MB
with an initial default of 4K. This is to accommodate larger WebDriver payloads.
2026-09-21 17:52:41 +08:00
Karl Seguin 735ae57f16 Merge pull request #3577 from lightpanda-io/type-error-helper
chore: move more cases to new typeError helper
2026-09-21 16:48:25 +08:00
Karl Seguin af47d524f2 Merge pull request #3576 from lightpanda-io/xhr-wpt
webapi: correct error on wrong method, guard headers
2026-09-21 16:08:47 +08:00
Karl Seguin 9de057ffa2 Merge pull request #3575 from lightpanda-io/lang-selector
webapi: remove "en" lang fallback
2026-09-21 16:08:33 +08:00
Karl Seguin 9f443e13d2 Merge pull request #3573 from lightpanda-io/iterative-dump
mem: Make dump iterative
2026-09-21 15:57:51 +08:00
Karl Seguin 09a0d580c9 verify js.Value is object before trying to taggedOpaque() 2026-09-21 15:42:49 +08:00
Pierre Tachoire d9bcf1a961 Merge pull request #3492 from lightpanda-io/nikneym/netscape-cookie-format
`cookies`: accept Netscape cookie format in `--cookie` argument
2026-09-21 09:04:52 +02:00
Karl Seguin a8e43777f5 webdriver: add element endpoints
Follows https://github.com/lightpanda-io/browser/pull/3552 to add various
element endpoints. Total of 13 new endpoints were added, including a slightly
fancier router to deal with variables in URLs.

```
$ curl -X POST "http://localhost:9222/session" --data '{}'
{"value":{"sessionId":"248378f2-bc8d-4cb5-8aaf-3ec4193c5a9e","capabilities":{"acceptInsecureCerts":false,"browserName":"Lightpanda","browserVersion":"1.0.0-dev.9605+475ed9ae7","platformName":"linux","setWindowRect":false,"userAgent":"Lightpanda/1.0","proxy":{}}}}⏎                        ~/c/p/browser2]

$ curl -X POST "http://localhost:9222/session/248378f2-bc8d-4cb5-8aaf-3ec4193c5a9e/url" --data '{"url": "https://lightpanda.io"}'
{"value":null}

$ curl -X POST "http://localhost:9222/session/248378f2-bc8d-4cb5-8aaf-3ec4193c5a9e/element" --data '{"using":"css selector","value":"h1"}'
{"value":{"element-6066-11e4-a52e-4f735466cecf":"1"}}

$ curl -X GET "http://localhost:9222/session/248378f2-bc8d-4cb5-8aaf-3ec4193c5a9e/element/1/text"
{"value":"The first browserfor machines, not humans"}
```

First two already existed, last two are new.
2026-09-21 14:57:03 +08:00
Karl Seguin 3213342055 http: improve caching
1 - Centralized cache-awareness into Cache and pulled header details out of
    SqliteCache and HttpClient

2 - Added support for expires header

3 - Support caching more status types (but not all, since HttpClient would need
    to be aware of what caching a 3xx/206 means)

4 - Revalidate cares about  "not specified" vs "no-store" vs "stale"
    (e.g. expires=0 means "stale", not fallthrough the last-modified logic)
2026-09-21 11:38:34 +08:00
Karl Seguin d28d37be92 webapi: improve fetch/response correctness with null bodies
Responses with specific status (e.g. 204) should always have a null body. Also
adds validation to Response constructor (e.g. can't provide an invalid status).

Improves a handful of WPT tests:

fetch/api/response/response-error.any.html
fetch/api/response/response-static-json.any.html
2026-09-19 13:38:12 +08:00
Karl Seguin 856d62183a chore: move more cases to new typeError helper
https://github.com/lightpanda-io/browser/pull/3403 added a typeError helper and
this commits moves a few more callers to it.
2026-09-19 12:18:14 +08:00
Karl Seguin 7b6bb7b269 webapi: correct error on wrong method, guard headers
Return TypeError on an invalid method and guard against invalid headers. This
2nd change just uses the guards added in https://github.com/lightpanda-io/browser/pull/3460
from XHR.

Fixes a handful of cases, e.g. /fetch/api/request/forbidden-method.any.html
2026-09-19 10:02:28 +08:00
Karl Seguin 475ed9ae73 webapi: remove "en" lang fallback
The "en" css fallback on document. I tested a number of pages, and pages with
no lang attribute return null on a `:lang('en')` query.
2026-09-19 09:47:42 +08:00
Karl Seguin 7cb98ad977 webapi: more accurate window.isSecureContext
Previously, our window.isSecureContext was hard-coded to false. This commit
(a) reports the correct value and (b) disables [some] secure-context-only APIs
in a non-secure context. This change is somewhat related to the ongoing Service
Worker work and will need to be adjusted accordingly, e.g. when #3562 lands,
the Cache will need to be disabled when isSecureContext == false.
2026-09-19 07:28:14 +08:00
Karl Seguin 923a270d9c mem: Make dump iterative
Inspired by https://github.com/lightpanda-io/browser/pull/3500 this switches
the dump from recursive to iterative. Huge DOMs no longer stack overflow.
2026-09-19 07:19:26 +08:00
Karl Seguin ae928a91b1 Merge pull request #3568 from lightpanda-io/speedup-unit-tests
dev: speedup unit tests
2026-09-19 07:13:56 +08:00
Karl Seguin 268931092b Merge pull request #3566 from lightpanda-io/CDP-frame-ownership
internal: CDP Node / Element frame ownership
2026-09-19 07:13:45 +08:00
Karl Seguin 21ca960dd6 Merge pull request #3564 from lightpanda-io/fetch-metadata
webapi: include Sec-Fetch-Site and Sec-Fetch-Mode headers
2026-09-19 07:13:28 +08:00
Karl Seguin ff3116432d Merge pull request #3562 from lightpanda-io/service-worker-cachestore
WebApi: Add Cache/CacheStore when ServiceWorker is enabled
2026-09-19 07:13:16 +08:00
Halil Durak e67301a0fb cookies: accept Netscape cookie format when loading from CLI 2026-09-18 17:19:21 +03:00
Adrià Arrufat dcc90d60c9 cdp: emit frameId on the document element, not the document node
Chrome sets frameId on frame-owner elements and on the element whose
parent is the document, never on the document node itself.
2026-09-18 10:00:37 +02:00
Adrià Arrufat acb6b835fe cdp: DOM.getFrameOwner returns the owner <iframe>, nodes carry frameId
DOM.getFrameOwner answered with the child frame's document instead of the
element hosting it. Clients that map an <iframe> to its frame compare the
backendNodeId it returns with the one they resolved in the parent
(Stagehand's frameLocator/deepLocator, Playwright's contentFrame), so the
lookup never matched and they could not descend into frames.

Return the owner element, as Chrome does, and error for the main frame.
The node writer now emits frameId on frame-owner elements and on document
nodes, which is the other half of that pairing.
2026-09-18 10:00:37 +02:00
Adrià Arrufat e56045f4bf Merge pull request #3560 from lightpanda-io/agent-repl-simplify
agent: REPL output fixes and command dispatch simplification
2026-09-18 09:51:49 +02:00
Karl Seguin e2299e2c05 dev: speedup unit tests
Directly improve a couple slow tests (crash_handler actually generating crash
dumps on some systems, e.g. mine). The runWebApiTest prefers to poll for work
when possible rather than a blind sleep -> check loop. (e.g. if we have
websocket connections, prefer an http tick).

For me, it's 22s -> 17s.
2026-09-18 15:17:39 +08:00
Karl Seguin b3684847a8 internal: CDP Node / Element frame ownership
Continuation of cleaning up frame ownership (#3549, #3536, #3520, ...).

Element.blur/focus are noop on a frameless element.

AXNode.Writer rejects frameless nodes. DOM.resolveNodes keeps its fallback
bacause it's stateless - just needs the context.
2026-09-18 13:14:28 +08:00
Karl Seguin f70705b2ce webapi: include Sec-Fetch-Site and Sec-Fetch-Mode headers 2026-09-18 12:34:19 +08:00
Karl Seguin 50c4f52df8 fix build for wpt_extensions 2026-09-18 11:11:36 +08:00
Karl Seguin b43c6087b7 WebApi: Add Cache/CacheStore when ServiceWorker is enabled
This adds the Cache and CacheStore APIs when ServiceWorker is enabled. Purely
in-memory, tied to the Session's lifetime. These generally don't do unbounded
growth, but simply load a fixed set of resources.

In firefox, when ServiceWorker is disabled, the cache is still available on the
Window. I tied it to the existing --experimental-features serviceworker flag
(at least for now).
2026-09-18 09:20:47 +08:00
Karl Seguin 6db04f694a Merge pull request #3548 from lightpanda-io/img-srcset
webapi: img srcset support
2026-09-18 08:04:21 +08:00
Karl Seguin 790a6e5bb9 hook up child srcset when created via fragment parser 2026-09-18 06:49:58 +08:00
Adrià Arrufat 290e4f81d9 agent: simplify REPL command dispatch and provider bookkeeping
- `available_providers` holds the static enum tag names; drop the dupe
  loop, its errdefer and the per-string frees.
- `reconcileModel` returns `error.ModelNotAvailable` directly instead of
  a `use`/`abort` union the caller only mapped to that same error.
- `runCommand`/`printCommandResult` take `Command.ToolCall`; the caller
  already has it, so the unreachable "no tool mapping" branches go.
- `handleSave` reuses `rememberSavePath`, which now propagates its
  allocation failure so a first save under OOM warns instead of
  unwrapping a null `save_path`.
- `SlashCommand.all_names` is a comptime `++` of the three name lists.
- `buildUserMessageParts` reads the attachment once for both text and
  image, and prepends the text part instead of copying the list.
- `printSeverity`/`formatBulletLine` use `allocPrint` and the shared
  `emitStderr`; drop an unreachable `ends_ws` check in `renderMetaHint`.
2026-09-18 00:45:55 +02:00
Adrià Arrufat 9b7225b580 agent: don't drop REPL tool lines or cut result text mid-codepoint
In a REPL whose stderr isn't a tty the spinner is disabled, so
`agentToolDone`'s `emitAbove` returned false and the `● [tool: …]` line
was discarded. `printToolOutcome` already fell back to a raw stderr write
in that case; share that fallback through `emitStderr`.

The non-REPL result line sliced `text` at a byte offset, which could
split a multi-byte codepoint and emit garbage. Truncate on a UTF-8
boundary instead.
2026-09-18 00:44:49 +02:00
Karl Seguin dbe6271479 Merge pull request #3559 from lightpanda-io/fix-preload-import-build
ScriptManagerBase: fix main build after #3485/#3543 merge
2026-09-18 06:31:24 +08:00