Commit Graph

3597 Commits

Author SHA1 Message Date
Karl Seguin
fc745b9614 Merge pull request #1627 from lightpanda-io/dom_load_no_window
Don't bubble "load" event to Window
2026-02-24 07:24:58 +08:00
Karl Seguin
95b1baebd2 Merge pull request #1626 from lightpanda-io/optimize_property_and_noop_functions
Optimizes properties and noop functions
2026-02-24 07:24:45 +08:00
Karl Seguin
56fe1ceb97 Merge pull request #1623 from lightpanda-io/finalizer_tweaks
Tweak Finalizer callbacks
2026-02-24 07:24:29 +08:00
Karl Seguin
863a51e556 Merge pull request #1614 from lightpanda-io/fix_v8_context_queue_lifetime
Improve Context shutdown
2026-02-24 07:24:18 +08:00
Karl Seguin
69b3064b45 Add Response.arrayBuffer() 2026-02-23 19:53:57 +08:00
Karl Seguin
fb3eab1aa8 Improve tests when running outside of our test runner
We often verify the correctness of tests by loading them in an external browser,
but some tests just don't run the same/correctly. For example, we used to hard-
code the http://127.0.0.1:9582/ origin, but that would cause tests to fail if
running from a different origin.

This commit _begins_ the work of improving this. It introduces a
testing.ORIGIN, testing.BASE_URL and testing.HOST which will work correctly in
both our runner and an external browser.

It also introduces `testing.IS_TEST_RUNNER` boolean flag so that tests which
have no chance of working in an external browser (e.g. screen.width) can be
skipped.

The goal is to reduce/remove tests which fail in external browsers so that such
failures aren't quickly written off as "just how it is".
2026-02-23 18:20:15 +08:00
Karl Seguin
32c7399f26 Log actual client address
We're currently logging the server address. It should clearly be the client
address.
2026-02-23 17:42:25 +08:00
Karl Seguin
955351b5bd Don't bubble "load" event to Window
As per spec:

For legacy reasons, load events for resources inside the document (e.g., images)
do not include the Window in the propagation path in HTML implementations.
2026-02-23 14:04:26 +08:00
Karl Seguin
75f6c67b6e Optimizes properties and noop functions
Define properties directly on the PrototypeTemplate, removing the need for 1
FunctionTemplate per instance-property. Also, properties were previously all
readonly. There is now a readonly flag...thus, properties which we don't care
about, but have a default value, can be defined this way.

Added a 'noop' flag to functions which skips the zig callback and does nothing.

I was initially hoping these would noticeably reduce the size of our snapshot
due to requiring fewer FunctionTemplates. While it shaves a few ~3KB, it's far
less than I was hoping. The issue is that noop function templates still need
to be unique so that `type_a.noopFunc !== type_b.noopFunc` remains true.

Still, as we add more dummy implementation, these little tweaks might add up.
2026-02-23 12:41:02 +08:00
Karl Seguin
00702448c7 Merge branch 'main' into wpt-fixes-batch-3 2026-02-23 07:01:35 +08:00
Karl Seguin
5074827d51 Merge pull request #1625 from lightpanda-io/option-set-text
add Option.text setter
2026-02-23 06:56:34 +08:00
Karl Seguin
ceb0711e42 Merge pull request #1620 from lightpanda-io/offscreen_canvas
Add dummy implementation of OffscreenCanvas
2026-02-23 06:55:18 +08:00
Karl Seguin
ddb5824b58 Merge pull request #1624 from lightpanda-io/fontface
add dummy implementation of FontFaceSet
2026-02-23 06:55:03 +08:00
egrs
39f9209374 fix file input value getter/setter per spec
- getValue() returns "" for file inputs regardless of value attribute
- setValue("") is a no-op for file inputs (was throwing)
- setValue(non-empty) still throws InvalidStateError
- add _setValue bridge wrapper for [LegacyNullToEmptyString]: null → ""

Flips html/semantics/forms/the-input-element/valueMode.html (38/40 → 40/40).
2026-02-22 19:13:57 +01:00
Adrià Arrufat
5fea4cf760 mcp: add protocol and router unit tests 2026-02-22 23:15:45 +09:00
Pierre Tachoire
0e5ec86ca9 add Option.text setter 2026-02-22 15:03:12 +01:00
Pierre Tachoire
8b95211055 add dummy implementation of font face set 2026-02-22 14:59:41 +01:00
Adrià Arrufat
a27339b954 mcp: add Model Context Protocol server support
Adds a new `mcp` run mode to start an MCP server over stdio.
Implements tools for navigation and JS evaluation, along with
resources for HTML and Markdown page content.
2026-02-22 22:32:14 +09:00
Karl Seguin
028b728760 Tweak Finalizer callbacks
1 - Finalizer callbacks are now give a *Page parameter. Various types no longer
    need to maintain a reference to *Page just to finalize

2 - EventManager now handles v8_handoff == false cleanup. This is largely
    because of the above change, which would require every:

```
defer if (!event._v8_handoff) event.deinit(false);
```

to be turned into:

```
defer if (!event._v8_handoff) event.deinit(false, page);
```

But the caller might not have a page. Besides this, it makes most uses of Event
simpler. But, in some cases, it could leave a window where the event doesn't
reach the EventManager to be properly managed (though, we have no such cases
as of now).
2026-02-22 20:51:21 +08:00
Karl Seguin
18e63df01e Merge pull request #1621 from egrs/wpt-fixes-batch-2
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 WPT failures: nodeName, PI validation, willValidate, maxLength
2026-02-22 07:45:17 +08:00
egrs
5f459c0901 cache document.implementation for object identity
getImplementation() now returns a cached *DOMImplementation pointer
per Document, matching the getStyleSheets() pattern. This ensures
document.implementation === document.implementation holds true.

Flips dom/nodes/Document-implementation.html (1/2 → 2/2).
2026-02-21 14:45:59 +01:00
egrs
a90bcde38c fix WPT failures: nodeName prefix case, PI validation, willValidate, maxLength
- uppercase entire qualified name in tagName (including prefix)
- validate PI data for "?>" and use proper XML Name production with Unicode
- implement willValidate on HTMLInputElement
- throw IndexSizeError DOMException for negative maxLength assignment

flips: Node-nodeName, Document-createProcessingInstruction, button,
maxlength, input-willvalidate (+6 subtests)
2026-02-21 13:11:06 +01:00
Karl Seguin
603e7d922e Improve Context shutdown
Under some conditions, a microtask would be executed for a context that was
already deinit'd, resulting in various use-after-free.

The culprit appears to be WASM compilation being placed in the microtask queue
(by a user-script) and then resolved at some point in the future. We guard the
microtask queue by a context.shutting_down boolean, but v8 doesn't know anything
about this flag. The fact is that, microtasks are tied to an isolate, not a
context.

This commit introduces a number of changes:

1 - It follows 309f254c2c and stores the zig Context inside of an embedder field. This
    ensures v8 doesn't consider this when GC'ing, which _could_ extend the
    lifetime of the v8::Context beyond what we expect

2 - Most significantly, it introduces per-context microtasks queues. Each
    context gets its own queue. This makes cleanup much simpler and reduces the
    chance of microtasks outliving the context

3 - pumpMessageLoop is called on context.deinit, this helps to ensure that any
    tasks v8 has for our context are processed (e.g. wasm compilation) before
    shtudown

4 - The order of context shutdown is important, we notify the isolate of the
    context destruction first, then pump the message loop and finally destroy
    the context's message loop.

Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/151
2026-02-21 13:02:43 +08:00
Karl Seguin
861126f810 Add dummy implementation of OffscreenCanvas 2026-02-21 12:58:35 +08:00
Karl Seguin
eb9b706ebc Merge branch 'select-event'
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
2026-02-21 07:21:37 +08:00
Karl Seguin
de9cbae0b2 Merge pull request #1565 from lightpanda-io/frames
Initial support for frames
2026-02-21 07:17:51 +08:00
Karl Seguin
25e890986f Merge pull request #1619 from egrs/wpt-small-fixes
fix DocumentType.remove, MutationRecord.attributeNamespace, createElementNS casing
2026-02-21 07:17:29 +08:00
Karl Seguin
f66627dd04 Merge pull request #1618 from arrufat/markdown-simplifications
markdown: simplify rendering logic and state management
2026-02-21 07:10:56 +08:00
Karl Seguin
924eb33b3f Update src/browser/js/Env.zig
Co-authored-by: Pierre Tachoire <pierre@lightpanda.io>
2026-02-21 07:02:21 +08:00
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