We currently log any unknown property access on the global (window). This has
proven pretty useful when debugging, often letting us know a type we're
completely missing.
However, it isn't just about what types we have, it's also about the properties
those types expose. Inspired by the wasted time spent on
https://github.com/lightpanda-io/browser/pull/1473, this commit adds the same
type of logging for unknown properties on objects. In debug mode only. This is
only done for objects which don't have their own NamedIndexer.
Right now, to do anything with listeners, we need to (a) lookup the listeners
registered with the element and (b) walk the linked list to find listeners of
the correct type.
There's no operations that behave on all of an element's listeners, e.g. there's
no element.removeAllListeners(). So, we can optimize the code, and generally
make it simpler to read, by changing our key to include the type (along with
the element).
This is an optimization on its own (and makes the code simpler), but it also
makes it more palatable to do a pre-listener check to avoid creating events when
no listener even exists; if we decide to implement that.
Both of these become self-contained with their own arena, which can be cleaned
up when (a) we don't need it anymore and (b) v8 doens't need it. The "we don't
need it anymore" is true when there's nothing being observed.
The underlying records also get their own arena and are handed off to v8 to
finalize whenever they fall out of scope.
Not sure if this should be in `EventTarget` or `EventManager`, here goes nothing.
`Image`: dispatch `load` event when `src` set
add load event test
remove `hasListener`
let `Scheduler` dispatch `load` event
Simulates async nature.
update test
free `args` when done
implement `load` event dispatch for `<img>` tags
This dispatches `load` events tied to `EventManager` but not the `onload` for some reason...
`"load"` event must be dispatched even if `onload` not set
Resolves the bug that cause event listeners added through `EventTarget` not executing if `onload` not set.
add `onload` getter/setter for `Image`
prefer `attributeChange` to run side-effects
This should give more consistent results than using `setSrc`.
add inline `<img src="..." />` test
`Image`: prefer `inline_lookup` for `onload`
remove incorrect URL check + prefer 0ms in `Scheduler`
change after rebase
On a blocking request that requires authentication, we now handle the two cases
correctly:
1 - if the request is aborted, we don't continue processing (if we did, that
would result in (a) transfer.deinit being called twice and (b) the callbacks
being called twice
2 - if the request is "continue", we queue the transfer to be re-issued, as
opposed to just processing it as-is. We have to queue it because we're
currently inside a process loop and it [probaby] isn't safe to re-enter it.
By using the queue, we wait until the next call to `tick` to re-issue the
request.
First, for macrotasks, it ensures that the correct context is entered.
More important, for microtasks, it protects against use-after-free. This is
something we already did, to some degree, in page.deinit: we would run
microtasks before erasing the page, in case any microtasks referenced the page.
The new approach moves the guard to the context (since we have multiple
contexts) and protects against a microtasks enqueue a new task during shutdown
(something the original never did).