6443 Commits

Author SHA1 Message Date
Karl Seguin
85d84c296e Merge pull request #2551 from lightpanda-io/fix-appcodename
Navigator.appCodeName returns `Mozilla`
0.3.1
2026-05-26 22:37:41 +08:00
Karl Seguin
5056c7ad2a Merge pull request #2548 from lightpanda-io/browser_finalizer_callback_identity
Move FinalizerCallbackIdentity lifetime from Session to Browser
2026-05-26 22:00:02 +08:00
Karl Seguin
2225a6ad29 Merge pull request #2429 from lightpanda-io/custom-element-reactions-v2
Custom element reactions v2
2026-05-26 21:59:28 +08:00
Karl Seguin
2ec8906339 Merge pull request #2549 from lightpanda-io/recursive_submit
Protect against recursive form submits
2026-05-26 21:58:40 +08:00
Pierre Tachoire
eb194627d4 Navigator.appCodeName returns Mozilla
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/appCodeName
2026-05-26 15:57:20 +02:00
Karl Seguin
38cdf6c4e4 Merge pull request #2542 from lightpanda-io/post_load_inline_deferred_scripts
Immediately run deferred inline scripts after "load" is fired
2026-05-26 17:57:35 +08:00
Karl Seguin
ed92ea1a5f Merge pull request #2543 from lightpanda-io/frame_document_write
Improve document.write within an iframe
2026-05-26 17:32:49 +08:00
Karl Seguin
72ad189785 Protect against recursive form submits
Fixes WPT crash /html/semantics/forms/form-submission-0/form-submission-algorithm.html

This fixes two separate possible recursive entries in the form submission
process. Both fixes are spec-accurate (hence the WPT test that specifically
tries it).

In short, the issues are  the submit -> submit -> repeat and
formdata -> submit -> formdata -> submit -> repeat.

So two guards are added to track "I'm submitting" and "I'm building the form
data".
2026-05-26 17:27:32 +08:00
Pierre Tachoire
398d9a5c39 Merge pull request #2545 from lightpanda-io/response_request_tweaks
Tweak Response and Request
2026-05-26 10:54:10 +02:00
Karl Seguin
01b8bb305b Move FinalizerCallbackIdentity lifetime from Session to Browser
A v8 Finalizer can fire at any point, including after the underlying Zig object
has been freed. Even after the corresponding Frame and Page have been freed.

To deal with this, v8 Finalizers are tied to a special
FinalizerCallback.Identity (fci) which tracks whether the underlying Page still
exists (fci.done == true). This ensures that, if v8 calls an finalizer much
later, we don't UAF. All we have to do is cleanup the fci itself and exit -
everything else is already gone.

The problem is, we tied the fci's to the session, but the v8 Finalizer can
outlive the Session (which is meaningful to v8). We made this work by trying
to force the isolate to reclaim memory on session deinit. The problem with this
is that it still isn't guaranteed to work (though, practically speaking, if
this _has_ resulted in any UAF, it's been rare). PLUS it puts load on the v8
worker threads that can compound over short-lived sessions.

The fix is to move the fci to the browser. This is safe because Browser ==
Env == Isolate, so when the browser is torn down, the isolate is torn down, and
at THAT point, we're sure no Finalizers can fire.

With this change, the call to `memoryPressureNotification(.critical)` in
Session.deinit has been removed.
2026-05-26 16:43:28 +08:00
Pierre Tachoire
cccf461a0e Merge pull request #2547 from mvanhorn/osc/fix-comment-typos
chore: fix three typos in comments and error message
2026-05-26 10:31:00 +02:00
Pierre Tachoire
c15cd46c85 Merge pull request #2541 from lightpanda-io/import_meta.resolve
implement import.meta.resolve
2026-05-26 10:04:00 +02:00
Matt Van Horn
e361540c2d chore: fix three typos in comments and error message
- src/cdp/CDP.zig L1029 (was L780 in previous scan): "we dont' want" -> "we don't want"
- src/storage/sqlite/Pool.zig L101: test comment "single connetion" -> "single connection"
- src/storage/sqlite/Sqlite.zig L201: @compileError message "unsupport column type" -> "unsupported column type"

Comment / compile-time string only; no runtime behavior change.
2026-05-26 00:48:52 -07:00
Pierre Tachoire
e7cb9253a6 Merge pull request #2540 from lightpanda-io/websocket_worker
make websocket work in worker
2026-05-26 09:37:16 +02:00
Pierre Tachoire
63a8e6dd52 Merge pull request #2539 from lightpanda-io/accname_content_for_name
Accessibility: use content for name for specific role
2026-05-26 09:34:51 +02:00
Karl Seguin
c846fa2faf Tweak Response and Request
Implement `bodyUsed` getter for both types. With this implemented, correctly
reject requests when `bodyUsed == true`.

Expand Response to use BodyInit (Request was already using it).

Expand BodyInit to discriminate between a TypedArray/BufferArray and a string,
which allows us to capture the correct content type.

Add Request.priority and in Request/Response body getters, strip BOM as needed.
2026-05-26 10:01:55 +08:00
Karl Seguin
9fb631bd4d Merge pull request #2506 from lightpanda-io/next-tick-client
Serve Cache from Next Client Tick
2026-05-26 08:42:52 +08:00
Muki Kiboigo
2043f3e3b1 use next_tick_count to limit drain count 2026-05-25 17:13:16 -07:00
Muki Kiboigo
17e166c35f assert that next_tick_count is 0 after abort 2026-05-25 17:12:40 -07:00
Muki Kiboigo
c927fc927d decrement next_tick_count when canceled 2026-05-25 17:05:48 -07:00
Karl Seguin
228fdafa11 Merge pull request #2544 from lightpanda-io/cache-evict
Cache Eviction
2026-05-26 07:38:12 +08:00
Muki Kiboigo
f0bc85f117 add Cache Eviction 2026-05-25 11:23:25 -07:00
Muki Kiboigo
a4c535370b add optional Abort handler to runNextTick 2026-05-25 11:05:11 -07:00
Muki Kiboigo
aa90575f82 iterate through NextTickQueue without popFirst 2026-05-25 10:52:52 -07:00
Muki Kiboigo
00ccb5ed52 NextTickNode is owned by Transfer 2026-05-25 10:52:51 -07:00
Muki Kiboigo
f4de603cf5 properly deinit transfer on runNextTick 2026-05-25 10:09:53 -07:00
Muki Kiboigo
a828a5cd78 properly wait for all next ticks to be flushed 2026-05-25 10:06:50 -07:00
Muki Kiboigo
766e163ef1 properly handle cancellation of next tick events 2026-05-25 10:06:50 -07:00
Muki Kiboigo
a295a7a21a various changes to properly track next ticked transfers 2026-05-25 10:06:50 -07:00
Muki Kiboigo
cd5e5ece40 serve from cache on next client tick 2026-05-25 10:06:49 -07:00
Muki Kiboigo
274ee25fb2 add NextTickQueue to HttpClient 2026-05-25 10:06:17 -07:00
Karl Seguin
d2b495113c Improve document.write within an iframe
This fixes two things. First, it better tracks the calling context and the
target context, so that if a parent frame does a document.write within a child
frame, any JavaScript is executed in the child frame's context (previously, it
would be executed in the parent's context).

Second, it ensures that, on document.write, we force-execute any pending
scripts. This is related to https://github.com/lightpanda-io/browser/pull/2542
but applies specifically to document.write.
2026-05-25 20:46:53 +08:00
Karl Seguin
0d9482ccbf Immediately run deferred inline scripts after "load" is fired
Currently, any inline deferred script, e.g:

<script type=module>
...
</script>

That happens AFTER load, never executes. Unclear how serious an issue this is,
but it _does_ cause problems for some WPT tests which use document.write to
inject a <script type="module">...</script> block after an iframe is loaded.
2026-05-25 18:16:44 +08:00
Karl Seguin
d03215492c implement import.meta.resolve 2026-05-25 16:54:52 +08:00
Karl Seguin
24639890a7 make websocket work in worker 2026-05-25 13:29:37 +08:00
Karl Seguin
8472d21c59 Accessibility: use content for name for specific role
For typically name-less elements, check the "role" attribute to see if we should
fallback to the content.

Improves a handful of WPT tests, e.g.: /accname/name/comp_text_node.html

(It seems impossible to get 100% on these tests without knowing what is and
isn't a block-level element which would require more knowledge in the
StyleManager).
2026-05-25 12:46:20 +08:00
Karl Seguin
9dc81f129c Merge pull request #2538 from lightpanda-io/feat-implement-file-api
Feat implement file api
2026-05-25 12:10:41 +08:00
Karl Seguin
d3c5c31a93 deduplicate File and Blob init 2026-05-25 11:36:17 +08:00
Karl Seguin
dc4218159a Merge pull request #2523 from navidemad/fix/2363-about-blank-replaces-document
Replace active page on synthetic root navigation (about:blank, blob:)
2026-05-25 09:19:30 +08:00
Karl Seguin
43a592d2fc small dedupe for arena release 2026-05-25 09:05:37 +08:00
Karl Seguin
43102317aa Merge pull request #2524 from willmafh/auth_challenge_parse_bugfix
bugfix: get scheme correctly when there is any leading whitespace
2026-05-24 16:44:00 +08:00
Armaan Sandhu
a7e3bea672 feat(webapi): implement W3C File API 2026-05-24 13:04:33 +05:30
willmafh
2d48926f1e bugfix: get scheme correctly when there is any leading whitespace 2026-05-23 12:39:34 +08:00
Karl Seguin
67a9aba79c Log on lack of Reaction scope in debug
Flag Range.cloneContents as CEReactions

setAttributeNode triggers single reaction, rather than a remove + add.
2026-05-23 07:52:35 +08:00
Karl Seguin
a8f01ae253 Skip reaction scope for getters 2026-05-23 07:52:34 +08:00
Karl Seguin
ca20a2c7f6 Use backup queue when one doesn't exist
Turns a crash into a slightly delayed (incorrect) execution order which has some
basis in the spec.
2026-05-23 07:52:34 +08:00
Karl Seguin
89814fd855 Fix ce_reactions audit gaps and iterator-invalidation UAF
popAndInvoke captured the reactions queue as a slice at loop entry. If
firing a reaction triggered a nested scope whose enqueue grew the
underlying ArrayList, the captured slice became dangling and the next
iteration read freed memory. Switch to indexed iteration so the queue
pointer is re-read each step. Repros via wpt/custom-elements/
enqueue-custom-element-callback-reactions-inside-another-callback.html.

The rest of the diff adds .ce_reactions = true to bridge declarations
that were missing it per WebIDL [CEReactions] *and* whose Zig impl
actually performs a DOM/attribute mutation (verified by reading each
setter). Without the flag, the algorithm's enqueue path hits
assertScopeActive and panics. Runtime-state-only setters (Input.value,
Input.checked, Select.value, Option.selected, Media.muted/volume, etc.)
are deliberately left untagged.

Covered:
- CustomElementRegistry.define, .upgrade
- HTMLDocument: body, title, dir
- Document: open, close
- HTMLElement base: insertAdjacentHTML, dir, hidden, lang, tabIndex,
  title, innerText
- Range: insertNode, deleteContents, extractContents,
  surroundContents, createContextualFragment
- Selection: deleteFromDocument
- HTMLOptionsCollection: add, remove
- DOMStringMap (dataset): namedIndexed setter/deleter — required adding
  .ce_reactions to NamedIndexed.Opts in bridge.zig
- ~28 HTMLxxxElement files: every settable attribute that resolves to
  setAttributeSafe/removeAttribute (Anchor, Button, Canvas, Data,
  Details, Dialog, FieldSet, Form, IFrame, Image, Input, Label, Link,
  LI, Media, Meta, OL, OptGroup, Option, Quote, Script, Select, Slot,
  Style, TableCell, Template, TextArea, Time, Track, Video)
2026-05-23 07:52:34 +08:00
Karl Seguin
6eeb97c220 CustomElement Reactions
While this PR touches a lot of files, and isn't trivial, many of the changes
are either:
1 - removing guards added in previous PRs, e.g.
    https://github.com/lightpanda-io/browser/pull/1969
    https://github.com/lightpanda-io/browser/pull/2172
    https://github.com/lightpanda-io/browser/pull/2313
    https://github.com/lightpanda-io/browser/pull/2366

2 - Adding the `.ce_reactions = true` flag to various WebAPIs

CustomElements have callbacks, e.g. connectedCallback. Also, many WebAPI calls
are implemented as a series of mutations, e.g. appendChild = remove from current
+ append to new.

These two things interact in an important way: when should callbacks execute?
Before this PR, we were invoking callbacks at each individual step. This is
(a) technically wrong and (b) breaks a lot of assumptions (the reason the above
4 PRs were needed to fix bugs).

This PR adds a `_ce_reactions` queue to the frame. And, instead of invoking
callbacks, we "enqueue" the reaction. At various boundaries, a scope is created
the DOM manipulation is done, and then we pop the scope, invoking all queued
reactions.
2026-05-23 07:52:32 +08:00
Karl Seguin
93d2e9689b Merge pull request #2522 from lightpanda-io/WebDriver_getComputedLabel
Add WebDriver getComputedLabel
2026-05-23 07:49:44 +08:00
Pierre Tachoire
9619738111 Merge pull request #2517 from navidemad/makefile/download-v8
Add `make download-v8` to fetch prebuilt V8 and skip the source build
2026-05-22 15:53:48 +02:00