summaryrefslogtreecommitdiff
path: root/test/parallel/test-whatwg-events-event-constructors.js
blob: 7880b10043e462902aa61e3a539de43d16503d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';

require('../common');
const { test, assert_equals, assert_array_equals } =
  require('../common/wpt').harness;

// Source: https://github.com/web-platform-tests/wpt/blob/6cef1d2087d6a07d7cc6cee8cf207eec92e27c5f/dom/events/Event-constructors.any.js#L91-L112
test(function() {
  const called = [];
  const ev = new Event('Xx', {
    get cancelable() {
      called.push('cancelable');
      return false;
    },
    get bubbles() {
      called.push('bubbles');
      return true;
    },
    get sweet() {
      called.push('sweet');
      return 'x';
    },
  });
  assert_array_equals(called, ['bubbles', 'cancelable']);
  assert_equals(ev.type, 'Xx');
  assert_equals(ev.bubbles, true);
  assert_equals(ev.cancelable, false);
  assert_equals(ev.sweet, undefined);
});