• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5const { strictEqual, throws, equal } = require('assert');
6
7// Manually converted from https://github.com/web-platform-tests/wpt/blob/master/dom/events/CustomEvent.html
8// in order to define the `document` ourselves
9
10{
11  const type = 'foo';
12  const target = new EventTarget();
13
14  target.addEventListener(type, common.mustCall((evt) => {
15    strictEqual(evt.type, type);
16  }));
17
18  target.dispatchEvent(new Event(type));
19}
20
21{
22  throws(() => {
23    new Event();
24  }, TypeError);
25}
26
27{
28  const event = new Event('foo');
29  equal(event.type, 'foo');
30  equal(event.bubbles, false);
31  equal(event.cancelable, false);
32  equal(event.detail, null);
33}
34