11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<title>Synthetic events are always cancelable by default</title>
31cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#dictdef-eventinit">
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci<script>
71cb0ef41Sopenharmony_ciconst eventsMap = {
81cb0ef41Sopenharmony_ci  wheel: 'WheelEvent',
91cb0ef41Sopenharmony_ci  mousewheel: 'WheelEvent',
101cb0ef41Sopenharmony_ci  touchstart: 'TouchEvent',
111cb0ef41Sopenharmony_ci  touchmove: 'TouchEvent',
121cb0ef41Sopenharmony_ci  touchend: 'TouchEvent',
131cb0ef41Sopenharmony_ci  touchcancel: 'TouchEvent',
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_cifunction isCancelable(eventName, interfaceName) {
161cb0ef41Sopenharmony_ci  test(() => {
171cb0ef41Sopenharmony_ci    assert_implements(interfaceName in self, `${interfaceName} should be supported`);
181cb0ef41Sopenharmony_ci    let defaultPrevented = null;
191cb0ef41Sopenharmony_ci    addEventListener(eventName, event => {
201cb0ef41Sopenharmony_ci      event.preventDefault();
211cb0ef41Sopenharmony_ci      defaultPrevented = event.defaultPrevented;
221cb0ef41Sopenharmony_ci    });
231cb0ef41Sopenharmony_ci    const event = new self[interfaceName](eventName);
241cb0ef41Sopenharmony_ci    assert_false(event.cancelable, 'cancelable');
251cb0ef41Sopenharmony_ci    const dispatchEventReturnValue = dispatchEvent(event);
261cb0ef41Sopenharmony_ci    assert_false(defaultPrevented, 'defaultPrevented');
271cb0ef41Sopenharmony_ci    assert_true(dispatchEventReturnValue, 'dispatchEvent() return value');
281cb0ef41Sopenharmony_ci  }, `Synthetic ${eventName} event with interface ${interfaceName} is not cancelable`);
291cb0ef41Sopenharmony_ci}
301cb0ef41Sopenharmony_cifor (const eventName in eventsMap) {
311cb0ef41Sopenharmony_ci  isCancelable(eventName, eventsMap[eventName]);
321cb0ef41Sopenharmony_ci  isCancelable(eventName, 'Event');
331cb0ef41Sopenharmony_ci}
341cb0ef41Sopenharmony_ci</script>
35