Commit Graph

6062 Commits

Author SHA1 Message Date
Karl Seguin
00d0a9f3b0 Merge pull request #2366 from lightpanda-io/custom_element_callbacks_again
Protect DOM mutations against custom element callbacks.
2026-05-06 08:02:16 +08:00
Karl Seguin
ca4444e389 Merge pull request #2362 from lightpanda-io/slience_test_log
silence an unecessary test log
2026-05-06 07:53:40 +08:00
Karl Seguin
a3891c4f68 Merge pull request #2364 from lightpanda-io/response_double_free
Protect against response double-free
2026-05-06 07:53:26 +08:00
Karl Seguin
0ca3f2d8ec Merge pull request #2365 from lightpanda-io/dom_version_node_frame
Track DOM version based on the node's owning frame
2026-05-06 07:53:13 +08:00
Karl Seguin
5112adc69f Protect DOM mutations against custom element callbacks.
Same issue as https://github.com/lightpanda-io/browser/pull/2313

DOM mutations have certain expectations that custom element callbacks can
violate.
2026-05-05 19:22:34 +08:00
Pierre Tachoire
b506e7998f Merge pull request #2360 from lightpanda-io/wp/mrdimidium/fix-crash
Fix v8 crash
2026-05-05 12:43:36 +02:00
Karl Seguin
becbd54f4e Track DOM version based on the node's owning frame
This fixes 2 separate issues, driven by the [very] broken
/dom/ranges/Range-insertNode.html WPT test.

The first, and simplest, is that when a script element is cloned, its executing
_executed and _force_async flags need to be copied. This prevents double-
execution.

The second is more complicated: dom version tracking (as a caching mechanism
used in various live collection) has to be against the node's owning frame, not
the frame that's executing the JavaScript. This includes both the version
checking and version change (on dom mutation). This introduces a relatively
expensive node -> document -> frame on every mutation and cache read. This is
potentially worth optimizing somehow, in a follow up PR. Two options come to
mind:

1 - Track a single dom version on the Page. Mutation in frame1 invalidates
    frame2.
2 - Optimize for the frame-less case. If a page has no frame, then the calling
    context should be equal to the owning document's frame.
2026-05-05 18:41:13 +08:00
Karl Seguin
8ee644d9bf Protect against response double-free
When Fetch.httpErrorCallback rejects the promise, microtasks are run. Those
microtasks could do anything, including triggering a frame shutdown (e.g. via
a navigation event). The result is that we end up with

httpErrorCallback
  httpShutdownCallback

And the code simply isn't designed to handle that. httpErrorCallback now takes
control of the cleanup, capturing the `self._owns_response` in a local, and
disabling so that any nested `httpShutdownCallback` are noops.
2026-05-05 15:19:10 +08:00
Karl Seguin
bdc9013241 silence an unecessary test log 2026-05-05 07:52:37 +08:00
Karl Seguin
d360fcc07b Merge pull request #2352 from navidemad/fix-input-pattern-validation
forms: implement HTMLInputElement.pattern + patternMismatch validity
2026-05-05 07:49:18 +08:00
Karl Seguin
91074ea834 Merge pull request #2361 from lightpanda-io/worker_deinit_order
Fix potential use-after-free by clearing worker AFTER frame context
2026-05-05 07:34:42 +08:00
Karl Seguin
d1d85e9f5d Fix potential use-after-free by clearing worker AFTER frame context 2026-05-05 07:21:37 +08:00
Karl Seguin
bc081247e7 update v8 dep 2026-05-05 07:04:02 +08:00
Nikolay Govorov
e5a9f8ba2e Fix ony more crash 2026-05-04 18:12:47 +01:00
Nikolay Govorov
5cc8a0daff Fix v8 crash 2026-05-04 17:21:15 +01:00
Nikolay Govorov
9c669974e4 Merge pull request #2359 from lightpanda-io/wp/mrdimidium/spli-cdp-http
Reorganize Server, Client, CDP and HttpClient
2026-05-04 17:03:19 +01:00
Nikolay Govorov
9a312a4177 Refactor server/client/cdp structure 2026-05-04 16:41:22 +01:00
Pierre Tachoire
0794fbdc68 upgrade zig-v8-fork 2026-05-04 17:27:44 +02:00
Pierre Tachoire
cf7dbc98de use v8 RegExp for Input.suffersPatternMismatch 2026-05-04 14:41:38 +02:00
Karl Seguin
112d4d1603 Merge pull request #2356 from lightpanda-io/cdp-audits
cdp: rename Audit into Audits
2026-05-04 19:03:35 +08:00
Pierre Tachoire
080e1e6415 cdp: rename Audit into Audits 2026-05-04 12:42:55 +02:00
Karl Seguin
6b896ba243 Merge pull request #2355 from lightpanda-io/worker_timers
Extract Window Scheduling and re-use it in Worker
2026-05-04 18:18:31 +08:00
Karl Seguin
d1bf44b686 Extract Window Scheduling and re-use it in Worker
Add worker.setInterval, clearInterval, setTimeout, clearTimeout by extracting
the scheduling logic from Window and making it use Execution rather than Frame.
2026-05-04 17:57:05 +08:00
Pierre Tachoire
5aa47f0837 Merge pull request #2354 from lightpanda-io/brew-AUR
README: add hombrew and AUR install
2026-05-04 11:42:07 +02:00
Pierre Tachoire
584d817d2e Merge pull request #2353 from lightpanda-io/remove-archlinux-pkg
ci: remove archlinux packaging
2026-05-04 11:40:43 +02:00
Pierre Tachoire
a266ae7c51 README: add hombrew and AUR install 2026-05-04 11:36:52 +02:00
Pierre Tachoire
2fde24c9c1 ci: remove archlinux packaging
Better use
```
yay -S lightpanda-bin
```
2026-05-04 11:29:24 +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
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