Commit Graph

1797 Commits

Author SHA1 Message Date
Karl Seguin
42bc80e5b5 add indexed_get to namednodemap 2025-04-19 21:28:16 +08:00
Karl Seguin
9f7446ba56 use allocSentinel (which i didn't know about) 2025-04-19 17:25:01 +08:00
Karl Seguin
7bdea1befa Support binding JS strings to [:0]const u8
Some APIs need a null-terminated string. Currently, they have to ask for a
`[]const u8` and then convert it to a `[:0]const u8`. This is 2 allocations: 1
for jsruntime to get the `[]const u8` from v8, and then one to get the [:0]. By
supporting `[:0]const u8` directly, this is now a single allocation.
2025-04-19 16:19:46 +08:00
Pierre Tachoire
66ec087416 Merge pull request #516 from karlseguin/javascript_anchor_click
Some checks failed
e2e-test / zig build release (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
Add zig listener support to netsurf event handler
2025-04-18 15:17:37 +02:00
Karl Seguin
9b4d1d442e Allow this argument to TokenList forEach
JsObject can now be used as a normal parameter. It'll receive the opaque value.
This is largely useful when a Zig function takes an argument which it needs
to pass back into a callback.

JsThis is now a thin wrapper around JsObject for functions that was the JsObject
of the receiver. This is for advanced usage where the Zig function wants to
manipulate the v8.Object that represents the zig value. postAttach is an example
of such usage.
2025-04-18 20:38:52 +08:00
sjorsdonkers
16a30fa3b7 enum as subtype
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
2025-04-18 13:46:54 +02:00
sjorsdonkers
1cd3ebfc3f remove tnames 2025-04-18 13:46:54 +02:00
sjorsdonkers
fd170df98f node subtypes 2025-04-18 13:46:54 +02:00
Karl Seguin
a2291b0713 Add missing TokenList APIs
Add value setter, keys(), values(), entries() and forEach().

Like nodelist, forEach still doesn't support `this` arg (gotta think about
how to do this).

I think these iterable methods are missing in a few places, so I added a
generic Entries iterator and a generic Iterable.

jsruntime will now map a Zig tuple to a JS array.
2025-04-18 19:10:37 +08:00
Karl Seguin
3134ff81f4 JS clicks and MouseInput clicks trigger page navigation 2025-04-18 16:24:04 +08:00
Karl Seguin
072bc514f4 Add zig listener support to netsurf event handler
Add _click handler to HTMLElement

Register zig click listener on document.

Largely waiting on https://github.com/lightpanda-io/browser/pull/501/files to
finalize the placeholders.
2025-04-18 16:20:46 +08:00
Pierre Tachoire
581a79f3fc Merge pull request #540 from lightpanda-io/make-e2e
make: add end2end target
2025-04-18 09:49:08 +02:00
Pierre Tachoire
cccb8e9645 Merge pull request #538 from lightpanda-io/node_class_attributes
Add Node.$NODE_TYPE class attributes
2025-04-18 09:48:11 +02:00
Pierre Tachoire
646fcafa62 Merge pull request #541 from lightpanda-io/subtype_fix
Change TypeLookup values from simple index (usize) to a TypeMeta
2025-04-18 09:47:09 +02:00
Karl Seguin
615453a687 Change TypeLookup values from simple index (usize) to a TypeMeta
TypeMeta constains the index and the subtype. This allows retrieving the subtype
based on the actual value being bound, as opposed to the struct type. (I.e. it
returns the correct subtype when a Zig class is a proxy for another using the
Self declaration).

Internally store the subtype as an enum. Reduces @sizeOf(TaggedAnyOpaque) from
32 to 16.

Finally, sub_type renamed to subtype for consistency with v8.
2025-04-18 09:56:08 +08:00
Karl Seguin
361a1a21ac zig fmt :| 2025-04-18 00:10:40 +08:00
Karl Seguin
e3e3311dd0 add deprecated node types (both Chrome and FF have them) 2025-04-18 00:10:03 +08:00
Pierre Tachoire
74fa9a6b2b ci: use the demo go runner 2025-04-17 17:57:19 +02:00
Pierre Tachoire
b62faef520 make: add end2end target 2025-04-17 17:41:29 +02:00
Karl Seguin
74391d59a5 Add Node.$NODE_TYPE class attributes 2025-04-17 21:41:28 +08:00
Pierre Tachoire
1c08b3e5e4 Merge pull request #534 from lightpanda-io/mutable_response_header_value
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
Make HTTP Response header values mutable
2025-04-17 13:10:33 +02:00
Pierre Tachoire
8c489c2131 Merge pull request #506 from lightpanda-io/jsruntime
replace zig-js-runtime
2025-04-17 13:09:44 +02:00
Pierre Tachoire
19976939b7 readme: fix build-v8 target 2025-04-17 13:01:01 +02:00
Karl Seguin
4e1659b98d Disable the call arena (for now)
The call arena doesn't consider nested calls (like, from callbacks). Currently
when a "call" ends, the arena is cleared. But in a callback, if we do that,
the memory for the containing code is no longer valid, even though it's still
executing.

For now, use the existing scope_arena, instead of the call_arena. In the future
we need to track the call-depth, and only reset the call_arena when we're done
with a top-level statement.

Also:
-Properly handle callback errors
-Increase wpt file size
-Merge latest loop.zig from zig-js-runtime.
2025-04-17 18:38:47 +08:00
Pierre Tachoire
26ef8deca5 Merge pull request #535 from lightpanda-io/wsl-support-note
WSL support note
2025-04-17 11:01:09 +02:00
Karl Seguin
4e5fe5ae1a Merge pull request #536 from lightpanda-io/jsruntime-imp
test: re-introduce js source name
2025-04-17 16:18:48 +08:00
Pierre Tachoire
7f308f59b4 test: re-introduce js source name
Having a js source name is useful to detect where the error comes from.

Using `null` generates messages with `<anonymous>` source name.
eg. `ReferenceError: report is not defined\n    at <anonymous>:1:1`
vs. `ReferenceError: report is not defined\n    at teststatus:1:1`
2025-04-17 10:08:13 +02:00
Karl Seguin
f4e8bb6c66 Re-introduce postAttach
index_get seems to be ~1000x slower than setting the value directly on the
v8.Object. There's a lot of information on "v8 fast properties", and values
set directly on objects seem to be heavily optimized. Still, I can't imagine
indexed properties are always _that_ slow, so I must be doing something wrong.
Still, for now, this brings back the original functionality / behavior / perf.

Introduce the ability for Zig functions to take a Env.JsObject parameter. While
this isn't currently being used, it aligns with bringing back the postAttach /
JSObject functionality in main.

Moved function *State to the end of the function list (making it consistent with
getters and setters). The optional Env.JsObject parameter comes after the
optional state.

Removed some uncessary arena deinits from a few webapis.
2025-04-17 09:26:37 +08:00
Karl Seguin
e3638053d0 better error messages in WPT report (in line with what main branch is doing) 2025-04-16 19:34:36 +08:00
Karl Seguin
d688d8812d add missing try/catch around loop wait for wpt tests 2025-04-16 19:20:35 +08:00
Karl Seguin
4a6bf38666 ResponseHeader.get should return mutable slice 2025-04-16 16:54:28 +08:00
Sjors
f532b62913 missing space 2025-04-16 10:41:20 +02:00
sjorsdonkers
0080c8457f WSL support note 2025-04-16 10:05:52 +02:00
Karl Seguin
613904e3a4 Make HTTP Response header values mutable
The HTTP response values _are_ mutable, but because we're using std.http.Header
the type is a `[]const u8`. This introduce a custom `Header` type where the
value is `[]u8`.

The goal is largely to allow more efficient value-comparison, by allowing
calling code to lower-case in-place. I specifically have the Mime parser in
mind:

25dcae7648/src/browser/mime.zig (L134)
2025-04-16 14:05:21 +08:00
Karl Seguin
753a093689 zig fmt :| 2025-04-15 21:16:20 +08:00
Karl Seguin
ea6f8ce4d9 Add more tests
Remove index and named setters, since they aren't working, and they aren't
currently needed.
2025-04-15 20:37:59 +08:00
Karl Seguin
180359e148 zig build test --json to get duration/memory stats 2025-04-15 18:49:39 +08:00
Karl Seguin
5816443ad3 improve XHR test reliability 2025-04-15 18:24:43 +08:00
Karl Seguin
e9fce9223e add some debug lines to see if we can fix the github action 2025-04-15 15:42:55 +08:00
Karl Seguin
f6c43eaf9c Fix dockerfile (hopefully)
Add dummy --json stats output to tests

Comment typos fixed

Add make get-v8, build-v8 and build-v8-dev make targets
2025-04-15 15:18:06 +08:00
Karl Seguin
8af71be551 Import some of the zig-js-runtime env tests
- Fix passing nothing into variadic (i.e. slice) parameter
- Optimize @sizeOf(T) == 0 types by avoiding uncessary allocations
  (something zig-js-runtime is doing)
2025-04-15 15:18:06 +08:00
Karl Seguin
9e36702eb2 Improve documentation
Remove Env from caller, and don't store Env in isolate. We don't need it, we
can execute all runtime code from the Executor (which we store a pointer to
in the v8.Context)
2025-04-15 15:18:06 +08:00
Karl Seguin
cda6f89dba work on fixing github workflows 2025-04-15 15:18:06 +08:00
Karl Seguin
b8d7744563 replace zig-js-runtime 2025-04-15 15:18:04 +08:00
Karl Seguin
25dcae7648 Merge pull request #529 from lightpanda-io/document-cookie
Some checks failed
e2e-test / zig build release (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
Document cookie
2025-04-11 23:34:44 +08:00
Pierre Tachoire
ee6382ef03 dom: use cookie jar's allocator to parse cookie 2025-04-11 16:23:03 +02:00
Pierre Tachoire
0310192660 dom: assume we are using an arena for cookie 2025-04-11 14:27:08 +02:00
Pierre Tachoire
c88bc65379 cookie: use a ; w/o space for cookie separator in requests 2025-04-11 12:40:16 +02:00
Pierre Tachoire
37340dc549 dom: implement document.cookie 2025-04-11 12:19:11 +02:00
Pierre Tachoire
9b6764a852 Merge pull request #527 from lightpanda-io/update-cla
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
add bornlex to cla whitelist
2025-04-11 11:14:46 +02:00