Commit Graph

4853 Commits

Author SHA1 Message Date
Karl Seguin
0971df4dfc Merge pull request #1782 from lightpanda-io/silence_shutdown_error_on_non_linux
Don't log SocketNotConnected when shutting down listener on non-Linux
2026-03-11 16:39:15 +08:00
Halil Durak
9fb57fbac0 Merge pull request #1771 from lightpanda-io/nikneym/compile-function
Prefer `ScriptCompiler::CompileFunction` to compile attribute listeners
2026-03-11 11:38:16 +03:00
Karl Seguin
48ead90850 Don't log SocketNotConnected when shutting down listener on non-Linux
On BSD, a listening socket isn't considered connected, so this error is
expected. Maybe we shouldn't call shutdown at all, but I guess it's safer this
way.
2026-03-11 16:29:44 +08:00
Pierre Tachoire
cc88bb7feb Merge pull request #1777 from lightpanda-io/mcp-missing-lp-commands
mcp: add interactiveElements and structuredData tools
2026-03-11 09:11:48 +01:00
Karl Seguin
a725e2aa6a Merge pull request #1774 from egrs/range-chardata-mutations
update live ranges after CharacterData and DOM mutations
2026-03-11 16:04:41 +08:00
Karl Seguin
ee637c3662 Add support for target attribute on anchors and forms 2026-03-11 15:49:30 +08:00
Adrià Arrufat
65d7a39554 SemanticTree: use payload captures for CData.Text checks
Improves conciseness and idiomatic Zig style by replacing .is(CData.Text) != null and .as() with direct payload captures in if statements.
2026-03-11 16:39:59 +09:00
Adrià Arrufat
37735b1caa SemanticTree: use StaticStringMap for structural role check
Improves performance and readability of isStructuralRole. Also includes minor syntax cleanup in AXNode.
2026-03-11 16:37:24 +09:00
Pierre Tachoire
c8f8d79f45 Merge pull request #1775 from lightpanda-io/arena_blob
Use arena from ArenaPool for Blob (and File)
2026-03-11 08:35:27 +01:00
Adrià Arrufat
1866e7141e SemanticTree: cast with as
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-03-11 16:33:39 +09:00
Adrià Arrufat
feccc9f5ce AXNode: remove unused mock JSON lifecycle methods
Simplifies TextCaptureWriter by removing unused methods, ensuring future changes to writeName will fail at build time if new methods are required.
2026-03-11 16:25:34 +09:00
Adrià Arrufat
af803da5c8 cdp.lp: use enum for getSemanticTree format param
Leverages std.json.parse to automatically validate the format param into a type-safe enum.
2026-03-11 16:21:43 +09:00
egrs
25c89c9940 Revert "remove ranges from live list on GC finalization"
This reverts commit 625d424199.
2026-03-11 08:04:53 +01:00
egrs
697a2834c2 Revert "fix CI: store list pointer on AbstractRange to avoid Page type mismatch"
This reverts commit 056b8bb536.
2026-03-11 08:04:51 +01:00
egrs
056b8bb536 fix CI: store list pointer on AbstractRange to avoid Page type mismatch
The bridge.finalizer resolves Page through its own module graph, which
can differ from Range.zig's import in release builds. Store a pointer
to the live_ranges list directly on AbstractRange so deinit can remove
without accessing Page fields.
2026-03-11 07:58:31 +01:00
egrs
625d424199 remove ranges from live list on GC finalization
Add a weak finalizer to Range that removes its linked list node from
Page._live_ranges when V8 garbage-collects the JS Range object. This
prevents the list from growing unboundedly and avoids iterating over
stale entries during mutation updates.
2026-03-11 07:27:39 +01:00
Adrià Arrufat
5329d05005 interactive: optimize getTextContent single-chunk path
Avoids an unnecessary double allocation and maintains a zero-copy fast path for single-chunk text extraction.
2026-03-11 15:27:12 +09:00
egrs
d2c55da6c9 address review: move per-range logic to AbstractRange, simplify collapsed check
Move the per-range update logic from Page into AbstractRange methods
(updateForCharacterDataReplace, updateForSplitText, updateForNodeInsertion,
updateForNodeRemoval). Page now just iterates the list and delegates.

Remove redundant start_container == end_container check in insertNode —
collapsed already implies same container.
2026-03-11 07:26:20 +01:00
Adrià Arrufat
2e6dd3edfe browser.EventManager: remove unused hasListener function 2026-03-11 15:18:14 +09:00
Nikolay Govorov
a95b4ea7b9 Use global connections poll 2026-03-11 05:44:59 +00:00
Nikolay Govorov
c891eff664 Use zig allocator for libcurl 2026-03-11 03:34:27 +00:00
Adrià Arrufat
68564ca714 mcp: add interactiveElements and structuredData tools 2026-03-11 11:09:19 +09:00
Adrià Arrufat
ca931a11be AXNode: add spacing between concatenated text nodes
When calculating accessible names for elements without explicit labels, multiple descendant text nodes were previously concatenated directly together. This adds a space between distinct text node contents to prevent words from sticking together.
2026-03-11 10:45:07 +09:00
Adrià Arrufat
6c7272061c cli: enable pruning for semantic_tree_text dump mode
Previously, semantic_tree_text hardcoded prune = false, which bypassed the structural node filters and allowed empty none nodes to pollute the root of the text dump.
2026-03-11 10:38:12 +09:00
Adrià Arrufat
4f262e5bed SemanticTree: filter computed names for generic containers
This prevents token bloat in JSON/text dumps and ensures that StaticText leaf nodes are not incorrectly pruned when structural containers (like none, table) hoist their text.
2026-03-11 10:22:40 +09:00
Karl Seguin
ff26b0d5a4 Use arena from ArenaPool for Blob (and File) 2026-03-11 09:21:54 +08:00
Adrià Arrufat
a6ccc72d15 interactive: properly concatenate text content for accessible names
This fixes a bug where only the first text node was being returned, causing fragmented text nodes (e.g. <span>Sub</span><span>mit</span>) to be missing their trailing text.
2026-03-11 09:57:08 +09:00
Karl Seguin
487ee18358 Merge pull request #1742 from lightpanda-io/context_origins
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Context origins
2026-03-11 08:54:53 +08:00
Karl Seguin
dc3d2e9790 Remove root context check from Env
This was only added [very briefly] when Env managed Origins, which it no longer
does.
2026-03-11 08:44:52 +08:00
Karl Seguin
f6d0e484b0 transfer finalizers on origin change 2026-03-11 08:44:52 +08:00
Karl Seguin
4cea9aba3c update v8 dep 2026-03-11 08:44:51 +08:00
Karl Seguin
7348a68c84 merge main 2026-03-11 08:44:51 +08:00
Karl Seguin
7d90c3f582 Move origin lookup to Session
With the last commit, this becomes the more logical place to hold this as it
ties into the Session's awareness of the root page's lifetime.
2026-03-11 08:44:51 +08:00
Karl Seguin
2a103fc94a Use Session as a container for cross-frame resources
The introduction of frames means that data is no longer tied to a specific Page
or Context. 255b9a91cc introduced Origins for
v8 values shared across frames of the same origin. The commit highlighted the
lifetime mismatched that we now have with data that can outlive 1 frame. A
specific issue with that commit was the finalizers were still Context-owned.
But like any other piece of data, that isn't right; aside from modules, nothing
should be context-owned.

This commit continues where the last left off and moves finalizers from Context
to Origin. This is done in a separate commit because it introduces significant
changes. Currently, finalizers take a *Page, but that's no longer correct. A
value created in one Page, can outlive the Page. We need another container. I
original thought to use Origin, but that isn't know to CDP/MCP. Instead, I
decide to enhance the Session.

Session is now the owner of the page.arena, the page.factory and the
page.arena_pool. Finalizers are given a *Session which they can use to release
their arena.
2026-03-11 08:44:49 +08:00
Karl Seguin
753391b7e2 Add origins safety cleanup when destroying the context for the root page 2026-03-11 08:43:41 +08:00
Karl Seguin
94ce5edd20 Frames on the same origin share v8 data
Depends on: https://github.com/lightpanda-io/zig-v8-fork/pull/153

In some ways this is an extension of
https://github.com/lightpanda-io/browser/pull/1635 but it has more implications
with respect to correctness.

A js.Context wraps a v8::Context. One of the important thing it adds is the
identity_map so that, given a Zig instance we always return the same v8::Object.

But imagine code running in a frame. This frame has its own Context, and thus
its own identity_map. What happens when that frame does:

```js
window.top.frame_loaded = true;
```

From Zig's point of view, `Window.getTop` will return the correct Zig instance.
It will return the *Window references by the "root" page. When that instance is
passed to the bridge, we'll look for the v8::Object in the Context's
`identity_map` but wont' find it. The mapping exists in the root context
`identity_map`, but not within this frame. So we create a new v8::Object and now
our 1 zig instance has N v8::Objects for every page/frame that tries to access
it.

This breaks cross-frame scripting which should work, at least to some degree,
even when frames are on the same origin.

This commit adds a `js.Origin` which contains the `identity_map`, along with our
other `v8::Global` storage. The `Env` now contains a `*js.Origin` lookup,
mapping an origin string (e.g. lightpanda.io:443) to an *Origin. When a Page's
URL is changed, we call `self.js.setOrigin(new_url)` which will then either get
or create an origin from the Env's origin lookup map.

js.Origin is reference counted so that it remains valid so long as at least 1
frame references them.

There's some special handling for null-origins (i.e. about:blank). At the root,
null origins get a distinct/isolated Origin. For a frame, the parent's origin
is used.

Above, we talked about `identity_map`, but a `js.Context` has 8 other fields
to track v8 values, e.g. `global_objects`, `global_functions`,
`global_values_temp`, etc. These all must be shared by frames on the same
origin. So all of these have also been moved to js.Origin. They've also been
merged so that we now have 3 fields: `identity_map`, `globals` and `temps`.

Finally, when the origin of a context is changed, we set the v8::Context's
SecurityToken (to that origin). This is a key part of how v8 allows cross-
context access.
2026-03-11 08:43:40 +08:00
Nikolay Govorov
3626f70d3e Merge pull request #1759 from lightpanda-io/wp/mrdimidum/net-poll-runtime
Network poll runtime
2026-03-10 23:38:07 +00:00
Nikolay Govorov
24cc24ed50 Fix Robots deinit 2026-03-10 23:28:40 +00:00
Karl Seguin
dd29ba4664 Merge pull request #1767 from egrs/css-value-normalization-gaps
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / zig build release (push) Has been cancelled
wpt / build wpt runner (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
extend CSS value normalization to cover more properties
2026-03-11 06:28:34 +08:00
egrs
7927ad8fcf route appendData through replaceData for spec compliance
Per DOM spec, appendData(data) is defined as replaceData(length, 0, data).
While the range update would be a no-op (offset=length, count=0), routing
through replaceData ensures consistent code path and spec compliance.
2026-03-10 20:27:05 +01:00
egrs
d23453ce45 update live ranges after CharacterData and DOM mutations
Per DOM spec, all live ranges must have their boundary offsets updated
when CharacterData content changes (insertData, deleteData, replaceData,
splitText) or when nodes are inserted/removed from the tree.

Track live ranges via an intrusive linked list on Page. After each
mutation, iterate and adjust start/end offsets per the spec algorithms.

Also fix Range.deleteContents loop that read _end_offset on each
iteration (now decremented by the range update), and Range.insertNode
that double-incremented _end_offset for non-collapsed ranges.

Route textContent, nodeValue, and data setters through replaceData
so range updates fire consistently.

Fixes 9 WPT test files (all now 100%): Range-mutations-insertData,
deleteData, replaceData, splitText, appendChild, insertBefore,
removeChild, appendData, dataChange (~1330 new passing subtests).
2026-03-10 19:59:04 +01:00
Halil Durak
a22040efa9 update body.onload test 2026-03-10 19:16:35 +03:00
Halil Durak
ba3da32ce6 spread new stringToPersistedFunction 2026-03-10 19:16:20 +03:00
Halil Durak
9d2ba52160 adapt stringToPersistedFunction to compileFunction
This is just a thin wrapper around it now.
2026-03-10 19:15:53 +03:00
Halil Durak
e610506df4 Local: initial compileFunction 2026-03-10 18:14:35 +03:00
Pierre Tachoire
dd91d28bfa Merge pull request #1761 from lightpanda-io/wp/mrdimidium/c-tsan
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Enable tsan for c libs
2026-03-10 15:33:33 +01:00
Pierre Tachoire
1ebf7460fe Merge pull request #1768 from lightpanda-io/inspector_cleanup
Call `resetContextGroup` on page removal
2026-03-10 15:32:47 +01:00
Pierre Tachoire
8c930e5c33 Merge pull request #1769 from lightpanda-io/form_action
Add Form.action getter/setter
2026-03-10 15:31:34 +01:00
egrs
4fb2f7474c remove incorrect entries from normalization maps
- Remove scale, contain-intrinsic-size, animation-range, text-box-edge
  from isTwoValueShorthand: these have asymmetric or 3-value semantics
  that make "X X" → "X" collapse incorrect.
- Remove line-height from isLengthProperty: bare 0 is the unitless
  number multiplier, not a length (Chrome serializes as "0" not "0px").
- Fix test: background-size "cover cover" is invalid CSS, use "auto auto".
2026-03-10 14:08:28 +01:00
Karl Seguin
5301f79989 Add Form.action getter/setter 2026-03-10 20:58:31 +08:00