Commit Graph

8347 Commits

Author SHA1 Message Date
Muki Kiboigo
0ecf981f7e add assert to SyncRequest headerCallback 2026-04-28 07:01:42 -07:00
Muki Kiboigo
1370f6805b add a note about cdp callback cb 2026-04-28 07:01:42 -07:00
Muki Kiboigo
3fe774fbfb pass error all the way up to Layer chain to clean 2026-04-28 07:01:42 -07:00
Muki Kiboigo
4de1dc5424 properly call error callback in InterceptionLayer 2026-04-28 07:01:42 -07:00
Muki Kiboigo
83b047e66a assert that intercepted isn't 0 before decrementing 2026-04-28 07:01:42 -07:00
Muki Kiboigo
c719a522b8 use lightpanda module log in layers 2026-04-28 07:01:42 -07:00
Muki Kiboigo
152a792c18 use Request Arena in RobotsLayer 2026-04-28 07:01:41 -07:00
Muki Kiboigo
e56036fb50 use Request Arena in CacheLayer 2026-04-28 07:01:41 -07:00
Muki Kiboigo
fc702794c2 use Request Arena in WebBotAuthLayer 2026-04-28 07:01:41 -07:00
Muki Kiboigo
d14b75d93b use Request arnea in InterceptionLayer 2026-04-28 07:01:41 -07:00
Muki Kiboigo
bb9e238f6c Requests now use arenas from the arena pool 2026-04-28 07:01:41 -07:00
Muki Kiboigo
175c2cc288 ensure robots params have arena and request id 2026-04-28 07:01:41 -07:00
Muki Kiboigo
87eec578aa use arena pool in InterceptionLayer 2026-04-28 07:01:41 -07:00
Muki Kiboigo
13cc122e26 remove InterceptState 2026-04-28 07:01:40 -07:00
Muki Kiboigo
ca08f0c56d remove blocking from RequestParams 2026-04-28 07:01:40 -07:00
Muki Kiboigo
3db3281e8e working authentication with InterceptionLayer 2026-04-28 07:01:40 -07:00
Muki Kiboigo
d0b421b085 partial auth challenge support 2026-04-28 07:01:40 -07:00
Muki Kiboigo
dddd0dfb90 fix request id mismatch on cdp 2026-04-28 07:01:40 -07:00
Muki Kiboigo
0d50f706db more fixing of hanging in cdp interception 2026-04-28 07:01:40 -07:00
Muki Kiboigo
9c826159a0 crude InterceptionLayer 2026-04-28 07:01:40 -07:00
Muki Kiboigo
6d41ea6fd0 move arena up to Request instead of Transfer 2026-04-28 07:01:39 -07:00
Muki Kiboigo
14ad5c9cdc move RequestStart to InterceptionLayer 2026-04-28 07:01:39 -07:00
Muki Kiboigo
e37c14a714 Transfer now uses Request's request_id 2026-04-28 07:01:39 -07:00
Muki Kiboigo
e988e49136 remove Context and thread *Client 2026-04-28 07:01:39 -07:00
Muki Kiboigo
b4a9bdd7a3 use syncRequest in ScriptManager 2026-04-28 07:01:39 -07:00
Muki Kiboigo
46d0b34c54 add RequestParams and SyncRequest 2026-04-28 07:01:39 -07:00
Muki Kiboigo
5dd15aa2cf use layers for Cache, Robots and WebBotAuth 2026-04-28 07:01:39 -07:00
Pierre Tachoire
86217dd78f Merge pull request #2295 from lightpanda-io/e2e-matrix
ci: create a matrix for e2e tests
2026-04-28 16:00:52 +02:00
Karl Seguin
8ac769bb10 Merge pull request #2298 from lightpanda-io/nikneym/fix-log-level-regression
`Config`: add a custom validator for `--log-level`
2026-04-28 17:49:29 +08:00
Halil Durak
c5b16cb18e Config: add a custom validator for --log-level 2026-04-28 12:37:16 +03:00
Karl Seguin
d46be2dc2b Merge pull request #2283 from navidemad/fix-a18-navigation-referer
browser: send Referer on cross-page navigation requests
2026-04-28 16:01:10 +08:00
Karl Seguin
70c7b7aa9a Merge pull request #2292 from navidemad/fix-b5-keyboard-keycode
events: implement KeyboardEvent.keyCode and charCode legacy attributes
2026-04-28 15:46:54 +08:00
Pierre Tachoire
ece2ec3753 ci: create a matrix for e2e tests 2026-04-28 09:31:54 +02:00
Karl Seguin
1df011bb2b Improve correctness of generateKey error
Previously, the only error generateKey would throw as SyntaxError. This commit
adds validation to the input so that the correct error can be returned. This
helps a couple thousands of WPT tests to pass, e.g.

/WebCryptoAPI/generateKey/failures_AES-CBC.https.any.html

Goes from 210 / 775 to  775/775.

This does not add more crypto capabilities / algos, just validation of the
provided parameters.
2026-04-28 15:13:33 +08:00
Adrià Arrufat
86ac6232f9 Merge branch 'main' into agent 2026-04-28 09:01:29 +02:00
Navid EMAD
73a007f88e events: gate KeyboardEvent.keyCode/charCode on isTrusted, add Enter charCode
Address review feedback on the legacy KeyboardEvent.keyCode and
KeyboardEvent.charCode getters:

* `getKeyCode` and `getCharCode` now early-return 0 when the event is
  not trusted, matching Chrome's behavior. Synthetic events created via
  `new KeyboardEvent(...)` from script have `isTrusted === false` and
  therefore expose 0 for both legacy attributes; only events dispatched
  by the user agent itself surface the legacy mapping.
* `getCharCode` now uses `_type_string.eql(comptime .wrap("keypress"))`
  to match the idiom used elsewhere in the project.
* The charCode mapping is moved into a pure `Key.charCode()` helper that
  mirrors `Key.keyCode()`, including a `.Enter => 13` arm so a trusted
  `keypress` for Enter exposes `\r` (U+000D) per spec.

The JS test fixture is consolidated into a single block asserting the
Chrome-correct behavior for synthetic events. The full per-key mapping
table is now exercised via two pure-function Zig unit tests on
`Key.keyCode()` and `Key.charCode()`.
2026-04-28 07:12:29 +02:00
Navid EMAD
88b38d240d Merge remote-tracking branch 'origin/main' into fix-b5-keyboard-keycode 2026-04-28 07:00:17 +02:00
Navid EMAD
0a4c2a2743 css: apply UA stylesheet display:none defaults for unrendered elements
`StyleManager.hasDisplayNone` honored only the `[hidden]` UA-stylesheet
rule; the rest of HTML Rendering §15.3.1 ("Hidden elements") was
unimplemented. As a result `getComputedStyle(headEl).display === "block"`
and `el.checkVisibility()` returned `true` for `<head>`, `<script>`,
`<style>`, `<link>`, `<meta>`, `<title>`, `<noscript>`, `<template>`,
`<param>`, `<source>`, `<track>`, `<area>`, `<datalist>`,
`<input type="hidden">`, and the non-`<summary>` direct children of a
closed `<details>`.

Add a `matchesUaDisplayNoneRule` helper consulted at the top of
`isElementHidden` so both `getComputedStyle().display` (via
`hasDisplayNone`) and `el.checkVisibility()` (via `isHidden`'s ancestor
walker) honor the same UA-stylesheet truth. The helper covers the
`[hidden]` attribute, a new `Tag.isHiddenByUaStylesheet()` predicate
mapping the spec's unrendered tag list, the
`input[type="hidden" i]` rule, and the `details:not([open]) > *:not(summary)`
parent-relationship rule. Inline `display` overrides still win per CSS
cascade.

Closes #2293
2026-04-28 06:31:14 +02:00
Navid EMAD
7feae5a958 events: implement KeyboardEvent.keyCode and charCode legacy attributes
Both getters were stubs returning 0. Per W3C UI Events § Annex C, keyCode
should report the legacy fixed virtual key code for the key being pressed
(e.g. 84 for 't'/'T', 16 for Shift, 13 for Enter), and charCode should
report the Unicode code point of the character produced on keypress events.

Adds a keyCode() method to the Key union that maps each named variant to
its spec-defined value and computes the uppercase-ASCII fallback for
.standard printable characters. getKeyCode delegates to it. getCharCode
checks the event type and returns the first byte of _key.standard for
keypress, 0 elsewhere.

For shift-modified symbol keys (e.g. shift+1='!'), keyCode falls back to
the modified char's ASCII rather than the unmodified key's value, since
KeyboardEvent doesn't currently store the unmodified key. Spec-strict
behavior would need plumbing unmodifiedText through KeyboardEventOptions
— left as a follow-up.

Closes #2291
2026-04-28 05:25:47 +02:00
Karl Seguin
827626db67 Merge pull request #2287 from sunguru98/chore/tests-htmlcollection-empty-name
browser: fix HTMLCollection empty name WPT
2026-04-28 11:16:40 +08:00
Karl Seguin
2bbf23b3bd Merge pull request #2280 from navidemad/fix-2277-input-range-step-matching
forms: round <input type=range> value to nearest step on the step ladder
2026-04-28 10:55:48 +08:00
Navid EMAD
7f865551ca page: implement Page.getNavigationHistory and Page.navigateToHistoryEntry
Both CDP methods returned -31998 UnknownMethod even though the underlying
browsing-context history is fully tracked in webapi/navigation/Navigation.zig.
Add the two methods to the Page dispatch enum + switch and wire them to the
existing Navigation._entries / navigateInner traverse path.

getNavigationHistory walks _entries and reports {currentIndex, entries:
[{id, url, userTypedURL, title, transitionType}]}. navigateToHistoryEntry
looks up the entry by id and calls frame.navigate(url, .{ .reason = .history,
.kind = .{ .traverse = idx } }), reusing commitNavigation's traverse arm
which only updates _index without pushing a new entry. URL is duplicated
into the new frame's arena because replacePage releases the prior arena.

Closes #2288
2026-04-28 04:48:29 +02:00
Sundeep Charan Ramkumar
325aebb231 browser: fix HTMLCollection empty name WPT 2026-04-28 08:07:57 +05:30
Navid EMAD
577a405f61 forms: address review feedback on range step matching
- Drop redundant `step_attr.len == 3` guard in `snapToStep`. Zig's
  `std.ascii.eqlIgnoreCase` already short-circuits on length mismatch
  (`ascii.zig:329`), so the outer length check is wasted work.

- Implement the `value` content attribute fallback for step base.
  Per https://html.spec.whatwg.org/multipage/input.html#concept-input-min
  the chain is `min` content attr -> `value` content attr -> 0. The
  fallback was previously skipped (step base went straight from `min`
  to 0), which meant `<input type=range value="3.5" max=10>` then
  `el.value = '5.3'` snapped to `5` instead of the spec-required `5.5`.
  Threads `value_attr` through `sanitizeRange` so the fallback engages
  whenever `min` is absent or unparseable but a parseable `value`
  content attr exists.

Three new test cases cover the fallback path (s10), the unparseable
`value` attr that falls through to 0 (s11), and `min` taking precedence
over `value` attr (s12).
2026-04-28 04:19:06 +02:00
Navid EMAD
b08f9b4abd Merge remote-tracking branch 'origin/main' into fix-2277-input-range-step-matching 2026-04-28 04:08:58 +02:00
Navid EMAD
60ce8540bf forms: implement HTML constraint validation API
Adds the ValidityState interface plus validity / validationMessage /
willValidate / checkValidity / reportValidity / setCustomValidity on
HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement,
HTMLButtonElement, and HTMLFormElement (form-level checkValidity /
reportValidity iterate the form's listed elements). checkValidity
fires a cancelable `invalid` event on each element whose
ValidityState.valid is false, matching the HTML Living Standard
constraint validation algorithm.

Validity flags implemented per element type follow the spec's
per-element constraint set: Input covers valueMissing / typeMismatch
(email + url) / tooLong / tooShort / rangeUnderflow / rangeOverflow /
customError; Select covers valueMissing / customError; TextArea covers
valueMissing / tooLong / tooShort / customError; Button covers
customError (only when type=submit). patternMismatch and stepMismatch
are placeholders that return false (pattern needs JS RegExp from Zig;
step matching for <input type=range> is being landed in PR #2280);
badInput is always false because headless never receives raw user
keystrokes.

Closes #2284
2026-04-28 04:03:10 +02:00
Karl Seguin
716b6f338b Merge pull request #2279 from navidemad/fix-a20-form-attrs-on-submitter
forms: honor formaction / formmethod / formenctype on submit button
2026-04-28 09:49:48 +08:00
Navid EMAD
7237c377d3 browser: send Referer on cross-page navigation requests
Anchor click, form submit, and `location.href = ...` assignments queue a
navigation through `Frame.scheduleNavigation`, which then tears down the
originating page and rebuilds the frame in `Session.processRootQueuedNavigation`
before `Frame.navigate` issues the HTTP request. The originator's URL was
discarded with the old arena, so the request went out without a Referer
header — even though the HTML "navigate" algorithm and Fetch §4.5 require
one. `Frame.headersForRequest` (#1449) handled subresource fetches but was
never called from the navigation path.

Capture the originating frame's URL into a new `referer` field on
`NavigateOpts` at scheduling time, dup'd into the `QueuedNavigation` arena
so it survives the page tear-down. `Frame.navigate` adds it as a
`Referer:` header alongside the existing per-request headers. Iframe
initial navigation (`Frame.zig:1282`) also sets `referer = parent.url`
since the parent frame outlives that direct `navigate` call. CDP
`Page.navigate` (`.reason = .address_bar`) and `Page.reload` continue to
omit Referer — matches Chrome.

Closes #2281
2026-04-28 03:21:12 +02:00
Karl Seguin
321601b3d4 Merge pull request #2273 from lightpanda-io/constructor_arity
Add constructor arity
2026-04-28 09:12:17 +08:00
Karl Seguin
2f6ce92db2 update v8 dep 2026-04-28 08:56:22 +08:00