Merge pull request #1033 from lightpanda-io/nikneym/custom-event

Support for CustomEvent in document.createEvent
This commit is contained in:
Karl Seguin
2025-09-10 15:23:34 +08:00
committed by GitHub
4 changed files with 59 additions and 7 deletions

View File

@@ -60,7 +60,7 @@
let byTagNameAll = document.getElementsByTagName('*');
// If you add a script block (or change the HTML in any other way on this
// page), this test will break. Adjust it accordingly.
testing.expectEqual(20, byTagNameAll.length);
testing.expectEqual(21, byTagNameAll.length);
testing.expectEqual('html', byTagNameAll.item(0).localName);
testing.expectEqual('SCRIPT', byTagNameAll.item(11).tagName);
@@ -167,3 +167,23 @@
acss.push(new CSSStyleSheet());
testing.expectEqual(1, acss.length);
</script>
<script id=createEvent>
const event = document.createEvent("Event");
testing.expectEqual(true, event instanceof Event);
testing.expectEqual("", event.type);
const customEvent = document.createEvent("CustomEvent");
customEvent.initCustomEvent("hey", false, false);
testing.expectEqual(true, customEvent instanceof CustomEvent);
testing.expectEqual(true, customEvent instanceof Event);
testing.withError(
(err) => {
// TODO: Check the error type.
},
() => document.createEvent("InvalidType"),
);
</script>