node/test/fixtures/wpt/dom/events/CustomEvent.html
Daiki Nishikawa 8dce6ad7a5
test: add WPT tests for dom/events
PR-URL: https://github.com/nodejs/node/pull/43151
Refs: https://github.com/nodejs/node/issues/40678
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-06-22 09:28:59 +01:00

35 lines
1.1 KiB
HTML

<!doctype html>
<title>CustomEvent</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var type = "foo";
var target = document.createElement("div");
target.addEventListener(type, this.step_func(function(evt) {
assert_equals(evt.type, type);
}), true);
var fooEvent = document.createEvent("CustomEvent");
fooEvent.initEvent(type, true, true);
target.dispatchEvent(fooEvent);
}, "CustomEvent dispatching.");
test(function() {
var e = document.createEvent("CustomEvent");
assert_throws_js(TypeError, function() {
e.initCustomEvent();
});
}, "First parameter to initCustomEvent should be mandatory.");
test(function() {
var e = document.createEvent("CustomEvent");
e.initCustomEvent("foo");
assert_equals(e.type, "foo", "type");
assert_false(e.bubbles, "bubbles");
assert_false(e.cancelable, "cancelable");
assert_equals(e.detail, null, "detail");
}, "initCustomEvent's default parameter values.");
</script>