7563 Commits

Author SHA1 Message Date
Karl Seguin
34ccdb11aa Merge pull request #2812 from lightpanda-io/agent-quickjs
agent: use QuickJS
2026-06-26 08:55:03 +08:00
Karl Seguin
8bc42e82cc only defer promise funcs on non-exception 2026-06-26 08:40:03 +08:00
Francis Bouvier
90e1a6e6d8 agent: use QuickJS 2026-06-24 17:54:14 +02:00
Karl Seguin
9d0c453893 adjust v8 snapshot path 2026-06-23 12:17:55 +08:00
Karl Seguin
5d75abb390 manually merge in de5b9364e6 2026-06-22 17:24:40 +08:00
Karl Seguin
ec1b37f67d new quickjs hooks for tool/agent additions 2026-06-22 17:11:12 +08:00
Karl Seguin
142bc87829 WIP: Add QuickJS as JS engine option (via build-time switch) 2026-06-22 17:11:11 +08:00
Pierre Tachoire
f61d16aa49 Merge pull request #2664 from rohitsux/feat/cdp-set-device-metrics
feat(cdp): honor viewport in Emulation.setDeviceMetricsOverride
2026-06-22 07:12:23 +00:00
Karl Seguin
39f9792bac Merge pull request #2785 from lightpanda-io/innerText
webapi: Improve innerText, add outerText
2026-06-21 08:23:55 +08:00
Karl Seguin
04e1b13af2 Merge pull request #2788 from lightpanda-io/popup_close_lifetime
uaf: Extend closed popup's lifetime from Frame to Page
2026-06-21 08:23:40 +08:00
Rohit
8580f92488 feat(cdp): honor viewport in Emulation.setDeviceMetricsOverride
Now that #2694 centralized the default viewport, store an optional override
on the Page and have every viewport consumer read it through
Page.getViewport(): window.innerWidth/innerHeight, screen.width/height/
availWidth, visualViewport.width/height, Page.getLayoutMetrics, the
IntersectionObserver root rect, and matchMedia / the StyleManager media
cascade. This keeps the viewport consistent across all of them instead of
the split-brain a single-property override would create.

Emulation.setDeviceMetricsOverride writes the override (a 0 width or height
keeps that dimension, per the CDP default); clearDeviceMetricsOverride resets
to the default. Not-yet-emulated params (deviceScaleFactor, mobile, scale,
screenWidth/Height) are accepted but logged as not_implemented.
2026-06-20 07:18:12 +05:30
Karl Seguin
6aa4d50b33 webapi: Improve innerText, add outerText
Aimed at improving correctness of the innerText getter and setter. Driven by a
number of WPT tests, largely in html/dom/elements/the-innertext-and-outertext-properties/

Meant as a replacement for (1). Though, unlike that PR, this commit does not
consider CSS at all (todo in a follow up PR). The change just to get correct
space handling is big enough on its own. The short version is that, as we
traverse the children, we need to keep various state in order to (for example)
avoid double whitespace. Table cells and rows need their own special handling
(tabs and newlines inserted between items), pre needs to preserve whitespace,
etc.

This also adds outerText which, for the getter, is identical to innerText and
for the setter, can reuse Element.replaceWith, except for special whitespace
handling at its edges.

(1) https://github.com/lightpanda-io/browser/pull/2741
2026-06-20 08:37:41 +08:00
Karl Seguin
e9bbf95cf5 Merge pull request #2787 from lightpanda-io/frame_breakup
cleanup: Break various frame behavior into their own little utility f…
2026-06-20 07:09:00 +08:00
Pierre Tachoire
5d62fdc0fc Merge pull request #2773 from lightpanda-io/internal-request-flag
Internal Flag on Request
2026-06-19 15:18:02 +00:00
Pierre Tachoire
a808386c76 Merge pull request #2722 from Ar-maan05/feat-cdp-download-behavior-2701
feat(cdp): implement Browser.setDownloadBehavior file downloads
2026-06-19 12:57:42 +00:00
Pierre Tachoire
0f5ee79a1b Download events mustn't send session id 2026-06-19 14:31:40 +02:00
Pierre Tachoire
1f85ff1653 cdp: return session id with Browser.setDownloadBehavior 2026-06-19 11:51:42 +02:00
Armaan Sandhu
ab4d702445 address review: Browser-only download events, Header param parsing, real url/basename, deny default 2026-06-19 11:51:41 +02:00
Armaan Sandhu
8e8a9b2213 fix(cdp): make Browser.setDownloadBehavior a no-op without a loaded context
Playwright sends Browser.setDownloadBehavior at the browser level during
connection setup, before any target/context exists. Returning an error there
aborted the whole connection, failing every playwright demo-runner test.
Treat the no-context case as a success no-op, matching the prior behavior.
2026-06-19 11:50:31 +02:00
Armaan Sandhu
8ba54850db feat(cdp): implement Browser.setDownloadBehavior file downloads
Browser.setDownloadBehavior was a noop, so Lightpanda had no file-download
path. A response with Content-Disposition: attachment is now streamed to disk
under downloadPath, and Page.downloadWillBegin / Browser.downloadProgress are
emitted when eventsEnabled.

Fixes #2701
2026-06-19 11:50:29 +02:00
Karl Seguin
de046cec36 Merge pull request #2784 from lightpanda-io/agent-task-save
agent: add --save flag to synthesize scripts from tasks
2026-06-19 17:27:09 +08:00
Adrià Arrufat
98a5458205 agent: allow paths in --save option 2026-06-19 07:46:42 +02:00
Karl Seguin
36fec926cc guard against post-close navigate 2026-06-19 13:01:42 +08:00
Karl Seguin
762e21a8f3 uaf: Extend closed popup's lifetime from Frame to Page
Follow up to https://github.com/lightpanda-io/browser/pull/2742

Where 2742 dealt with window-reuse across navigation, this commit addresses
window lifetime after a .close() (so, specifically for popups). I was hoping for
a fancier solution which would let us maintain eager release with safety, but
instead opted for the much simpler "window lifetime is tied to the page".

There's a couple reasons for this. It _is_ more consistent with how everything
else works (Workers, and iframes), but the real reason is that we lack the
infrastructure to do this safely/cleanly.
2026-06-19 11:43:18 +08:00
Karl Seguin
de5b9364e6 cleanup: Break various frame behavior into their own little utility files
This is purely mechanical and was driven almost entirely by Claude. The goal is
simply to break Frame.zig into small / more cohesive components. So instead of
having ~10 observer-specific methods on Frame, they now live in Frame.observers.

In general, our code always takes *Frame as the last parameter (a consequence
that this is the easiest / less ambiguous way to auto-inject a Frame into a
webapi). But, for these, I kept it as the first parameter because it's still
the "receiver" even though the dot syntax isn't applicable.
2026-06-19 10:11:17 +08:00
Karl Seguin
6b42cad3db Merge pull request #2727 from rohitsux/feat/cdp-browser-permissions
feat(cdp): honor Browser.grantPermissions / setPermission / resetPermissions
2026-06-19 07:49:41 +08:00
Rohit
a0fc38eb6d fix(cdp): store permissions at the browser level
Address review: permissions set via Browser.grantPermissions / setPermission
now live on the Browser instead of the active Page, so they persist across
page navigations (previously a navigation dropped them) and match how Chrome
scopes permissions to the browser context. navigator.permissions.query() reads
the browser-level state. Also log not_implemented for the origin and
browserContextId params, which are accepted but not yet honored.
2026-06-19 07:30:16 +08:00
Karl Seguin
3335c746dc switch permission value/state from string to enum 2026-06-19 07:28:36 +08:00
Rohit
697ae06852 feat(cdp): honor Browser.grantPermissions / setPermission / resetPermissions
These three Browser methods were noops, so a CDP client could not change
what navigator.permissions.query() reports - it always returned "prompt".

Store permission state on the active Page (keyed by permission name) and
have navigator.permissions.query() read it back. grantPermissions sets each
listed permission to "granted", setPermission sets a single permission to an
explicit state, and resetPermissions clears them (query falls back to
"prompt"). State is scoped to the Page and resets on navigation.

Adds a CDP round-trip test exercising all three methods.
2026-06-19 07:28:05 +08:00
Karl Seguin
56795e3c0b Merge pull request #2782 from lightpanda-io/scope-filter-improvement
support +/-/all syntax in --log-filter-scopes
2026-06-19 07:19:43 +08:00
Karl Seguin
deeb136ab2 Merge pull request #2786 from lightpanda-io/cleanup_tests
cleanup, minor: remove weird fake-tags
2026-06-19 07:16:40 +08:00
Karl Seguin
a1ce1ae791 cleanup, minor: remove weird fake-tags
Cleanup of https://github.com/lightpanda-io/browser/pull/2779 which inserted
unnecessary tags.
2026-06-19 07:07:44 +08:00
Pierre Tachoire
d0d2048e11 Merge pull request #2771 from lightpanda-io/clone-postmessage
webapi: structured-clone window/MessagePort postMessage messages
2026-06-18 16:46:35 +00:00
Adrià Arrufat
9df4537109 Merge pull request #2783 from lightpanda-io/extract-absolute-urls
extract: resolve href/src attributes to absolute URLs
2026-06-18 18:01:34 +02:00
Adrià Arrufat
56e4401db4 extract: resolve href/src attributes to absolute URLs
The schema walker returned raw attribute values, so `attr: "href"` /
`attr: "src"` yielded whatever the markup contained — usually a relative
URL. That is inconsistent with the links and structuredData tools (which
resolve against the document base) and with the DOM .href/.src
properties, and it makes the common extract-then-goto pattern fail on
sites with relative links, since goto needs an absolute URL.

Resolve href/src via `new URL(raw, document.baseURI)`, falling back to
the raw value on parse failure. Other attributes pass through unchanged;
absolute URLs are unaffected.
2026-06-18 17:46:06 +02:00
Adrià Arrufat
69d302fabe agent: add --save flag to synthesize scripts from tasks 2026-06-18 17:45:26 +02:00
Pierre Tachoire
a83b9b1e7e Merge pull request #2781 from lightpanda-io/agent-help-providers
agent: list Vercel, Mistral, llama.cpp in --help
2026-06-18 13:20:46 +00:00
Pierre Tachoire
828444675f feat(log): support +/-/all syntax in --log-filter-scopes
`--log-filter-scopes` previously took a comma-separated list of scopes to
suppress. Extend it with explicit include/exclude directives applied
left-to-right:

  -X     filter out scope X
  X      alias for -X (backward compatible)
  +X     filter in scope X
  all    target every scope

This makes "filter everything except one scope" expressible, e.g.
`-all,+cdp` suppresses all logs except `cdp`. Bare scope names keep their
old meaning, so existing invocations like `http,unknown_prop` are
unaffected.

Internally, the suppressed-scope list is replaced by a resolved per-scope
`scope_enabled` boolean array built via `log.resolveFilterScopes()`, so the
hot-path `enabled()` check is a single array index. Filtering remains
Debug-only, as before. `testing.LogFilter` is adapted to the new
representation; all existing call sites are unchanged.

Adds a unit test for resolveFilterScopes (default, backward-compat,
-all,+cdp, ordering) and updates the help text.
2026-06-18 14:42:07 +02:00
Adrià Arrufat
1cfdd9ae3b agent: list Vercel, Mistral, llama.cpp in --help
The agent already supports these providers (via zenai), but the agent
command's help text still listed only anthropic/openai/gemini/huggingface/
ollama. Bring --help in sync:

- Add vercel, mistral, and llama_cpp to the --provider allowed values
- Add AI_GATEWAY_API_KEY and MISTRAL_API_KEY to the auto-detect and
  env-key lists
- Document llama.cpp as a keyless local server (base http://localhost:8080/v1)
- Note that a provider can set its own effort default (Mistral -> none)

This realigns --help with the docs at lightpanda.io/docs/usage/agent.
2026-06-18 13:48:49 +02:00
Adrià Arrufat
8bcd0a9567 Merge pull request #2780 from lightpanda-io/agent-default-effort
agent: support provider-specific default effort
2026-06-18 13:35:13 +02:00
Adrià Arrufat
59dc69f1fe agent: support provider-specific default effort
Updates the zenai dependency and resolves the agent's effort based on
the configured provider's default. Also dynamically updates the active
effort when switching providers.
2026-06-18 13:22:29 +02:00
Pierre Tachoire
2b5456ca0b webapi: structured-clone window/MessagePort postMessage messages
window.postMessage and MessagePort.postMessage stashed the message
js.Value.Temp verbatim and handed it straight into the MessageEvent, with
no structuredClone on the path. The receiver got the literal object the
sender posted, so a mutation on either side was visible to the other; worse,
posting to a different same-origin frame exposed the source realm's object
directly into the target realm instead of minting a fresh one there. The
spec requires StructuredSerialize in postMessage and deserialize in the
destination realm.
2026-06-18 12:36:29 +02:00
Pierre Tachoire
80603902be Merge pull request #2570 from lightpanda-io/cache-revalidation
Cache Revalidation
2026-06-18 09:46:02 +00:00
Karl Seguin
4281e0f0f4 Merge pull request #2779 from lightpanda-io/async_tests
tests: Migrate all legacy testing.async(cb) to new testing.async flow
2026-06-18 17:40:23 +08:00
Pierre Tachoire
6726da4293 Merge pull request #2777 from lightpanda-io/ci-agent-alias
ci: upload on s3 an agent alias
2026-06-18 09:37:08 +00:00
Karl Seguin
7cafd05e21 Merge pull request #2767 from lightpanda-io/broadcastchannel
implement BroadcastChannel
2026-06-18 17:26:25 +08:00
Karl Seguin
397176d868 tests: Migrate all legacy testing.async(cb) to new testing.async flow
The legacy testing.async(async() => {...}); was simple to use, but it only
worked in simple cases. Any microtasks which wasn't immediately resolve would
still fail.

The newer testing.async code is more robust and can handle any async scenario.
It's a bit more verbose and it's limited to 1 per <script type=module>. This
commit migrates all remaining legacy usages to the new flow. While the simpler
one was nice, having both approaches is confusing (to humans and ai).
2026-06-18 17:22:20 +08:00
Karl Seguin
31404bf511 Merge pull request #2772 from lightpanda-io/worker_navigator
webapi, worker: Expose Navigator on Worker
2026-06-18 17:13:25 +08:00
Adrià Arrufat
7677fb142a Merge pull request #2778 from lightpanda-io/agent-save-effort-fix
agent: respect configured reasoning effort
2026-06-18 11:08:36 +02:00
Pierre Tachoire
d3ba85818b Merge pull request #2776 from lightpanda-io/remove_external_connection_from_unit_test
tests: remove external connection from unit tests
2026-06-18 08:58:22 +00:00