11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<title>Event.defaultPrevented</title>
31cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
41cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
51cb0ef41Sopenharmony_ci<div id="log"></div>
61cb0ef41Sopenharmony_ci<script>
71cb0ef41Sopenharmony_civar ev;
81cb0ef41Sopenharmony_citest(function() {
91cb0ef41Sopenharmony_ci  ev = document.createEvent("Event");
101cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
111cb0ef41Sopenharmony_ci}, "When an event is created, defaultPrevented should be initialized to false.");
121cb0ef41Sopenharmony_citest(function() {
131cb0ef41Sopenharmony_ci  ev.initEvent("foo", true, false);
141cb0ef41Sopenharmony_ci  assert_equals(ev.bubbles, true, "bubbles");
151cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, false, "cancelable");
161cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
171cb0ef41Sopenharmony_ci}, "initEvent should work correctly (not cancelable).");
181cb0ef41Sopenharmony_citest(function() {
191cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, false, "cancelable (before)");
201cb0ef41Sopenharmony_ci  ev.preventDefault();
211cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, false, "cancelable (after)");
221cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
231cb0ef41Sopenharmony_ci}, "preventDefault() should not change defaultPrevented if cancelable is false.");
241cb0ef41Sopenharmony_citest(function() {
251cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, false, "cancelable (before)");
261cb0ef41Sopenharmony_ci  ev.returnValue = false;
271cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, false, "cancelable (after)");
281cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
291cb0ef41Sopenharmony_ci}, "returnValue should not change defaultPrevented if cancelable is false.");
301cb0ef41Sopenharmony_citest(function() {
311cb0ef41Sopenharmony_ci  ev.initEvent("foo", true, true);
321cb0ef41Sopenharmony_ci  assert_equals(ev.bubbles, true, "bubbles");
331cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable");
341cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
351cb0ef41Sopenharmony_ci}, "initEvent should work correctly (cancelable).");
361cb0ef41Sopenharmony_citest(function() {
371cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable (before)");
381cb0ef41Sopenharmony_ci  ev.preventDefault();
391cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable (after)");
401cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, true, "defaultPrevented");
411cb0ef41Sopenharmony_ci}, "preventDefault() should change defaultPrevented if cancelable is true.");
421cb0ef41Sopenharmony_citest(function() {
431cb0ef41Sopenharmony_ci  ev.initEvent("foo", true, true);
441cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable (before)");
451cb0ef41Sopenharmony_ci  ev.returnValue = false;
461cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable (after)");
471cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, true, "defaultPrevented");
481cb0ef41Sopenharmony_ci}, "returnValue should change defaultPrevented if cancelable is true.");
491cb0ef41Sopenharmony_citest(function() {
501cb0ef41Sopenharmony_ci  ev.initEvent("foo", true, true);
511cb0ef41Sopenharmony_ci  assert_equals(ev.bubbles, true, "bubbles");
521cb0ef41Sopenharmony_ci  assert_equals(ev.cancelable, true, "cancelable");
531cb0ef41Sopenharmony_ci  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
541cb0ef41Sopenharmony_ci}, "initEvent should unset defaultPrevented.");
551cb0ef41Sopenharmony_ci</script>
56