Closes the test gap on the FrameSet stub. Asserts that
HTMLFrameSetElement exists as a global function, that <frameset> in
markup yields an HTMLFrameSetElement instance with the standard
tagName/toString/prototype-chain shape, and that document.createElement
('frameset') round-trips the same.
Refs #2249
Angular 9's zone.js polyfill calls HTMLFrameSetElement during
__load_patch, but the constructor was undefined in Lightpanda. The
fetch in #2249 dies on the very first patched API.
Add a minimal stub mirroring the existing HTMLDirectoryElement /
HTMLBodyElement pattern: a Zig struct with `_proto: *HtmlElement`,
asElement / asNode helpers, and a JsApi block exposing the bridge as
HTMLFrameSetElement. Registration goes in the same five files every
HTML element touches: the new file under
webapi/element/html/, an import + union field in Html.zig, the bridge
list in js/bridge.zig, the Tag enum + tag-name mappings in
webapi/Element.zig, and the default-display block list in
CSSStyleDeclaration.zig.
No tests; the build itself validates the registration paths.
Closes#2249
- Update `ToolExecutor.callEval` to return `EvalResult` for better error handling.
- Swap `ScriptIterator.init` arguments to follow the allocator-first convention.
- Use explicit type syntax for `.init` calls across the agent package.
- Remove redundant `isKnownTool` helper in favor of direct enum conversion.
Runner._wait can iterate for the full opts.ms budget (up to 30s in
fetch, longer in agent tool-use loops). V8 was only nudged to GC on
session/page teardown (Browser.deinit, Page.deinit), so a page that
stays alive while running heavy JS accumulates wrappers and
external-ref'd Zig allocations V8 has no reason to drop. Fire
memoryPressureNotification(.moderate) once per second from the wait
loop.
The main.zig path for `fetch` now captures the *Browser so that
browser.env.terminate() can be called. This is a bit more complex than the serve
path because the Browser owns the Isolate and can't be moved from one thread to
another.
With main having access to the browser, two things are now possible:
1 - We can support a --terminate-ms flag (https://github.com/lightpanda-io/browser/issues/2206)
2 - ctrl-c can correctly stop blocked JavaScript processes
1 is implemented via setitimer to set a timer for SIGALRM, avoiding the need to
add another "watcher" thread, or putting a timer in Network.run.
Was previously using page.arena, but there's no reason to hold this beyond the
point where the page is parsed, and the page can live for quite some time after
the initial load.
Frame.getElementByIdFromNode is the selector engine's fast path for
`#id` queries. It only consulted `_elements_by_id`, while
Document.getElementById and ShadowRoot.getElementById both fall back
to `_removed_ids` + TreeWalker to recover a surviving duplicate after
the first has been removed.
The two APIs could disagree after DOM manipulation that removes a
duplicate-ID element (e.g. Turbo Drive's PageRenderer.replaceBody
doing innerHTML + replaceWith):
document.querySelector('#page-title') => null
document.getElementById('page-title') => <h1>
Dispatch to the existing canonical getElementById on the scope
(ShadowRoot or Document) instead of keeping a third, map-only copy
of the lookup. The two APIs now agree by construction.
Adds limited support for window.open. This leverages the new page container and
behaves similarly to an iframe. There are many things not implemented, but the
most significant are:
1- target=window_name or target=_blank don't work (but this could be added
pretty easily I think)
2- Windows (which are is just a Frame) are shutdown when the Page is shutdown.
They would need to be owned by the Session (rather than the Page), but I'm
not really confident in that right now.
3- No CDP testing. There are maybe CDP-specific messages we need to emit (or
maybe messages that we shouldn't emit).
As-is, this should help with common cases where:
1. window.open is called but doesn't matter (won't give a JS error)
2. window.open is short-lived, or, more specifically, lives only for the
duration of the page that opened it (e.g. a login popup).
3. WPT tests! (because most of these fit in #2).
Don't use pre-built snapshot for wpt action (the snapshot needs the WebDriver
added, which is not normally added). Instead, rely on runtime snapshot creation
(this just adds a bit of startup time and peak memory, neither or which should
be an issue for WPT runs).
Fired when elements are moved from one document to another. I don't think this
is really used much, but it helps pass a number of WPT cases.
This required tweaking insertAdjacentHTML as it was creating a full document
and trigger spurious callbacks in the new code. A DocumentFragment is now used
instead.
Support `new MyElement()` syntax to create custom element. The implementation
for this is pretty straightforward, but it depends on:
https://github.com/lightpanda-io/zig-v8-fork/pull/173.
Also modify the `attributeChangedCallback` and pass a missing parameter: the
namespace. Currently, we pass `null`, but this is less likely to cause issues
than not passing anything.