emit contextCreated when it's needed, not when it actually happens.
I thought we could make this sync-up, but we'd need to create 3 contexts to
satisfy both puppeteer and chromedp. So rather than having it partially
driven by notifications from Browser, I rather just fake it all for now.
- Pages within the same session have proper isolation
- they have their own window
- they have their own SessionState
- they have their own v8.Context
- Move inspector to CDP browser context
- Browser now knows nothing about the inspector
- Use notification to emit a context-created message
- This is still a bit hacky, but again, it decouples browser from CDP
The approach borrows heavily from Zig's new LinkedList API.
The main benefit is that it unifies how event callbacks are done. When the
Page.windowClick event was added, the Event structure was changed to a union,
supporting a distinct Zig and JS event.
This new approach more or less treats everything like a Zig event. A JS event
is just a Zig struct that has a Env.Callback which it can invoke in its handle
method.
The intrusive nature of the EventNode means that what used to be 1 or 2
allocations is now 0 or 1.
It also has the benefit of making netsurf completely unaware of Env.Callbacks.
It's still generic over the client - we need to assert messages written to and
be able to send specific commands, but it's no longer generic over Browser/
Session/Page/etc..
- Fix get_removedNodes (it was returning addedNodes)
- get_removedNodes and get addedNodes now return references
- used enum for dispatching and clean up dispatching in general
- Remove MutationRecords and simply return an array
- this allows the returned records to be iterable (as they should be)
- jsruntime ZigToJs will now map a Zig array to a JS array
-Rely on default initialize of NodeList
-Batch observed records
- Callback only executed when call_depth == 0
- Fixes crashes when a MutationObserver callback mutated the nodes being
observes.
- Fixes some WPT issues, but Netsurf's mutationEventRelatedNode does not
appear to be to spec, so most tests fail.
- Allow zig methods to execute arbitrary code when call_depth == 0
- This is a preview of how I hope to make XHR not crash if the CDP session
ends while there's still network activity
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.