Commit Graph
25 Commits
Author SHA1 Message Date
Karl Seguin fda59823ad webapi: cross validate more tests with chrome
cookie_store.html
1 - error message difference
2 - cookie change events can happen later than setTimeout(x, 0) later in chrome

crypto.html
1 - different error messages
2 - limits we impose that chrome doesn't
3 - algos chrome doesn't support (Ed448 and X448)

data_transfer.html
1 - effectAllowed should start off at "none"
2 - getAsString should be asynchronous

domparser.html
1 - Reject unknown entities when using DOMParser and responseXML.
2026-10-26 13:40:13 +08:00
Karl Seguin 7dcf8ef38e dev: groundwork for cross validating our unit tests in chrome
Will rely on an external driver (in demo) to run our page tests in Chrome and
catch unintentional divergence.

Initially this involves:

1 - Flagging every test with a marker (`<meta name=lp-mode content=test>`) so
    that the external runner knows this is a test file to be run, and not
    some support file.

2 - Extracting the TestHTTPServer and TestWSServer so that they can be run from
    a new (very simple) build step (`zig build test-server`) so that the
    test files and test endpoints (e.g. `/redirect_cross_echo_headers`) are
    accessible

3 - Starting to tweak testing.js so that it runs better in Chrome. Namely
    removing some of the attribution (for module scripts) which depend on our
    non-compliant document.currentScript behavior.

4 - Flagging a few tests and fixing them, as proof of concept.
2026-10-23 07:07:02 +08:00
Jay Hemnani 68dbf42ef3 markdown: write a text/markdown document as-is
A text/markdown response is loaded as a text document, with the body in
a <pre>, so `fetch --dump markdown` and the markdown tool wrapped the
whole file in a code fence, and a fence inside the file closed it early.
Write the document's text instead: it is already the markdown the
server sent. --dump-max-bytes / maxBytes still apply.
2026-10-20 14:55:21 +05:30
Karl Seguin bcdd5cc283 feature: Parse xml documents
Adds support for parsing XML documents, of note, application/html+xml. Fallsback
to trying to HTML parse on an invalid XML document.
2026-10-19 07:37:26 +08:00
Adrià Arrufat 7cd4863c48 test: simplify the parallel runner and port routing
Share the bound-address lookup as sys_net.boundAddress, set the test
connect-to routes once per handle in Connection.reset, add a
testing.tmpPath helper, and print the runner Report directly instead of
round-tripping it through SlowTracker. Replace deprecated
std.fmt.allocPrint and std.fs.path uses.
2026-10-08 17:18:03 +02:00
Adrià Arrufat d6dfd23217 test: let several test processes run at once
The test servers bind ephemeral ports instead of 9582-9584. Fixtures and
tests keep addressing the fixed ports: in test builds, libcurl's
CONNECT_TO routes them to the real ones, so URLs and origins are
unchanged. Only the few CDP server tests that dial it, or assert a URL
it advertises, use the real port.

Tests that wrote to fixed paths (/tmp/lightpanda_test.sqlite, /tmp/iid,
.zig-cache/tmp/upload.txt, files in the repo root) now use tmpDir.
2026-10-08 17:08:39 +02:00
Scott Taylor 012d9ba487 runner: run timers in text and image documents
hasRunnablePage only counted frames in the html or complete parse state. A text document (text/plain, text/markdown, application/json, text/css, text/javascript) stays in .text after parsing and an image document ends in .raw_done, so a session showing one never ran macrotasks: setTimeout and requestAnimationFrame callbacks queued there, including by CDP evaluate and init scripts, never fired. Count both states as runnable.
2026-10-06 10:28:06 +08:00
Adrià Arrufat c3083725c5 Replace deprecated std.mem.indexOf* with find* 2026-10-03 16:09:42 +02:00
Adrià Arrufat ab8e9622e2 Implement WebAssembly.compileStreaming and instantiateStreaming
V8 installs the two functions only when the isolate has a
WasmStreamingCallback, and installs them at context genesis, so the
callback is registered on the snapshot isolate as well as the runtime
one. Pages loading wasm through fetch() previously failed on a missing
function (https://www.nicbarker.com/clay, https://arrufat.github.io/zignal/).

WasmStreaming.zig is the embedder half: it resolves the
Response | Promise<Response> argument, checks the application/wasm
MIME essence, the status and the body usability, sets the source URL,
drains the body through Response.bytes and feeds V8. Failures abort the
stream with a TypeError, or with the source promise's own rejection.
In-flight streams are tracked on the Context and cancelled on teardown.

Depends on lightpanda-io/zig-v8-fork#208 for the v8__WasmStreaming__*
bindings.
2026-09-15 23:38:00 +02:00
Karl Seguin 4b3c5ed947 chore: Silence the sporadic WriteFailed HTTP Error from the test server
No clue why this happens, but if the error mattered, a test would fail. A lot
of tests can be "harsh" on the server (e.g. a frame that navigates its parent
away while some resource load), so a WriteFailed error isn't exactly surprising
2026-08-23 13:37:08 +08:00
Karl Seguin 73de272755 chore: speed up unit tests on linux 2026-08-10 15:51:58 +08:00
Karl Seguin 8e42d63c1c zig: Zig 0.16
Built against https://github.com/lightpanda-io/zig-v8-fork/tree/zig-0.16 but
it doesn't require a new v8 build.

Built against https://github.com/lightpanda-io/boringssl-zig/tree/zig-0.16
since the current fork we point to isn't updated.

A global std.Io instance, lp.io. Way easier this way and requires 0 changes to
our libcurl integration / event loop.

Network code uses a new layer that does what Zig 0.15's posix package used to
do. Again, quicker migration that way. But, as long as we have the global IO,
and given the half-baked nature of networking in std.Io 0.16, this just makes
sense. Things can be migrated as needed.

The std.time.* -> std.Io.Timestamp/Clock/Duration resulted in _a lot_ of
changes. ArrayList = .{} -> ArrayList -> .empty also resulted in a lot of
changes, but that's obviously superficial. As is the trimLeft/trimRight ->
trimStart/trimEnd rename.

Locking adopt the `Uncancelable` variants, e.g. mutex.lockUncancelable() to
preserve the error-free signature (and, because cancellation would be something
we'd have to put more thought into).

std.json.ObjectMap is now unmanaged, so the allocator had to be passed along.
However, there's still a deprecated managed variant of MemoryPool, so I switched
to it (we can do a small follow up PR to move to the unmanaged after).

I tried use_llvm = false, but it locks my computer, consuming RAM until MacOS
gives me a popup I've never seen before, begging me to start killing processes.

Agent and the networking stuff saw the most significant changes.
2026-07-22 13:26:03 +08:00
Karl Seguin 87b93faf91 minor: ignore test server error when writing internal server error 2026-06-30 20:40:36 +08:00
Karl Seguin db260fe029 test,perf: Fix leaky thread in test runner
The TestHTTPServer leaks a thread for every connection that shuts down. This
commit correctly releases it. It also closes a leaking CDP socket.

Full test went from 20s -> 10s for me
2026-06-09 11:42:31 +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 bdc9013241 silence an unecessary test log 2026-05-05 07:52:37 +08:00
Karl Seguin 763927c352 Use encoding_rs on non-UTF-8 html to convert to utf-8
Using our existing MIME type detection, this uses encoding_rs to convert non-
UTF-8 content to UTF-8, which can then be passed to html5ever.

Issue: https://github.com/lightpanda-io/browser/issues/2089
2026-04-08 18:32:08 +08:00
Karl Seguin 4f4dbc0c22 Allow iframe.src to renavigate the page
Unlike a script, an iframe can be re-navigated simply by setting the src.
2026-03-02 18:14:34 +08:00
Karl Seguin da49d918d6 use close, not shutdown on BSD/Mac 2026-02-05 10:58:10 +08:00
Nikolay Govorov 6ccd3f277b Fix race condition 2026-02-04 13:48:07 +00:00
Karl Seguin c3f8f9de54 merge https://github.com/lightpanda-io/browser/pull/1275 2025-12-18 21:17:13 +08:00
Karl Seguin 1164da5e7a copyright notices 2025-11-14 10:52:43 +08:00
Karl Seguin b047cb6dc1 remove libdom 2025-10-27 22:14:59 +08:00
Karl Seguin 67935b11c9 Try to address WPT running OOM
- Continue to reuse the Browser/Env/Isolate, but no start a new session per test.
- Test http server now properly closes the sendFile fd
- Run WPT in ReleaseMode
- Add --quiet option to WPT and some commented out debug code for dumping v8
  memory stats
2025-09-09 19:15:35 +08:00
Karl Seguin 7d46e8fe80 Start unifying test and code
Depends on https://github.com/lightpanda-io/browser/pull/993

There's currently 3 ways to execute a page:
1 - page.navigate (as used in both the 'fetch' and 'serve' commands)
2 - jsRunner as used in unit tests
3 - main_wpt as used in the WPT runner

Both jsRunner and main_wpt replicate the page.navigate code, but in their own
hack-ish way. main_wpt re-implements the DOM walking in order to extract and
execute <script> tags, as well as the needed page lifecycle events.

This PR replaces the existing main_wpt loader with a call to page.navigate. To
support this, a test HTTP server was added. (The test HTTP server is extracted
from the existing unit test test server, and re-used between the two).

There are benefits to this approach:
1 - The code is simpler
2 - More of the actual code and flow is tested
3 - There's 1 way to do things (page.navigate)
4 - Having an HTTP server might unlock some WPT tests

Technically, we're replacing file IO with network IO i.e. http requests). This
has potential downsides:
1 - The tests might be more brittle
2 - The tests might be slower

I think we need to run it for a while to see if we get flaky behavior.

The goal for following PRs is to bring this unification to the jsRunner.
2025-09-01 13:01:08 +08:00