Commit Graph

3888 Commits

Author SHA1 Message Date
Adrià Arrufat
21325ca9be Merge branch 'main' into semantic-versioning 2026-03-21 09:46:05 +09:00
Karl Seguin
b4b7a7d58a Merge pull request #1901 from lightpanda-io/goodbye_origin
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / wba-demo-scripts (push) Has been cancelled
e2e-test / wba-test (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 fmt (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
Remove Origins
2026-03-21 07:19:47 +08:00
Karl Seguin
a5378feb1d Merge pull request #1927 from lightpanda-io/feat/fetch-wait-options
Feat/fetch wait options
2026-03-21 07:18:59 +08:00
Adrià Arrufat
b5d3d37f16 Merge pull request #1931 from lightpanda-io/fix/mcp-jsonrpc-response
Fix MCP error responses missing jsonrpc field
2026-03-21 06:23:34 +09:00
Pierre Tachoire
9b02e4963b Merge pull request #1929 from mvanhorn/osc/1819-fix-detach-session-null
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / wba-demo-scripts (push) Has been cancelled
e2e-test / wba-test (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 fmt (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
Send Target.detachedFromTarget event on detach
2026-03-20 20:06:19 +01:00
Halil Durak
a865b86fa5 Merge pull request #1925 from lightpanda-io/nikneym/promise-error
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / wba-demo-scripts (push) Has been cancelled
e2e-test / wba-test (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 fmt (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
Return correct errors in promise rejections
2026-03-20 14:05:21 +03:00
Halil Durak
de28d14aff give up on switch (comptime kind), prefer union(enum) 2026-03-20 13:35:12 +03:00
Karl Seguin
88681b1fdb Fix Context's call_arena
The Context's call_arena should be based on the source, e.g. the IsolateWorld
or the Page, not always the page. There's no rule that says all Contexts have
to be a subset of the Page, and thus some might live longer and by doing so
outlive the page_arena.

Also, on context cleanup, isolate worlds now cleanup their identity.
2026-03-20 16:50:03 +08:00
Adrià Arrufat
02d05ae464 Fix MCP error responses missing jsonrpc field
Closes #1928
2026-03-20 09:55:54 +09:00
Matt Van Horn
84557cb4e6 fix(cdp): send Target.detachedFromTarget event on detach
detachFromTarget and setAutoAttach(false) both null bc.session_id
without notifying the client. Per the CDP spec, detaching a session
must fire a Target.detachedFromTarget event so the driver stops
sending messages on the stale session ID.

Capture the session_id before nulling it and fire the event in both
code paths. Add tests covering the event emission and the no-session
edge case.

Fixes #1819

This contribution was developed with AI assistance (Claude Code + Codex).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 16:42:32 -07:00
Karl Seguin
4cdc24326a Merge pull request #1918 from lightpanda-io/shadowroot_adoptedstyle
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / wba-demo-scripts (push) Has been cancelled
e2e-test / wba-test (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 fmt (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
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
Add `adoptedStyleSheets` property to ShadowRoot, just like Document
2026-03-20 07:11:49 +08:00
Karl Seguin
cf46f0097a Merge pull request #1915 from lightpanda-io/unhandled_rejection_improvements
Improve unhandled rejection
2026-03-20 07:11:35 +08:00
Adrià Arrufat
f1293b7346 Merge branch 'main' into semantic-versioning 2026-03-20 07:04:05 +09:00
Halil Durak
94190f93af return correct errors from promises 2026-03-19 16:30:09 +03:00
Halil Durak
93e239f682 bind more ECMAScript errors 2026-03-19 16:27:51 +03:00
Karl Seguin
a4cb5031d1 Tweak wait_until option
Small tweaks to https://github.com/lightpanda-io/browser/pull/1896

Improve the wait ergonomics with an Option with default parameter. Revert
page pointer logic to original (don't think that change was necessary).
2026-03-19 20:29:20 +08:00
Karl Seguin
a2e59af44c Merge pull request #1911 from lightpanda-io/fix/turnstile-300030-missing-navigator-apis
Fix/turnstile 300030 missing navigator apis
2026-03-19 20:26:27 +08:00
Karl Seguin
00c962bdd8 Merge pull request #1914 from lightpanda-io/semantic-tree-depth
SemanticTree: add progressive discoverability
2026-03-19 20:12:02 +08:00
Karl Seguin
1fa87442b8 log not_implemented on navigator.getBattery 2026-03-19 20:11:03 +08:00
Karl Seguin
ac5400696a Merge pull request #1916 from lightpanda-io/request_abort
Add Request.signal
2026-03-19 20:07:12 +08:00
Adrià Arrufat
5062273b7a SemanticTree: use CDPNode.Id for NodeData id 2026-03-19 20:29:54 +09:00
Adrià Arrufat
9c2393351d SemanticTree: simplify max_depth logic 2026-03-19 20:25:20 +09:00
Adrià Arrufat
f0cfe3ffc8 SemanticTree: use logger better
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-03-19 20:15:56 +09:00
Karl Seguin
f70865e174 Take 2.
History: We started with 1 context and thus only had 1 identity map. Frames
were added, and we tried to stick with 1 identity map per context. That didn't
work - it breaks cross-frame scripting. We introduced "Origin" so that all
frames on the same origin share the same objects. That almost worked, by
the v8::Inspector isn't bound by a Context's SecurityToken. So we tried 1 global
identity map. But that doesn't work. CDP IsolateWorlds do, in fact, need some
isolation. They need new v8::Objects created in their context, even if the
object already exists in the main context.

In the end, you end up with something like this: A page (and all its frames)
needs 1 view of the data. And each IsolateWorld needs it own view. This commit
introduces a js.Identity which is referenced by the context. The Session has a
js.Identity (used by all pages), and each IsolateWorld has its own js.Identity.

As a bonus, the arena pool memory-leak detection has been moved out of the
session and into the ArenaPool. This means _all_ arena pool access is audited
(in debug mode). This seems superfluous, but it's actually necessary since
IsolateWorlds (which now own their own identity) can outlive the Page so there's
no clear place to "check" for leaks - except on ArenaPool deinit.
2026-03-19 18:46:35 +08:00
Karl Seguin
38e9f86088 fix context-leak 2026-03-19 15:42:29 +08:00
Karl Seguin
d9c5f56500 Remove Origins
js.Origin was added to allow frames on the same origin to share our zig<->js
maps / identity. It assumes that scripts on different origins will never be
allowed (by v8) to access the same zig instances.

If two different origins DID access the same zig instance, we'd have a few
different problems. First, while the mapping would exist in Origin1's
identity_map, when the zig instance was returned to a script in Origin2, it
would not be found in Origin2's identity_map, and thus create a new v8::Object.
Thus we'd end up with 2 v8::Objects for the same Zig instance. This is
potentially not the end of the world, but not great either as any zig-native
data _would_ be shared (it's the same instance after all), but js-native data
wouldn't.

The real problem this introduces though is with Finalizers. A weak reference
that falls out of scope in Origin1 will get cleaned up, even though it's still
referenced from Origin2.

Now, under normal circumstances, this isn't an issue; v8 _does_ ensure that
cross-origin access isn't allowed (because we set a SecurityToken on the
v8::Context). But it seems like the v8::Inspector isn't bound by these
restrictions and can happily access and share objects across origin.

The simplest solution I can come up with is to move the mapping from the Origin
to the Session. This does mean that objects might live longer than they have to.
When all references to an origin go out of scope, we can do some cleanup. Not
so when the Session owns this data. But really, how often are iframes on
different origins being created and deleted within the lifetime of a page?

When Origins were first introduces, the Session got burdened with having to
manage multiple lifecycles:
1 - The page-surviving data (e.g. history)
2 - The root page lifecycle (e.g. page_arena, queuedNavigation)
3 - The origin lookup

This commit doesn't change that, but it makes the session responsible for
_a lot_ more of the root page lifecycle (#2 above).

I lied. js.Origin still exists, but it's a shell of its former self. It only
exists to store the SecurityToken name that is re-used for every context with
the same origin.

The v8 namespace leaks into Session.

MutationObserver and IntersectionObserver are now back to using weak/strong refs
which was one of the failing cases before this change.
2026-03-19 14:54:10 +08:00
Adrià Arrufat
f36499b806 markdown: refactor renderer into a struct to simplify argument passing 2026-03-19 15:19:11 +09:00
Karl Seguin
2b9d5fd4d9 Add adoptedStyleSheets property to ShadowRoot, just like Document
Used in github.
2026-03-19 12:09:10 +08:00
Adrià Arrufat
2dbd32d120 build: automate version resolution in build.zig
Removes manual git flags from CI and build scripts.
Versioning is now automatically derived from git and build.zig.zon.

With this PR, we follow https://semver.org/
Logic:

1. Read the version from build.zig.zon
2. If it doesn't have a `.pre` field (i.e. dev/alpha/beta) it will use that
3. Otherwise it will get the info from git: hash and number of commits since last `.0` version
4. Then build the version: `0.3.0-dev.1493+0896edc3`

Note that, since the latest stable version is `0.2.6`.
The convention is to use `0.3.0-dev`, as:
- `0.2.6` < `0.3.0.dev` < `0.3.0`
2026-03-19 13:03:29 +09:00
Karl Seguin
964fa0a8aa Add Request.signal
Allows aborting a fetch. Improves github integration
2026-03-19 11:40:16 +08:00
Karl Seguin
db01158d2d Improve unhandled rejection
We now pay attention to the type of event that causes the unhandled exception.
This allows us to trigger the window.rejectionhandled event when that is the
correct type. It also lets us no-op for other event types which should not
trigger rejectionhandled or unhandledrejection.

Fixes stackoverflow in github integration.
2026-03-19 11:36:39 +08:00
Adrià Arrufat
e997f8317e SemanticTree: add tests for backendDOMNodeId and maxDepth 2026-03-19 12:25:02 +09:00
Karl Seguin
a88c21cdb5 Fix Navigator Additions
Follow up to https://github.com/lightpanda-io/browser/pull/1884

Fixes build, uses arena/finalizer for PermissionStatus. Fixes tests. A few other
small cleanups.
2026-03-19 09:41:13 +08:00
shaewe180
e2be8525c4 Config: remove js_enum_from_string constant 2026-03-19 09:40:40 +08:00
shaewe180
c15afa23ca Session: fix page pointer handling in wait loop
- Refactor `wait` and `_wait` to handle `page` as `*Page` instead of `**Page`, preventing stale references during navigations.
- Update `networkidle` wait condition to use `_notified_network_idle == .done`.
- Document `--wait_ms` and `--wait_until` options in `Config.zig` help text.
2026-03-19 09:36:42 +08:00
Adrià Arrufat
7a7c4b9f49 SemanticTree): add backendNodeId and maxDepth support 2026-03-19 10:18:08 +09:00
Pierre Tachoire
4e6a357e6e use initTrusted for InputEvent 2026-03-18 16:41:28 +01:00
Pierre Tachoire
bf6e4cf3a6 disaptch InputEvent on input/TextArea changes 2026-03-18 16:40:21 +01:00
Pierre Tachoire
c29f72a7e8 Merge pull request #1898 from lightpanda-io/keyboard-event-bubble
Keyboard events are bubbling, cancelable and composed
2026-03-18 16:26:15 +01:00
Adrià Arrufat
d4427e4370 Merge pull request #1894 from lightpanda-io/semantic-tree-interactive
SemanticTree: implement interactiveOnly filter and optimize token usage
2026-03-18 22:33:45 +09:00
Karl Seguin
b85ec04175 Merge pull request #1902 from lightpanda-io/fix/emulation-set-user-agent-override
Fix/emulation set user agent override
2026-03-18 20:05:26 +08:00
Karl Seguin
da05ba0eb7 log on ignored setUserAgentOverride 2026-03-18 19:46:37 +08:00
Karl Seguin
414a68abeb Merge pull request #1899 from lightpanda-io/idle_task_fix
only run idle tasks from the root page
2026-03-18 19:41:58 +08:00
Karl Seguin
52455b732b Merge pull request #1885 from lightpanda-io/danling_context_fallback
Fallback to the Incumbent Context when the Current Context is dangling
2026-03-18 19:41:38 +08:00
Pierre Tachoire
ba71268eb3 Keyboard events are bubbling, cancelable and composed
According to the specs: https://w3c.github.io/uievents/#event-type-keyup
2026-03-18 12:36:00 +01:00
Adrià Arrufat
694aac5ce8 browser.interactive: optimize role checks with StaticStringMap 2026-03-18 20:10:15 +09:00
Adrià Arrufat
cbab0b712a SemanticTree: simplify TextVisitor printing logic 2026-03-18 20:07:11 +09:00
Karl Seguin
1aee3db521 only run idle tasks from the root page 2026-03-18 19:03:38 +08:00
Pierre Tachoire
f634c9843d Merge pull request #1893 from lightpanda-io/link_onload_rel
Some checks failed
zig-test / zig fmt (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
Expand rel's that trigger a link's onload
2026-03-18 09:41:10 +01:00
Pierre Tachoire
e1e45d1c5d Merge pull request #1796 from lightpanda-io/wp/mrdimidium/telemetry-common-network
Use common network runtime for telemetry messages
2026-03-18 09:34:19 +01:00