Commit Graph
9351 Commits
Author SHA1 Message Date
Karl Seguin 218a4bacd4 split out protocol.json to 1 line per command 2026-09-11 06:40:23 +08:00
Karl Seguin e8f6591411 address feedback
remove --strip-mode full   (and all `full` support from cli, because it makes
backwards-compatibility a pain)
2026-09-11 06:36:49 +08:00
Karl Seguin 5bc4f7482c render: add "clutter" option to --strip-mode
Adds a `clutter` option to --strip-mode. This is based on readability.js. It
isn't a direct port (e.g. it doesn't strop bylines). It fallsback to `shell` if
it strips too much (and shell itself can fallback to not stripping anything).
But clutter rarely fallback to shell, only when a page is very small or when
it strips out _a lot_.

Also expanded shell to look at class names and ids.
2026-09-11 06:36:48 +08:00
Karl Seguin cdceca37c3 render: add "shell" option to --strip-mode
Some additional API changes:
- Add strip-mode support to pdf/png generation.
- Add LP.dump which provides greater content gathering capability to CDP,
  exposing most `fetch` dump-related parameters (e.g. format, strip, selector,
  ...)

The new "--strip-mode shell" is designed to try to remove non-content elements
such as the header and footer. The end goal is to use readibility.js test cases
as a baseline, but this isn't a port of readibility.js.

This is just the basic implementation of this, e.g removing a few key tags, e.g.
<header>, <footer> and considering some specific roles.

Even if --strip-mode shell is used, we might decide to stick with a whole dump:
it's better to strip not enough than to strip too much. This currently works by
measuring the ratio of non-link text of the stripped vs unstripped page.
2026-09-11 06:35:26 +08:00
Karl Seguin c21462cc38 Merge pull request #3480 from lightpanda-io/cdp-dom-focus
cdp: add DOM.focus
2026-09-11 06:29:34 +08:00
Karl Seguin 0837292d5e Merge pull request #3465 from lightpanda-io/getCurrentEntry-crash
Fix `history.state` and `Navigation.currentEntry` crash
2026-09-11 06:24:25 +08:00
Karl Seguin ceaa81721b update protocol.json 2026-09-11 06:09:51 +08:00
Karl Seguin 35e13e4d64 dom.focus only on focusable elements 2026-09-11 06:02:27 +08:00
Karl Seguin 561d4ab0ea Merge pull request #3482 from lightpanda-io/deps-releasefast
build: compile dependencies in ReleaseFast regardless of -Doptimize
2026-09-11 05:55:02 +08:00
Karl Seguin 33c9f3b9fd Merge pull request #3401 from lightpanda-io/http-webdriver
webdriver: HTTP WebDriver session management
2026-09-11 05:41:33 +08:00
Karl Seguin 9e44738775 update orderfile 2026-09-11 05:40:19 +08:00
Adrià Arrufat 585cfb06dd build: compile dependencies in ReleaseFast regardless of -Doptimize
Debug and release builds each compiled their own copy of every C
dependency and of the Rust staticlib, because build.zig threaded the
top-level optimize mode into all of them. Under dev_fast the deps also
picked up the bundled-CRT target query, so even the same mode could not
share objects with a plain build.

Dependencies now build in ReleaseFast for the requested target, the way
the prebuilt V8 archive already works. Debug and release builds share
one set of cached dependency objects, and debug binaries run TLS, HTML
parsing, regex and sqlite optimized. -Ddebug_deps restores the old
behaviour for stepping into a dependency.

The Rust staticlib can only be shared by dropping the Debug-only memstats
feature: its single export, html5ever_get_memory_usage, was declared on
the Zig side but never called, and it pulled a jemalloc build into every
cold debug build. The Makefile override that existed for jemalloc's
nested make goes with it.
2026-09-11 05:40:17 +08:00
Karl Seguin 2ace9d1548 make socket ownership more explicit and future-proof 2026-09-11 05:24:12 +08:00
Karl Seguin bcf69ced9c address feedback
tighten socket ownership (on error paths)

allow reaper to be disabled

Handle window where link is being destroyed, worker is still alive, and client
attempts to re-link.
2026-09-11 05:11:36 +08:00
Karl Seguin 3fb4539b87 fix import 2026-09-11 05:11:36 +08:00
Karl Seguin 6392454892 fix test-only tsan issue 2026-09-11 05:11:36 +08:00
Karl Seguin 8ad9eaf48d webdriver: HTTP WebDriver session management
This is a small step towards WebDriver supports (non-bidi). It allows creating
and deleting a BiDi "Session" (e.g. a worker). It also allows attaching a BiDi
driver to an HTTP-created BiDi session (the typical selenium startup flow).

This change unblocks the most basic setup/teardown of Selenium, so it still
isn't enough to actually use a Selenium script as-is. But it's significant
because it models a worker (thread) that isn't tied to a WebSocket, something we
haven't had before.

A consequence of a pure HTTP Session is that we don't have a clear cleanup
signal. There is no "the socket is disconnected". There's a new HTTP reaper
which kills HTTP Sessions after --http-session-timeout. It's expected that
drivers properly DELETE /session/:id. I imagine we're going to run into
--cdp-max-connections limits and need to tweak this code. BUT, this entire flow
is only enabled with --protocol webdriver, so it won't impact exiting CDP users.
2026-09-11 05:11:26 +08:00
Karl Seguin 72165ef2a4 Merge pull request #3476 from lightpanda-io/make-private-if-private
chore: make declarations private if they don't need to be public
2026-09-11 05:09:17 +08:00
Muki Kiboigo 676fa59835 update ids in CDP navigation tests 2026-09-10 13:16:40 -07:00
Muki Kiboigo 87e7403826 move initial page creation to createPage 2026-09-10 13:15:20 -07:00
Adrià Arrufat 9f4f31820f cdp: add DOM.focus
Drivers focus a node before typing (chromedp's SendKeys calls DOM.focus,
then Input.dispatchKeyEvent). The method was unknown, so the keystrokes
went to the previously active element and every chromedp form fill was a
no-op. Resolve the node like the other DOM commands and call Element.focus,
which already handles focusability and the blur/focus event sequence.
2026-09-10 16:04:21 +02:00
Adrià Arrufat d693f49872 Merge pull request #3463 from lightpanda-io/adblock-regex-pcre2
`AdBlocker`: run /regex/ filters with PCRE2
2026-09-10 14:04:14 +02:00
Adrià Arrufat aecb115771 Regex: a failed compile allocation is PCRE2_ERROR_HEAP_FAILED
Compile errors are reported as 100 plus the internal number, and the
one for a failed allocation has a public name.
2026-09-10 11:25:20 +02:00
Adrià Arrufat 06f7f6f295 Engine: look through an optional stretch when reading a branch's ends
An alternation or a repeat keeps only whether its text may start and
end with a token character, and read that off one marker. An optional
non-token stretch there (`\/?x`) was taken as a definite non-token,
so `\/ads(\/?x|\/y)` was filed under "ads" while `/adsx` carries no
such token. What follows the stretch answers now.
2026-09-10 11:25:20 +02:00
Karl Seguin 2e6999f20b chore: make declarations private if they don't need to be public
This change is 99%  s/pub//   + a handful of dead code removal.
2026-09-10 14:42:09 +08:00
Karl Seguin b26d487b2a Merge pull request #3461 from lightpanda-io/style-manager-custom-properties
webapi: add basic support for custom properties
2026-09-10 12:37:49 +08:00
Karl Seguin e83e1e76ea webapi: add basic support for custom properties
Attempt to improve https://github.com/lightpanda-io/browser/issues/3199

Meant an leaner alternative to https://github.com/lightpanda-io/browser/pull/3440

3440 is close, but it adds 16 bytes to every VisibilityRule which isn't ideal
especially since the majority of these rules have no custom properties.

Let's make a few reasonable assumptions:
1 - Most custom properties don't have many distinct selectors
    (--background-color might be defined on, :root, and .card and a few others)

2 - Most custom properties aren't queried from JS (Tailwind can define thousands
    of custom properties, but they're used by the rendering engine, not from JS)

3 - Most selectors don't have custom properties

The design is to inverse what we do for visibility: lookup per property. We end
up with a property-name -> [(selector, value), (selector, value)] lookup. If
there's a query for --foreground, we O(1) to get the list of (selector, value)
and then iterate through this (hopefully) short list to get the value.

PLUS, we only parse the selector on the first query. So for those sites with
thousands of custom-properties, we're not wastefully storing / parsing the
selector on every build.
2026-09-10 12:09:50 +08:00
Karl Seguin dd0fd04267 Merge pull request #3475 from lightpanda-io/style-visibility-memo
Style visibility memo
2026-09-10 12:09:24 +08:00
Adrià Arrufat 9d994efbee Merge pull request #3468 from lightpanda-io/drop-visibility-call-caches
Drop the per-call visibility caches
2026-09-10 11:20:32 +08:00
Karl Seguin 3b4088ab62 use node's own frame, not the callers 2026-09-10 11:03:46 +08:00
Adrià Arrufat 60139f395b Merge pull request #3467 from lightpanda-io/style-visibility-memo
perf: memoize StyleManager visibility per element
2026-09-10 11:02:19 +08:00
Adrià Arrufat 1583a4b45f Drop the per-call visibility caches
With the StyleManager memo, a VisibilityCache/PointerEventsCache hit
costs the same hash probe as a memo hit, so the caches only added a
second probe per ancestor, a call_arena allocation per element, and
plumbing through SemanticTree, AXNode, CDP, links, ResizeObserver and
elementFromPoint. checkVisibilityCached becomes isVisible.
2026-09-10 10:34:43 +08:00
Karl Seguin 482d63e89e update style_version change on:
1 - history change (:target)
2 - document._active_element change (various places, added doc.setActiveElement())
3 - fragment-only navigation (:target)
4 - checkbox/radio commit/rollback (:checked)
2026-09-10 10:33:45 +08:00
Karl Seguin 33ddbdf0fc Merge pull request #3466 from lightpanda-io/locale-timezone
cli: add --locale and --timezone, derive language signals from one value
2026-09-10 08:06:39 +08:00
Karl Seguin 471ea3bd80 Merge pull request #3464 from lightpanda-io/fix-attr-clone-owner-element
dom: detach cloned Attr from its owner element
2026-09-10 08:01:41 +08:00
Karl Seguin 58e1a547d8 fix help ordering, remove unnecessary pub 2026-09-10 07:41:34 +08:00
Karl Seguin 0cca01c0e8 Register a detached node's frame
Clear attribute element on remove

Relax naming validation to match Firefox/Chrome
2026-09-10 07:34:59 +08:00
Karl Seguin 1a7904843d Merge pull request #3460 from lightpanda-io/http-headers
webapi: Origin header + request header validation
2026-09-10 06:45:50 +08:00
Karl Seguin befea97d1e Merge pull request #3459 from lightpanda-io/named-interceptor-query
webapi: improve indexing / enumerable of various collections
2026-09-10 06:45:37 +08:00
Karl Seguin 773b7cbb22 Merge pull request #3455 from lightpanda-io/fix-cdp-notification-crash
Fix `Notification` use-after-free
2026-09-10 06:32:26 +08:00
Adrià Arrufat fec94aae0a Memoize StyleManager visibility per element
Every ancestor-aware visibility query (checkVisibility, offsetWidth,
getBoundingClientRect, getComputedStyle().visibility, pointer-events, and
the Zig tree walkers) re-resolved each ancestor from scratch. Resolve an
element's display/visibility/opacity/pointer-events once and reuse it
while Page.style_version is unchanged.

The inline style attribute is scanned once for all four properties, the
pointer-events scan shares the same path, and a materialize-mode hit still
creates the inline style object that layout reads.
2026-09-09 22:47:36 +02:00
Adrià Arrufat 84c46b6331 Add Page.style_version stamp for style-dependent state
Bumped through Frame.styleChanged: with dom_version, and by the state
changes that alter a selector match without changing what live
collections see: checked/indeterminate, input values, custom element
definitions, character data (:empty), parser insertions and stylesheet
changes. Stamps the visibility memo added next.
2026-09-09 20:46:06 +02:00
Adrià Arrufat 37bf7b68c1 cli: one Accept-Language parser for the header and navigator.languages
navigator.languages now lists the Accept-Language tags in order, which is
Chrome's contract, instead of a second derivation from the locale tag that
disagreed with the header (--locale de-DE sent de-DE,de,en but reported
["de-DE","de"]). HttpHeaders.AcceptLanguage owns both shapes and is also
the CDP override type.

ICU canonicalizes a BCP 47 tag read from LC_ALL itself, script subtag
included, so the POSIX id conversion is gone; it dropped the script and
turned zh-Hans-TW into Traditional Chinese.

Also: the CDP handler keeps validateUserAgent's verdict instead of scanning
for Mozilla twice, the override is cleared unconditionally on context
teardown instead of through a flag, and the flags are sentinel strings so
Platform passes them to setenv without copying.
2026-09-09 18:07:03 +02:00
Adrià Arrufat c55afc1df9 cli: add --locale and --timezone, derive language signals from one value
navigator.language was hard-coded to en-US and Accept-Language was a
constant, while Intl, toLocaleString and Date followed the host process
environment. On a de_DE host a page saw navigator.language === "en-US"
next to German number formatting, a mismatch fingerprinting scripts look
for, and the same page rendered differently across machines.

Follow Chrome's --lang rule: one configured tag drives navigator.language(s),
the Accept-Language header and ICU's default locale. --locale defaults to
en-US, so Intl is now en-US on every host instead of whatever LANG says.
--timezone sets the IANA zone Date and Intl use; absent, the host zone stays.

Both are applied by writing LC_ALL and TZ before V8 initializes ICU, which
reads them lazily. Platform.init is the first call in App.init, before any
thread exists, so setenv is safe there.

CDP Emulation.setUserAgentOverride.acceptLanguage, which Playwright sends
for its locale option, now overrides the header and navigator.languages
for the browser context's lifetime, mirroring the user agent override, and
applies even when the Mozilla user agent is refused.

Emulation.setLocaleOverride and setTimezoneOverride stay no-ops: changing
ICU's defaults at runtime needs new zig-v8-fork bindings.
2026-09-09 17:49:02 +02:00
Muki Kiboigo 1bdb38770c add a matching navigation.currentEntry test 2026-09-09 07:58:11 -07:00
Muki Kiboigo f6e2210023 pushEntry instead of doing a full navigation initially 2026-09-09 07:57:21 -07:00
Muki Kiboigo fa71299c75 createTarget should navigate to about:blank initially 2026-09-09 07:52:02 -07:00
Muki Kiboigo a6d0ecb790 add cdp target test that tries to read history.state 2026-09-09 07:51:46 -07:00
Muki Kiboigo 260ad4f8db move notification fix to Session.deinit 2026-09-09 07:37:11 -07:00
Adrià Arrufat 51974bb346 dom: detach cloned Attr from its owner element
Attr.cloneNode() copied _element, so the clone still claimed the original
owner. Element.setAttributeNode() then tried to remove it from that owner,
which never held it, and threw NotFoundError. Per the DOM spec a cloned Attr
has a null ownerElement.

While there, make setAttributeNode() throw InUseAttributeError when the Attr
belongs to another element instead of silently moving it, matching the spec
and both Chrome and Firefox.

Mozilla's Readability.js hits this on every page (_setNodeTag,
_simplifyNestedElements), as does any code that copies attributes with
el.setAttributeNode(attr.cloneNode()).
2026-09-09 16:21:50 +02:00