Commit Graph

3368 Commits

Author SHA1 Message Date
Karl Seguin
1b288c541a Merge pull request #1616 from lightpanda-io/URL_createObjectURL
Add URL.createObjectURL and URL.revokeObjectURL
2026-02-21 07:02:01 +08:00
Karl Seguin
2612b8c86f Merge pull request #1617 from lightpanda-io/cookie_fixes
Add more cookie tests
2026-02-21 07:01:47 +08:00
Karl Seguin
3e2796d456 Merge pull request #1611 from lightpanda-io/utf_range_offsets
Get both start and end bytes in a single pass
2026-02-21 07:01:30 +08:00
Pierre Tachoire
7092913863 Merge pull request #1615 from lightpanda-io/css_escape_null
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (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
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
prorper escaping of null character
2026-02-20 15:38:54 +01:00
Pierre Tachoire
67625fc347 Merge pull request #1600 from lightpanda-io/formdata_disabled_fieldset
FormData recognizes (and skips over) disabled fieldsets
2026-02-20 15:35:03 +01:00
Pierre Tachoire
eb55030b06 Merge pull request #1584 from egrs/fix-textarea-selection-insert
fix textarea text insertion to respect selection range
2026-02-20 15:24:39 +01:00
egrs
6e1b2d50f2 fix DocumentType.remove, MutationRecord.attributeNamespace, createElementNS casing
- add ChildNode.remove() to DocumentType (flips DocumentType-remove.html)
- return null for MutationRecord.attributeNamespace on non-namespaced
  attribute mutations (flips MutationObserver-takeRecords.html)
- stop lowercasing in createElementNS per spec — only createElement
  should ASCII-lowercase for HTML namespace (flips
  Element/Document-getElementsByTagNameNS.html)
- fix getElementsByTagName to use case-insensitive matching for HTML
  namespace elements
2026-02-20 14:46:58 +01:00
Adrià Arrufat
c6f72c44b8 markdown: simplify rendering logic and state management 2026-02-20 22:04:36 +09:00
Karl Seguin
d38ded0f26 Merge pull request #1613 from egrs/lookup-namespace-uri
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
implement Node.lookupNamespaceURI() and isDefaultNamespace()
2026-02-20 20:48:05 +08:00
egrs
ec20b7bd3a implement Node.lookupNamespaceURI() and Node.isDefaultNamespace()
Implements the DOM spec algorithms for namespace lookup on all node
types. Stores custom namespace URIs in a page lookup for elements
created via createElementNS with unknown namespaces. Fixes
setAttributeNS to preserve qualified names for xmlns namespace
declarations.

Flips dom/nodes/Node-lookupNamespaceURI.html: 0/75 → 75/75.
2026-02-20 13:25:09 +01:00
Karl Seguin
0766cf464a Merge pull request #1612 from egrs/fix-childnode-sibling-ordering
fix ChildNode after() and replaceWith() sibling ordering
2026-02-20 20:24:29 +08:00
egrs
867f00e091 fix ChildNode after() and replaceWith() sibling ordering
after() captured node.nextSibling() once, which went stale when that
sibling was one of the nodes being inserted. Use viableNextSibling() to
find the first following sibling not in the nodes list per the DOM spec.

replaceWith() in CData had the same stale-reference problem and also
removed self before inserting, unlike Element.replaceWith() which keeps
self as the insertion anchor. Adopt the same anchor pattern: insert
before self, then remove self at the end.

Flips ChildNode-after.html from 33/45 to 45/45 and
ChildNode-replaceWith.html from 27/33 to 33/33.
2026-02-20 13:12:34 +01:00
Karl Seguin
c823b8d7ae Add more cookie tests
Fix trimming and incorrect early loop termination when  expiring cookies.
2026-02-20 20:03:18 +08:00
Karl Seguin
393d4d336c Add URL.createObjectURL and URL.revokeObjectURL 2026-02-20 19:34:57 +08:00
Karl Seguin
2cb3f2d03d prorper escaping of null character 2026-02-20 18:44:54 +08:00
Karl Seguin
279f2dd633 Merge pull request #1599 from lightpanda-io/input_sanitize_ownership
Improve and fix sanitized value ownership.
2026-02-20 18:40:51 +08:00
Karl Seguin
dec051a6e0 Merge pull request #1603 from egrs/wpt-spec-guards
spec compliance: missing validation guards
2026-02-20 15:33:06 +08:00
Karl Seguin
790fdd320c Merge pull request #1610 from lightpanda-io/add_js_nullablestring
Add js.NullableString
2026-02-20 15:30:15 +08:00
Karl Seguin
feb4a364a7 Merge pull request #1608 from egrs/null-domstring-constants
add DOMException legacy error code constants
2026-02-20 15:30:01 +08:00
egrs
1140149e1e add dom_exception flag to Element.replaceChildren 2026-02-20 08:22:29 +01:00
egrs
2ee9599b6e add DOMException legacy error code constants
Add all 25 legacy constants (INDEX_SIZE_ERR through DATA_CLONE_ERR)
to DOMException on both constructor and prototype, enabling WPT
assert_throws_dom checks that reference e.code.
2026-02-20 08:13:23 +01:00
Karl Seguin
188d45e002 Get both start and end bytes in a single pass
Follow up to https://github.com/lightpanda-io/browser/pull/1605 to calculate
both start and end bytes in a single pass.
2026-02-20 10:14:47 +08:00
Karl Seguin
7c4c2f7860 Merge pull request #1605 from egrs/wpt-chardata-utf16
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
fix CharacterData methods to use UTF-16 code unit offsets
2026-02-20 09:35:26 +08:00
Karl Seguin
90b7f2ff3b Improve and fix sanitized value ownership.
1 - Fix an issue where build would persist a value in the call_arena
2 - Remove double allocation (call_arena -> page_arena)
3 - Improve ergonomics of sanitizeValue with a comptime value indicating whether
    or not to always dupe the value.
2026-02-20 09:30:44 +08:00
Karl Seguin
d3f0041e93 Merge pull request #1607 from arrufat/markdown-anchors
markdown: handle block-level and standalone anchors
2026-02-20 08:59:41 +08:00
Karl Seguin
9d60142828 Add js.NullableString
When a WebAPI takes `[]const u8`, we coerce values to strings. But when it
takes a `?[]const u8` how should we handle `null`?  Some APIs might want to know
that it was null, others might just want `"null``.

Currently when `null` is passed to `?[]const u8`, we'll get null.

This adds a discriminator type, js.NullableString. When `null` is passed to it
it'll be converted to `"null"`.
2026-02-20 07:24:43 +08:00
Adrià Arrufat
68d5edca60 markdown: use node.is() for type checking and casting 2026-02-20 08:14:15 +09:00
Karl Seguin
1b369489df Merge pull request #1602 from lightpanda-io/css-delcaration
parse style attribute on CSSStyleDeclaration init
2026-02-20 06:57:58 +08:00
Karl Seguin
600ddfbf2d Merge pull request #1587 from lightpanda-io/label_control
Add HTMLLabelElement.control getter
2026-02-20 06:56:37 +08:00
Karl Seguin
415d4dde2a Merge pull request #1606 from lightpanda-io/form_selectors
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (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
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
More pseudo-seletors
2026-02-19 23:49:35 +08:00
Pierre Tachoire
1867245ed3 Merge pull request #1598 from egrs/input-value-sanitization
input value sanitization per WHATWG spec
2026-02-19 16:48:56 +01:00
Karl Seguin
71d34592d9 add frame created cdp messages 2026-02-19 23:47:33 +08:00
Karl Seguin
db2927eea7 cleanup a not-so-great rebase 2026-02-19 23:47:33 +08:00
Karl Seguin
bb01a5cb31 Make CDP frame-aware 2026-02-19 23:47:33 +08:00
Karl Seguin
815319140f cleanupany incomplete scheduled_navigation on renavigate or page.deinit 2026-02-19 23:47:33 +08:00
Karl Seguin
6e6082119f Remove session.transfer_arena
This no longer works with frames. Multiple frames could have a scheduled
navigation, so a single arena no longer has a clear lifecycle. Instead an arena
from the pool is used per navigation event, thus the queued_navigation is self-
contained.

This required having libcurl copy the body. Unfortunate. Currently we free the
arena as soon as the navigation begins. This is clean. But it means the body is
immediately freed (thus we need libcurl to copy it). As an alternative, each
page could maintain an optional transfer_arena, which it could free on
httpDone/Error.
2026-02-19 23:47:33 +08:00
Karl Seguin
da48ffe05c Move page.wait to session.wait
page.wait is the only significant difference between the "root" page and a page
for an iframe. I think it's more explicit to move this out of the page and
into the session, which was already the sole entry-point for page.wait.
2026-02-19 23:47:33 +08:00
Karl Seguin
081979be3b Initial support for frames
Missing:

- [ ] Navigation support within frames (in fact, as-is, any navigation done
      inside a frame, will almost certainly break things
- [ ] Correct CDP support. I don't know how frames are supposed to be exposed
      to CDP. Normal navigate events? Distinct CDP frame_ids?
- [ ] Cross-origin restrictions. The interaction between frames is supposed to
      change depending on whether or not they're on the same origin
- [ ] Potentially handling src-less frames incorrectly. Might not really matter

Adds basic frame support. Initially explored adding a BrowsingContext and
embedding it in Page, with the goal of also having it embedded in a to-be
created Frame. But it turns out that 98% of Page _was_ BrowsingContext and
introducing a BrowsingContext as the primary interaction unit broke pretty much
_every_ single WebAPI. So Page was expanded:

- Added `_parent: ?*Page`, which is `null` for "root" page.
- Added `frame: ?*IFrame`, which is `null` for the "root" page. This is the
  HTMLIFrameElement for frame-pages.
- Added a _type: enum{root, frame}, which is currently only used to improve
  the logs
- Added a frames: std.ArrayList(*Page). This is a list of frames for the page.
  Note that a "frame-page" can itself haven nested frames.

Besides the above, there were 3 "big" changes.

1 - Adding frames (dynamically, parsed) has to create a new page, start
    navigation, track it (in the frames list). Part of this was just
    piggybacking off of code that handles <script>

2 - The page "load" event blocks on the frame "load" event. This cascades.
    when a page triggers it's load, it can do:
```zig
      if (self._parent) |p| {
        p.iframeLoaded(self);
      }
```
   Pages need to keep track of how many iframes they're waiting to load. When
   all iframes (and all scripts) are loaded, it can then triggers its own load
   event.

3 - Our JS execution expects 1 primary entered context (the pages). But we now
    have multiple page contexts, and we need to be in the correct one based
    on where javascript is being executed. There is no more an default entered
    context. Creating a Local.Scope enters the context, and ls.deinit() exits
    the context.
2026-02-19 23:47:33 +08:00
egrs
3673956c1c add pure zig tests for utf16Len and utf16OffsetToUtf8 2026-02-19 16:29:49 +01:00
egrs
bdd3c274ed address review: arena param + pure zig tests
- sanitizeDatetimeLocal takes arena: Allocator instead of *Page
- add unit tests for isValidFloatingPoint, isValidDate, isValidMonth,
  isValidWeek, isValidTime, sanitizeDatetimeLocal, parseAllDigits,
  daysInMonth, maxWeeksInYear
2026-02-19 16:22:13 +01:00
Adrià Arrufat
423034d5c4 markdown: handle block-level and standalone anchors in
Adds logic to detect if an anchor contains block descendants or is a
standalone element within a layout block. These are now rendered with
appropriate spacing and link formatting. Also adds `.main` to the list
of block elements.
2026-02-20 00:11:38 +09:00
Pierre Tachoire
19fd2b12c0 Update src/browser/webapi/css/CSSStyleDeclaration.zig
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-02-19 15:29:36 +01:00
Karl Seguin
21cd17873f More pseudo-seletors
:invalid, :valid and :indeterminate implementation

Fix Element.closest with :scope pseudo-selector.
2026-02-19 22:28:14 +08:00
egrs
9870fa9e34 fix CharacterData methods to use UTF-16 code unit offsets
The DOM spec requires CharacterData offset/length to count UTF-16 code
units, not UTF-8 bytes or Unicode codepoints. Multi-byte characters
(CJK = 3 bytes UTF-8 / 1 code unit, emoji = 4 bytes / 2 code units)
were getting mangled.

- Add utf16Len/utf16OffsetToUtf8 helpers for UTF-8 ↔ UTF-16 conversion
- Fix .length to count UTF-16 code units instead of codepoints
- Fix substringData, deleteData, insertData, replaceData, splitText
- Fix data setter: null → "" (LegacyNullToEmptyString), undefined → "undefined"

Flips 6 WPT files (+134 subtests), 0 regressions.
2026-02-19 15:18:28 +01:00
Karl Seguin
938cd5e136 Merge pull request #1582 from lightpanda-io/cdp_per_page_frame_id
Rework CDP frameIds (and loaderIds and requestIds and interceptorIds)
2026-02-19 22:16:52 +08:00
Karl Seguin
e8025ad4b3 Merge pull request #1592 from lightpanda-io/element_render_property_optimization
Reduce cost of various Element render-related properties.
2026-02-19 22:16:17 +08:00
Karl Seguin
07fa141aaa Merge pull request #1593 from lightpanda-io/focus_noop_disconnected
make element.focus()  noop when element is disconnected
2026-02-19 22:16:04 +08:00
Pierre Tachoire
18bdf1e8b3 Merge pull request #1594 from lightpanda-io/fix_flaky_scroll_test
Fix flaky window.scrollTo test
2026-02-19 14:58:28 +01:00
Pierre Tachoire
5be977005e avoid useless priority parsing in CSSStyleDeclaration 2026-02-19 14:49:49 +01:00
Pierre Tachoire
7263d484de Update src/browser/webapi/css/CSSStyleDeclaration.zig
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-02-19 14:36:02 +01:00