Commit Graph

6491 Commits

Author SHA1 Message Date
Karl Seguin
23e58b005e Add Notification WebAPI
Adds a pretty simplistic Notification WebAPI. Also adds a dummy drawImage to
CanvasRenderingContext2D.

Trying to improve how we're seen by https://bot.sannysoft.com/
2026-05-29 11:35:32 +08:00
Karl Seguin
f07eb3e264 Merge pull request #2562 from lightpanda-io/cookie-storage
Implement CookieStore web API
2026-05-29 08:20:50 +08:00
Karl Seguin
75993123b3 Merge pull request #2568 from lightpanda-io/navigate_schemaless_url
Improve navigate to schema-less URL
2026-05-29 08:03:47 +08:00
Karl Seguin
91ef1ff925 Merge pull request #2567 from lightpanda-io/rust_drop_warning
Heed Rust warning and replace copy with ignore
2026-05-29 08:02:49 +08:00
Pierre Tachoire
ef3faf8329 use String to return CookieListItem 2026-05-28 18:22:20 +02:00
Pierre Tachoire
b57798e4a3 Merge pull request #2569 from lightpanda-io/e2e-enable-cache
ci: always enable HTTP cache with e2e test
2026-05-28 17:58:55 +02:00
Pierre Tachoire
2c2561da50 avoid string build + parse on CookieStore.setCookie 2026-05-28 17:50:21 +02:00
Pierre Tachoire
4f2a7ba2c8 implement url option for getting cookies from CookieStore 2026-05-28 15:13:31 +02:00
Pierre Tachoire
2a47432c20 fix comments 2026-05-28 14:49:27 +02:00
Pierre Tachoire
8c9d693fd7 set max-age to 0 when cookie is expired in CookieStore 2026-05-28 14:33:30 +02:00
Pierre Tachoire
c7b9f02765 reject invalid cookie into into CookieStore 2026-05-28 14:30:36 +02:00
Pierre Tachoire
d35eaea1aa testing: deinit browser before notifications 2026-05-28 14:17:52 +02:00
Pierre Tachoire
efde428cd4 Notify the deleted cookie on change 2026-05-28 12:37:17 +02:00
Pierre Tachoire
d68f1a48ad ci: always enable cache with e2e test 2026-05-28 11:25:47 +02:00
Karl Seguin
06f279c6be Improve navigate to schema-less URL
I noticed that `fetch www.openmymind.net` worked but, `fetch www.example.com`
didn't. www.openmymind.net redirects to `https://www.openmymind.net/` so
in `frameHeaderDoneCallback` we get the updated response.url(). www.example.com
doesn't redirect, so self.url remains `www.example.com` which just doesn't work
at various parts of the code (Location.init, RobotsLayer...).

Added a quick check in Navigate, if the URL isn't a "complete" URL, stick
"http://" infront. There are probably cases where this is wrong, e.g.
'javascript:...' but these don't work anyways.

(Curl works with www.example.com of course).
2026-05-28 17:16:20 +08:00
Pierre Tachoire
6179c7dde5 replace Frame with Execution into CookieStore 2026-05-28 11:14:52 +02:00
Karl Seguin
0b4ba17236 Heed Rust warning and replace copy with ignore 2026-05-28 16:48:27 +08:00
Karl Seguin
a2b3626495 Merge pull request #2563 from lightpanda-io/message_port_and_doNotTrack
postMessage / MessageEvent now allow / track MessagePost
2026-05-28 16:39:13 +08:00
Karl Seguin
b37e5288d5 Merge pull request #2565 from lightpanda-io/null_function_guard
Guard against null function
2026-05-28 16:38:42 +08:00
Karl Seguin
79afadeb42 Merge pull request #2561 from lightpanda-io/replaceable
Make various Window/Worker accessors settable
2026-05-28 16:37:43 +08:00
Karl Seguin
e40912f4b5 Merge pull request #2559 from lightpanda-io/module_evaluation_stack
In debug, try to capture a module evaluation stack
2026-05-28 16:37:14 +08:00
Karl Seguin
26a701bb32 Merge pull request #2557 from lightpanda-io/node_insert_notification_frame
Use Node's own frame when executing on nodeIsReady
2026-05-28 16:36:43 +08:00
Karl Seguin
3348eb83b2 Merge pull request #2556 from lightpanda-io/declarative_shadow_dom
Add declarative shadow dom (DSD)
2026-05-28 16:36:11 +08:00
Pierre Tachoire
27fe1d46d8 add missing .{ .dom_exception = true } into CookieStore bridge 2026-05-28 10:08:47 +02:00
Pierre Tachoire
ad0e0445a8 avoid extra allocation for 1 value slice in CookieChangeEvent 2026-05-28 10:08:46 +02:00
Pierre Tachoire
3029f8eae2 adjust CookieStore.attachToFrame comment 2026-05-28 10:08:46 +02:00
Pierre Tachoire
9c74fed309 Implement CookieChangeEvent with CookieStore 2026-05-28 10:08:45 +02:00
Pierre Tachoire
06cc808728 first draft for CookieStore API implementation 2026-05-28 10:08:41 +02:00
Pierre Tachoire
4280e28975 Merge pull request #2564 from lightpanda-io/execution_ux_improvement
This is a very small / mechanical change.
2026-05-28 10:08:24 +02:00
Karl Seguin
1ed6cd1120 Guard against null function
I'm not sure how this is happening, but we occasionally see an attempt to
execute a null v8::Function (from crash reports). It seems pretty clear that
this is a Global that is being reset, but I can't figure out a path where
a global is reset while a callback is still active. So, in != .Debug mode, we
null check functions before executing and return an error.

This potentially will work without causing any new/different issues. If this is
a global being reset, than we must be in some teardown state, and it probably
doesn't matter if a JS callback is or isn't executed.

In case anyone ends up here and wonders about the guard, here's a stack from
a crash dump:

```
Fatal V8 Error
---
location: v8::Function::Call
message: Function to be called is a null pointer
???:?:?: 0x2ac0b59 in ??? (???)
???:?:?: 0x2ace19b in ??? (???)
/src/browser/js/Function.zig:160:41: 0x268db23 in callWithThis__anon_236231 (lightpanda)
/src/browser/EventManagerBase.zig:259:30: 0x2614b53 in dispatchDirect__anon_179346 (lightpanda)
/src/browser/EventManager.zig:137:33: 0x261737e in stateChanged (lightpanda)
/src/browser/webapi/net/XMLHttpRequest.zig:580:30: 0x2621b21 in handleError (lightpanda)
/src/browser/webapi/net/XMLHttpRequest.zig:542:21: 0x2628bbd in httpErrorCallback (lightpanda)
/src/network/layer/Forward.zig:70:13: 0x29193de in errorCallback (lightpanda)
/src/browser/HttpClient.zig:1447:36: 0x2784aa6 in processMessage (lightpanda)
/src/cdp/CDP.zig:314:24: 0x26a3244 in dispatchParsed (lightpanda)
/src/cdp/CDP.zig:187:31: 0x252df34 in drainInbox (lightpanda)
/src/browser/HttpClient.zig:416:24: 0x27f01ab in handleConnection (lightpanda)
/home/runner/work/_temp/91356985-8cc1-40de-b1b8-395a29b4bd91/zig-x86_64-linux-0.15.2/lib/std/Thread.zig:509:13: 0x26877f3 in entryFn (lightpanda)
???:?:?: 0x7df4279d11f4 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7df4279d11f4` was not available, trace may be incomplete
```
2026-05-28 11:04:55 +08:00
Karl Seguin
05daa4a6dc This is a very small / mechanical change.
Three changes:
- js.Execution now has a page (instead of calling exec.context.page)
- js.Execution now has a session (instead of calling exec.context.page.session)
- js.Execution.context renamed to .js to be consistent with Frame and WGS
2026-05-28 08:23:35 +08:00
Karl Seguin
3430bbddd8 postMessage / MessageEvent now allow / track MessagePost
Navigator properties moved from data properties to real accessors. This impact
how they're seen (and potentially treated) by JS code.

These change result in https://www.browserscan.net/bot-detection correctly
rendering. When paired with https://github.com/lightpanda-io/browser/pull/2561
we now render that page correctly (still detected as a bot, but we no longer
fail to render)
2026-05-28 08:13:21 +08:00
Karl Seguin
4e2f21990c Merge pull request #2560 from lightpanda-io/capture_401_407
Capture 401 and 407 bodies
2026-05-28 06:57:21 +08:00
Karl Seguin
15a7a66003 Make various Window/Worker accessors settable
window.console (and many others) should be settable. This is the [Replaceable]
WebIDL attribute.

This improves loading of https://www.browserscan.net/bot-detection which would
immediately break/fail because we would throw on window.console setting.

This appears to come from obfuscator.io's disableConsoleOutput flag, so the
issue might be relatively common.
2026-05-27 21:41:40 +08:00
Karl Seguin
f614d898aa Capture 401 and 407 bodies
We currently skip capturing 401 and 407 bodies. This appears to be an
optimization with the intent that it won't be needed. While that might be true
in some cases (though, not sure when), it isn't always true. A page.navigate
to a 401 should display the content.

(Also, tried to silence meaningless BrokenPipe noise in tests).
2026-05-27 19:34:39 +08:00
Karl Seguin
13547c0ff8 Add declarative shadow dom (DSD)
Normally, a shadow dom is attached to an element via `el.attachShadow(mode)`.
With DSD, the shadow dom is attached during parsing. Essentially, when we see:

<template shadowrootmode="open">...</template>

it has the end result of calling attachShadow on the parent element. This is
used increasingly by a number of frameworks, though normally with backwards
compatibility that fallbacks to doing it in JavaScript.

DSD happens during parsing and document.write, but not via innerHTML = ''.
However, both Element and DocumentFragment gain a `setHTMLUnsafe` which is like
innerHTML WITH DSD.

I initially thought this feature could be implement exactly like I describe:
when the parser adds a template, check for a `shadowrootmode` attribute and
call attachShadow...except..you need to call attachShadow on the parent, which
the parser hasn't popped yet, and it alters where the children are added.
Thankfully, html5ever has a boolean to enable/disable dsd..hence the html5ever
binding changes to (a) enable / disable this featuer and (b) the new callback.
2026-05-27 19:11:43 +08:00
Karl Seguin
158dffd543 In debug, try to capture a module evaluation stack
This requires setting SetCaptureStackTraceForUncaughtExceptions on the isolate,
so for now, I've only enabled it in debug.
2026-05-27 19:10:25 +08:00
Pierre Tachoire
7743e68c58 Merge pull request #2558 from lightpanda-io/session_deinit_memory_notification 2026-05-27 13:08:26 +02:00
Karl Seguin
930ffb5581 Notify v8 of memory pressure on session.deinit
https://github.com/lightpanda-io/browser/pull/2548 removed the _need_ to call
v8::Isolate::MemoryPressureNotification on Session.deinit and actually removed
the call.

But [my theory] is that this causes our peak memory to be higher. So, I'm
adding it back.

The point of #2548 was to open the door for improving the memory signals to v8
by removing the _need_ for this specific signal. That PR made it so that, for
correctness (UAF) we no longer _had_ to call it. The point of the PR wasn't
to necessarily improve the signals, so I don't feel too bad about putting this
back in.
2026-05-27 18:35:40 +08:00
Karl Seguin
c04c6b3827 Use Node's own frame when executing on nodeIsReady
When nodeIsReady is called from a dynamic (JS) insertion, execute any code
on the node's frame, not the frame that did the insertion.

The code is a bit uglier than it has to be, because getting the node's frame
isn't free, and we only execute code for a few types (scripts, links, ...) so
we only get the owning frame when we're sure it's needed (thus the duplication)
2026-05-27 18:13:01 +08:00
Karl Seguin
4735126507 Merge pull request #2553 from lightpanda-io/remove_legacy_test
Remove legacy test
2026-05-27 15:23:51 +08:00
Karl Seguin
ff6743af88 Merge pull request #2554 from lightpanda-io/StaticRange
Add StaticRange
2026-05-27 15:23:33 +08:00
Karl Seguin
f80a5ce3b2 Merge pull request #2555 from lightpanda-io/markdown-shadow-piercing
Add shadow dom piercing to markdown dump
2026-05-27 15:18:55 +08:00
Karl Seguin
014b8e12eb Add shadow dom piercing to markdown dump
The markdown renderer currently ignores shadow-dom. It doesn't "pierce" it, so
it'll render the light-dom (which is the template / fallback), which won't be
right.

This largely mimics the existing logic in dump.
2026-05-27 13:20:14 +08:00
Karl Seguin
7cb7d01d97 Add StaticRange
This doesn't solve anything, but I was looking at /input-events/ WPT tests and
many are stuck with due to this type not existing. I don't expect this to fix
any of those tests, but it does move them along a bit further (the /input-events
test are all based on editing capabilities that we don't have).

We already had a // todo StaticRange in AbstractRange, and since it's very
simple, why not.
2026-05-27 10:40:52 +08:00
Karl Seguin
479c29816a Remove legacy test
AFAIK, these aren't being used and I've personally not have reason to reference
/ look at them for months.

I have no issues though if we want to keep them in.
2026-05-27 08:55:04 +08:00
Karl Seguin
81c1ae7392 Merge pull request #2546 from lightpanda-io/unified_data_urls
Unify Data URLs
2026-05-27 08:33:22 +08:00
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