Commit Graph

8347 Commits

Author SHA1 Message Date
Adrià Arrufat
8171868ced browser.tools: use startsWithIgnoreCase for LP_ check 2026-05-04 11:06:25 +02:00
Adrià Arrufat
c0491bd69e agent: clean up and optimize code
- Fix typo in REPL info message.
- Optimize Recorder to avoid unnecessary allocations.
- Simplify field type detection in SlashCommand using stringToEnum.
- Remove unused yellow ANSI constant in Terminal.
- Shorten log message in McpServer.
2026-05-04 10:51:41 +02:00
Adrià Arrufat
03d883b263 agent: improve script healing atomicity and error handling 2026-05-04 10:41:46 +02:00
Adrià Arrufat
a9b3b66802 agent.mcp: prevent path traversal in task attachments 2026-05-04 10:33:46 +02:00
Adrià Arrufat
804b596d5b agent: block navigation and eval during self-heal
Restricts self-heal turns to only allow page-local commands. Commands
like `goto` and `eval_js` are now ignored to prevent the model from
navigating away or executing arbitrary scripts during healing.
2026-05-04 10:21:31 +02:00
Adrià Arrufat
fba00e33cc agent: ensure atomic message pruning 2026-05-04 10:14:27 +02:00
Karl Seguin
116cc3aee7 Merge pull request #2350 from lightpanda-io/worker_importScripts
Worker.importScripts
2026-05-04 16:00:42 +08:00
Karl Seguin
5238799f6c Merge pull request #2348 from lightpanda-io/window_close_scheduler_reset
On window.close, reset the frame's scheduler
2026-05-04 15:56:46 +08:00
Karl Seguin
b25b91447c Merge pull request #2344 from lightpanda-io/sighandler_threadsafety
Make sighandler thread-safe
2026-05-04 15:56:33 +08:00
Karl Seguin
3d8499abe4 Merge pull request #2317 from lightpanda-io/worker_xhr_fetch
Make Fetch and XHR usable from Worker
2026-05-04 15:56:10 +08:00
Adrià Arrufat
2ca7550947 agent: restrict getEnv tool to LP_ namespace
Limits the getEnv tool to variables starting with LP_ to prevent the
model from probing sensitive system environment variables or API keys.
2026-05-04 09:54:13 +02:00
Pierre Tachoire
65308f01c4 Merge pull request #2297 from lightpanda-io/pending-page
keep the existing page active until the pending one is loaded
2026-05-04 09:42:27 +02:00
Navid EMAD
f8f14efe40 forms: implement HTMLInputElement.pattern + patternMismatch validity
The `pattern` IDL attribute had no accessor registered on
`HTMLInputElement.prototype` (returned undefined despite getAttribute
working), and `Input.suffersPatternMismatch` was a TODO stub returning
false. As a result, `validity.patternMismatch` never fired for
`<input pattern="…">` and `validationMessage` was always empty for
pattern violations.

This change registers `pattern = bridge.accessor(Input.getPattern,
Input.setPattern, .{})` and rewrites `suffersPatternMismatch` to
evaluate `new RegExp("^(?:" + pattern + ")$", "v").test(value)` via
`ls.local.exec` on the owner frame. Strings are JSON-encoded for safe
interpolation. Per HTML §4.10.5.3.5, the constraint applies only to
text-like input types and skips empty values; an unparseable pattern
is ignored. `ValidityState.getPatternMismatch` now takes a `*Frame` so
the regex evaluation can reach the owner frame's V8 scope.

Closes #2351
2026-05-04 09:04:15 +02:00
Pierre Tachoire
14743e4369 replace pages array from Session to allocated active and pending pages 2026-05-04 08:59:59 +02:00
Pierre Tachoire
f9cdc12bf6 use qn.is_about_blank for check instead of string comparison
And fix comment
2026-05-04 08:59:58 +02:00
Pierre Tachoire
6e7398d586 Don't re-init fields w/ default values 2026-05-04 08:59:57 +02:00
Pierre Tachoire
35cecf6fcc fix lp.assert usage
Remove unreachable code and use `comptime IS_DEBUG` check when need.
2026-05-04 08:59:57 +02:00
Pierre Tachoire
3fc5e6d8a5 rename var old_idx into old_active_idx for clarity 2026-05-04 08:59:56 +02:00
Pierre Tachoire
38169fdb52 rename pendingOrCurrentFrame
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-05-04 08:59:55 +02:00
Pierre Tachoire
e3eb8eba46 typo fix 2026-05-04 08:59:54 +02:00
Pierre Tachoire
ddbdaafa28 refacto Session install and teardown active page 2026-05-04 08:59:54 +02:00
Pierre Tachoire
cddabe60f5 cdp: avoid request id conflict between LID- and REQ-
Use distinct key for laoder id and request id based captured response.
2026-05-04 08:59:53 +02:00
Pierre Tachoire
b2c53f4a1d update comments according to abortFrame change 2026-05-04 08:59:52 +02:00
Pierre Tachoire
e33018f40e discardPendingPage on Session.initiateRootNavigation 2026-05-04 08:59:51 +02:00
Pierre Tachoire
11172a341a cdp: use loader_id as captured response key for documents 2026-05-04 08:59:50 +02:00
Pierre Tachoire
84246c3b57 Get the pending frame from the Runner
We want to take in account the pending frame in Runner._tick to continue
to process. If we use only the current frame, we will immediately return
in case of navigation.
2026-05-04 08:59:49 +02:00
Pierre Tachoire
c251f0c03b cdp: remove replacePage and use Session.initiateRootNavigation 2026-05-04 08:59:48 +02:00
Pierre Tachoire
f7ac258b8c dispatch frame_remove and new_frame events from sesion.replacePage
So the CDP can remove/reset context and re-create isolated world
accordingly
2026-05-04 08:59:47 +02:00
Pierre Tachoire
6e1b8f6a41 always deinit http of frame/page/worker by frame id 2026-05-04 08:59:45 +02:00
Pierre Tachoire
acdddb7ec8 keep the existing page active until the pending one is loaded
During a root navigation, we keep the existing page active until we get
the headers callback from the pending page. Then
Session.commitPendingPage makes the switch.

It delays the deinit of CPD execution context to handle JS execution in
the meantime.

Now session has an array of two pages, _active_idx points to the main
page.

Both active and pending pages share the same frame_id, it must remains
stable. So this PR adds a Request.protect_from_abort to avoid removing
the request form the pending page when deinit the previous active page.
2026-05-04 08:50:26 +02:00
Karl Seguin
77a1fdc2a0 Worker.importScripts
I also noticed that failures in async assertions could be ignored, so I fixed
that and fixed a couple failing XHR tests.
2026-05-04 14:40:57 +08:00
Karl Seguin
0420802f8d Merge pull request #2349 from lightpanda-io/remove-arraylist-unmanaged
RobotsLayer: use ArrayList
2026-05-04 14:19:09 +08:00
Adrià Arrufat
eab9ae0243 RobotsLayer: use managed ArrayList 2026-05-04 08:01:22 +02:00
Adrià Arrufat
f56b0426ca Merge branch 'main' into agent 2026-05-04 07:58:57 +02:00
Karl Seguin
0c55875b63 encode worker URL 2026-05-04 13:52:38 +08:00
Adrià Arrufat
5df44fd9f4 url: add component encode set and use in tools 2026-05-04 07:52:33 +02:00
Karl Seguin
d8b16eb4f6 Make Fetch and XHR usable from Worker
Follows previous changes to make a WebAPI worker-compatible by replacing any
dependency on *Frame with *js.Execute, *Page and/or *Session. The changes here
are relatively minor since most of the existing supporting WebApis (e.g. Blob,
Response, Request) have already been migrated.
2026-05-04 13:50:30 +08:00
Adrià Arrufat
2dffd6099f Frame: use byte buffer for console messages
Replaces ArrayList(ConsoleMessage) with an allocating byte buffer.
Limits storage to 64KB and returns pre-formatted text when draining.
2026-05-04 07:45:43 +02:00
Adrià Arrufat
8ce0624f0d agent: clarify that WAIT waits for DOM presence 2026-05-04 07:23:06 +02:00
Adrià Arrufat
bdfe0c8674 browser: replace ArrayListUnmanaged with ArrayList 2026-05-04 06:54:32 +02:00
Karl Seguin
2ee398b6d5 On window.close, reset the frame's scheduler
Saw that worker.close() does this and it makes sense to do for window.close()
too.
2026-05-04 11:31:02 +08:00
Karl Seguin
b8144d3ec4 Merge pull request #2346 from navidemad/fix/libidn2-macos-strchrnul
build: provide strchrnul shim for libidn2 on macOS
2026-05-04 11:30:42 +08:00
Karl Seguin
87b7ebfc00 Merge pull request #2340 from lightpanda-io/tick_efficiency
More aggressive popup cleanup, more efficient load tick
2026-05-04 11:29:24 +08:00
Karl Seguin
cf04873d7a Merge pull request #2334 from lightpanda-io/script_mode
Split Script
2026-05-04 11:28:25 +08:00
Karl Seguin
150c401a27 Merge pull request #2313 from lightpanda-io/callback_fixes
Fix more DOM assumptions that callback and document.write can break
2026-05-04 11:28:05 +08:00
Karl Seguin
501bfe65f0 Merge pull request #2333 from webcoyote/display-dynamic-port
Display actual port when binding --port 0
2026-05-04 11:15:58 +08:00
Karl Seguin
ab93cbb56c Merge pull request #2318 from lightpanda-io/atob_btoa
Fix atob/btoa
2026-05-04 08:29:11 +08:00
Karl Seguin
0da32a73b7 Merge pull request #2337 from lightpanda-io/about_blank_navigation_assertion
Fix failed navigation assertion
2026-05-04 08:27:28 +08:00
Karl Seguin
9bea9c9dc7 Merge pull request #2347 from lightpanda-io/fix/summary-click-toggles-details
Fix/summary click toggles details
2026-05-04 08:26:57 +08:00
Karl Seguin
1b90ef58be Summary click opens details
Tweak on https://github.com/lightpanda-io/browser/pull/2342
2026-05-04 08:02:56 +08:00