When you clone a processing_node via the node_clone_node, or directly via the
processing_node copy, you end up in _dom_pi_copy:
da8b967905/src/core/pi.c (L104)
For whatever, reason, the node created here gets a vtable that doesn't seem
compatible with how we cast vtables in netsurf.zig. For now, a simple fix is
to create a new new and copy the attributes over.
Fixes https://github.com/lightpanda-io/browser/issues/123 and a WPT crash.
Netsurf's dom_node_is_equal appears to be both unsafe and incorrect. It's unsafe
because various node types don't have the dom_node_get_attributes implementation
so they default to setting the node attributes to null:
https://github.com/lightpanda-io/libdom/blob/master/src/core/node.c#L658
However, it doesn't do a NULL check when comparing them, so it crashes:
da8b967905/src/core/namednodemap.c (L312)
Furthermore, specific nodes need to be compared using specific attributes/values.
This PR fixes a WPT crash.
Currently, we treat every .html file in tests/wpt as-if it's a test. That
isn't always the case. wpt has a manifest tool to generate a manifest (in
JSON) of the tests, we should probably use that (but it's quite large).
This PR filters out two groups. First, everything in resources/ appears to
be things to _run_ the tests, not actual tests.
Second, any file without a "testharness.js" doesn't appear to be a test
either. Note that WPT's own manifest generator looks at this:
43a0615361/tools/manifest/sourcefile.py (L676)
(which is used later in the file to determine the type of file).
The call_arena is still re-added, and the call_depth is still used, but
the call_arena and scope_arenas are no longer part of the Env - they remain on
the Executor.
This is to accommodate upcoming changes where multiple executors will exist at
once. While the shared allocators _might_ have been safe in some cases, the
performance gains don't justify the risk of having 2 executors interacting in a
way where sharing the allocators would cause issues.
Because of callbacks, calls into Zig can be nested. Previously, the call_arena
was reset after _every_ call. When calls are nested, this doesn't work - the
nested call resets the arena, which the caller might still need. A `call_depth`
integer was added to the Executor. Each call starts by incrementing the
call_depth and, on deinit, decrements the call_depth. The call_arena is only
reset when the call_depth == 0. This could result in lower memory use.
Also promoted the call_arena and scope_arena to the Env. Practically speaking,
nothing has changed, since they're still reset under the exact same conditions.
However, when an executor ends and a new one is started, it can now reuse the
retained_capacity of the previous arenas. This should result in fewer
allocations.
Synchronous body reader now exposes a peek() function to get the first few bytes
from the response body. This will be no less than 100 bytes (assuming the body
is that big), but could be more. Streaming API, via res.next() continues to work
as-is even if peek() is called.
Introduce Mime.sniff() that detects a few common types - the ones that we care
about right now - from the body content.