events: Start porting WPT tests
I tried porting the WPT tests through git node wpt
- it worked pretty well initially but there were several big issues:
- All the meaningful tests are HTML files.
- Even the JS files contained a lot of DOM logic.
- The WHATWG tests don't test
EventTarget
directly - rather they testdocument
andwindow
as event targets.
I started down the path of implementing a document
, window
, appendChild
and then decided it would probably be easier to just manually port these tests after changing them to terms Node understands.
Ideally, we could contribute these back to WPT as less-tried-to-document tests for EventTarget.
For example where the test does document.addEventListener
I do let document = new EventEmitter()
first.
When I tried porting https://github.com/web-platform-tests/wpt/blob/master/dom/events/AddEventListenerOptions-once.html#L36-L57 it threw ERR_EVENT_RECURSION
indicating that that behavior is probably not spec compliant. @jasnell any objections to changing it to align with the spec and allow dispatching an event while in an event handler for the same handler?
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines