Commit Graph

5600 Commits

Author SHA1 Message Date
Karl Seguin
5c33c8fc3c Merge pull request #2158 from lightpanda-io/websocket_tweaks
WS.close returns DOMException
2026-04-15 07:08:37 +08:00
Karl Seguin
eb0af793c2 WS.close returns DOMException
Cleanup WS after sending disconnetion events

Mapping support for []f32 and []f64

Default max WS connections 8 -> 64
2026-04-14 21:58:43 +08:00
Pierre Tachoire
28614479ae Merge pull request #2153 from lightpanda-io/cdp-useragent
cdp: Emulation.setUserAgentOverride implementation
2026-04-14 13:53:19 +02:00
Karl Seguin
2cdaac780b Merge pull request #2155 from lightpanda-io/nikneym/fetch-cookie-jar
`Fetch`: cookie jar should only be included for `include` and same or…
2026-04-14 19:45:28 +08:00
Halil Durak
c42e242897 Fetch.init: prefer isSameOrigin for comparison 2026-04-14 13:12:48 +03:00
Halil Durak
f9fc858212 Page.isSameOrigin: !bool -> bool 2026-04-14 13:12:48 +03:00
Halil Durak
e698028e3a Fetch: cookie jar should only be included for include and same origin requests 2026-04-14 13:12:48 +03:00
Karl Seguin
5226df9968 Tweak tests
De-duplicate user agent validation
2026-04-14 17:11:54 +08:00
Karl Seguin
1a2d0934e6 Merge pull request #2078 from lightpanda-io/worker
Worker
2026-04-14 16:00:26 +08:00
Karl Seguin
b088c42980 update workers for better cdp integration 2026-04-14 12:42:07 +08:00
Karl Seguin
1adb371902 fix rebase 2026-04-14 12:24:10 +08:00
Karl Seguin
4c02959596 update workers to use new arena pool 2026-04-14 12:24:09 +08:00
Karl Seguin
60249f5e5d update v8 dep 2026-04-14 12:24:09 +08:00
Karl Seguin
197de3dc0c Limit Worker API to supported types
In order for an API to be supported by workers, their dependency on *Page has
to be removed. To keep this PR smaller, we're only converting a minimum number
of APIs from Page to Execution. All other APIs should not be exposed to the
worker (better to get a FormData undefined than to try to segfault trying to
execute FormData without a page).
2026-04-14 12:24:09 +08:00
Karl Seguin
d1d561f5c1 Worker.close() 2026-04-14 12:24:09 +08:00
Karl Seguin
3830ccfdf2 support worker navigating using object url blobs 2026-04-14 12:24:09 +08:00
Karl Seguin
b3a8a7454e add error callbacks for workers 2026-04-14 12:24:09 +08:00
Karl Seguin
5e7f891546 Add unhandledPromiseRejection for Worker
Allow *Session to be injected into WebAPI for more generic webapis between
page and workers.
2026-04-14 12:24:09 +08:00
Karl Seguin
0247b21483 Improve event dispatching between/from workers 2026-04-14 12:24:08 +08:00
Karl Seguin
ce6b01f7f6 Allow structuredClone to target a different context 2026-04-14 12:24:08 +08:00
Karl Seguin
fb844a17b6 Worker WebAPI 2026-04-14 12:24:08 +08:00
Karl Seguin
951986b655 Create Worker context in snapshot
Turns out you can embed multiple contexts within a snapshot. So our snapshot
now contains the Page context (as before) but also the Worker context. This
gives us the performance benefit of snapshots and makes context creation for
pages and workers much more similar.
2026-04-14 12:24:08 +08:00
Karl Seguin
7ca3aa61e9 Make context work with Page of WGS
A context can be created for either a Page or a Worker. This removes the
Context.page field and replaces it with a Context.global union.
2026-04-14 12:24:08 +08:00
Karl Seguin
cd2bb28c6c Tweak snapshot for workers
We'll have two types of contexts: one for pages and one for workers. They'll
[probably] both be js.Context, but they'll have distinct FunctionTemplates
attached to their global. The Worker template will only contain a small subset
of the main Page's types, along with 1 or 2 of its own specific ones.

The Snapshot now creates the templates for both, so that the Env contains the
function templates for both contexts. Furthermore, having a "merged" view like
this ensures that the env.template[N] indices are consistent between the two.

However, the snapshot only attaches the Page-specific types to the snapshot
context. This allows the Page-context to be created as-is (e.g. efficiently).
The worker context will be created lazily, on demand, but from the templates
loaded into the env (since, again, the env contains templates for both).
2026-04-14 12:24:08 +08:00
Karl Seguin
4e385a3d13 Introduce Execution
A Worker has no page. So any API that is accessible to a worker cannot take
a *Page parameter. Such APIs will now take a js.Execution which the context
will own and create from the Page (or from the WorkerGlobalScope when that's
created).

To test this, in addition to introducing the Execution, this change also updates
URLSearchParams which is accessible to Worker (and the Page obviously). This
change is obviously viral..if URLSearchParams no longer has a *Page but instead
has an *Execution, then any function it calls must also be updated.

So some APIs will take a *Page (those only accessible from a Page) and some will
take an *Execution (those accessible from a Page or Worker). I'm ok with that.

A lot of private/internal functions take a *Page, because it's simple, but all
they want is a call_arena or something. We'll try to update those as much as
possible. The Page/Execution being injected from the bridge is convenient, but
we should be more specific for internal calls and pass only what's needed.
2026-04-14 12:24:06 +08:00
Karl Seguin
f2a2acc1aa Merge pull request #2134 from lightpanda-io/cache_public_default
Cache-Control is public by default
2026-04-14 12:22:25 +08:00
Karl Seguin
48e8b7dc81 Merge pull request #2156 from lightpanda-io/lid-as-reqid
cdp: accept LID- as requestId prefix
2026-04-14 08:07:58 +08:00
Pierre Tachoire
a114106790 cdp: accept LID- as requestId prefix 2026-04-13 23:46:37 +02:00
Karl Seguin
1ee7641f54 Merge pull request #2138 from lightpanda-io/range_error
Map a zig error.RangeError to a proper JS RangeError
2026-04-13 22:50:35 +08:00
Karl Seguin
12a0fb3fb6 Merge pull request #2137 from lightpanda-io/http_abrupt_close
Handle http response with closed socket
2026-04-13 22:50:18 +08:00
Karl Seguin
2f2f74ef4b Merge pull request #2135 from lightpanda-io/mo_cleanup
On Page cleanup, capture next linked list node _before_ releasing MO
2026-04-13 22:49:59 +08:00
Karl Seguin
9a05fd8af4 Merge pull request #2154 from lightpanda-io/cdp_request_id
Improve loaderId and requestId compatibility
2026-04-13 22:49:27 +08:00
Karl Seguin
ce811c1b48 Merge pull request #2142 from lightpanda-io/formdata_encoding
Encode form data based on the form (or documents) encoding.
2026-04-13 19:51:17 +08:00
Karl Seguin
6723d6642a 'fix' test 2026-04-13 19:51:04 +08:00
Karl Seguin
cdd109a41b Improve loaderId and requestId compatibility
This introduces two slightly related changes.

My understanding is:

- frameId represents the page. Even if the page navigates, it's the same
  frameId. We capture this in Page._frame_id. Nothing here changes.

- loaderId is essentially for a specific document of the page. If the page
  navigates, it should be a different loaderId. We were using a distinct
  loaderId per request. Not sure what problems that caused. But it was wrong.
  This was achieved by exposing Page.id to CDP.

- requestId was mostly correct: unique per request. HOWEVER, for the original
  document, apparently, requestId == loaderId. This change is particularly
  important for various puppeteer and playwrightb behavior. This is a bit
  hacked. CDP will look at the resource_type, if it's .document, it'll return
  the loaderId, else it returns the requestId it always id.
2026-04-13 18:33:43 +08:00
Karl Seguin
cd4e977020 Merge pull request #2150 from lightpanda-io/eventcounts
Add EventCounts API
2026-04-13 18:33:24 +08:00
Karl Seguin
3fe8c3ee8f Merge pull request #2148 from lightpanda-io/fix_typedarray_offset
Correctly treat a view's offset as a byte offset, not an element offset
2026-04-13 18:33:08 +08:00
Karl Seguin
ca061b46b7 Merge pull request #2149 from lightpanda-io/websocket_protocol
Basic protocol support for websocket.
2026-04-13 17:34:28 +08:00
Karl Seguin
577629f536 Merge pull request #2151 from lightpanda-io/text_decoder_streaming
TextDecoder streaming stop
2026-04-13 17:34:16 +08:00
Pierre Tachoire
920ae57f9a cdp: ignore UA containing Mozilla
Instead of returning an error when the UA contains Mozilla, we ignore
the option and log an message.
2026-04-13 11:25:16 +02:00
Pierre Tachoire
1589445ec0 zig fmt 2026-04-13 10:36:35 +02:00
Pierre Tachoire
21e27a257d cdp: add warning for non-implemented params on Emulation.setUserAgentOverride 2026-04-13 10:32:36 +02:00
Pierre Tachoire
05a08f1f97 cdp: forward Network.setUserAgentOverride to Emulation.setUserAgentOverride 2026-04-13 10:23:55 +02:00
zed
9fe3a48c3a test: add tests for setting CDP user agent 2026-04-13 10:23:54 +02:00
zed
5e5a573a9f new: allow CDP change useragent 2026-04-13 10:23:54 +02:00
Karl Seguin
299104ff1d TextDecoder streaming stop
When we stop streaming, we need to use any previously streamed data as part of
the last "unstreamed" chunk. Or, put differently, when stream is false, that
merely stops any subsequent streams, it doesn't discard any previously streamed
data.
2026-04-13 13:06:16 +08:00
Karl Seguin
592dc3e18d Add EventCounts API 2026-04-13 12:30:49 +08:00
Karl Seguin
5c161260fd don't break union probing 2026-04-13 11:35:32 +08:00
Karl Seguin
28a7e7fe45 Basic protocol support for websocket.
Websockets client can send a Protocol which the server can agree to. This isn't
as fancy as it sounds. We just send a specific header on websocket handshake
and then read the response header.
2026-04-13 11:21:59 +08:00
Karl Seguin
de167861c6 handle null buffers 2026-04-13 10:03:19 +08:00