Commit Graph

4708 Commits

Author SHA1 Message Date
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
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
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
Adrià Arrufat
eab9ae0243 RobotsLayer: use managed ArrayList 2026-05-04 08:01:22 +02:00
Karl Seguin
0c55875b63 encode worker URL 2026-05-04 13:52:38 +08: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
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
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
Karl Seguin
e69bcfa4da Merge pull request #2345 from lightpanda-io/fix/cookie-samesite-json-case-guyua9
Fix/cookie samesite json case guyua9
2026-05-02 13:30:25 +08:00
Karl Seguin
3ec507773c change sameSite to string to deal with case-insensitive values 2026-05-02 12:10:57 +08:00
Karl Seguin
0c7a4f1540 Make sighandler thread-safe
Currently, variables (`attempt`, `listeners`)  can be read/written to
concurrently from 2 threads (main + the sighandler thread). This opens up
some undefined behavior. More practically, what I'm seeing is that if I ctrl-c
quickly after a `zig build run` launch, the program appears to terminate but
remains running in the background.
2026-05-02 11:58:46 +08:00
Karl Seguin
4704185980 Merge pull request #2341 from lightpanda-io/script_manager_encode
Encode script urls before making request
2026-05-02 09:39:17 +08:00
swaroski
55b5c134dc dom: toggle parent <details>.open on <summary> click
Per HTML §4.11.1.2, a <summary>'s activation behavior runs the
toggle-details-state algorithm on its parent <details>, but only when
the summary is the first summary child of that details.

Frame.handleClick previously had no arm for .generic, so summary clicks
fell into `else => {}` and details.open never changed. Add a .generic
arm gated on `_tag == .summary` that walks the parent's element
children to confirm first-summary-child, then flips details.open via
the existing Details.setOpen.

Out of scope (tracked separately): firing ToggleEvent on the parent
(no ToggleEvent type yet); activating when a descendant of <summary>
is clicked (same gap exists for <a>/<label>; needs a broader walk-up
refactor of handleClick).

Tests: src/browser/tests/element/html/summary_click.html covers
closed→open, open→closed, non-first summary no-op, and orphan summary
no-op.
2026-05-01 18:31:01 -04:00
Pierre Tachoire
47ea77f7b2 Merge pull request #2286 from navidemad/fix-b6-validity-api 2026-05-01 20:53:53 +02:00
Pierre Tachoire
76deb2552a fix Input.sameFormOwner regression 2026-05-01 18:40:49 +02:00
Karl Seguin
9fdd13a626 Encode script urls before making request
This comes from a WPT crash in /content-security-policy/blob/self-doesnt-match-blob.sub.html

The core issue is double-free on the request header list. This is a fundamental
issue about ambiguous ownership. On error, who's responsible for freeing the
request? The caller or the HttpClient. Answer: it depends when/where the error
happens. That just doesnt' work, and needs to be fixed. BUT....

There's also the issue that this specific test is failing because we aren't
properly encoding script URLs. This is a real and separate issue that also needs
to be fixed. That's what this commit does. In some ways, it's a bit superficial
because there's a real double-free issue, but this is a real issue to fix.
2026-05-01 13:00:12 +08:00
Karl Seguin
2b95b1e743 More aggressive popup cleanup, more efficient load tick
Follow up to https://github.com/lightpanda-io/browser/pull/2335 which hooks
into the tick's GC hint to close any closed window (rather than having to wait
until page unload).

Also, use schedule task for dispatchLoad which removes an check in every tick.
2026-05-01 09:06:47 +08:00
Navid EMAD
604f812827 forms: address review feedback on constraint validation API
- Cache `ValidityState` per element so repeated `el.validity` access
  returns the same instance (also avoids allocating a struct per
  per-keystroke call).
- Use `Event.initTrusted` for the `invalid` event — browser-generated.
- Use `frame.dupeString(message)` (interns short strings) instead of
  `frame.arena.dupe(u8, message)` for `setCustomValidity` storage.
- Cascade `*const Input` / `*const Select` through `getValidationMessage`,
  `suffersValueMissing`, and Select.effectiveOption.
- Factor radio-group walking into a shared `radioGroupIterator`; add the
  same-form check to `radioGroupHasChecked` (was only in
  `uncheckRadioGroup`). The form comparison uses a frame-less helper so
  it can run from the const validation path.
- Narrow `numericRangeBreach` to `.number, .range` — date/time/month/
  week/datetime-local need type-specific conversion before comparison
  (was silently returning false). TODO comment left in place.
- Add `getMinLength`/`setMinLength` getters to Input and TextArea, plus
  `getMaxLength`/`setMaxLength` to TextArea (Input already had them).
  Used internally by `suffersTooLong`/`suffersTooShort` and exposed via
  IDL.
- TODO prefix on the file-input value-missing comment so the limitation
  is greppable.

Tests cover the new IDL surface (`minLength`/`maxLength` on Input and
TextArea), the validity-state caching guarantee
(`el.validity === el.validity`), and the trusted-event flag on the
`invalid` event for Input, Select, TextArea, and Button.
2026-04-30 22:35:44 +02:00
Karl Seguin
b254671fa1 Fix failed navigation assertion
When the root frame navigates to about:blank, we still need to create an
navigation entry, else navigation's expectation (via assertions) fail.
2026-04-30 22:54:22 +08:00
Karl Seguin
216cec5e42 Merge pull request #2335 from lightpanda-io/window_close
Defer window.close()
2026-04-30 19:58:21 +08:00
Karl Seguin
f921869fb6 Defer window.close()
Cannot Frame.deinit in window.close() as that's happening inside JS runtime.
Instead, defer on Page.deinit. This is MUCH later than necessary, but I'd like
to address the timing separately. This commit, as-is, prevents real crashes.
2026-04-30 18:04:56 +08:00
Karl Seguin
fe77694437 Merge pull request #2310 from navidemad/fix-a22-iscontenteditable
dom: implement HTMLElement.isContentEditable IDL attribute
2026-04-30 16:09:56 +08:00
Karl Seguin
a591956dcc Split Script
This is a follow up to https://github.com/lightpanda-io/browser/pull/2290. That
PR spit ScriptManager into ScriptManager and ScriptManagerBase, with the
goal of letting a Worker have a ScriptManagerBase that works without needing
a frame.

But the Script object was still a large object meant to work with any type of
script invocation, e.g. it has a nullable element. This commit swaps out these
fields for a better-typed "extra" union field. So that Element only exists in
the extra.frame tag. In the end, it just makes it more explicit about what
fields are valid under specific conditions.
2026-04-30 15:30:37 +08:00