11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<meta charset=utf-8> 31cb0ef41Sopenharmony_ci<title>Event.defaultPrevented is not reset after dispatchEvent()</title> 41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 61cb0ef41Sopenharmony_ci</head> 71cb0ef41Sopenharmony_ci<body> 81cb0ef41Sopenharmony_ci<div id=log></div> 91cb0ef41Sopenharmony_ci<input id="target" type="hidden" value=""/> 101cb0ef41Sopenharmony_ci<script> 111cb0ef41Sopenharmony_citest(function() { 121cb0ef41Sopenharmony_ci var EVENT = "foo"; 131cb0ef41Sopenharmony_ci var TARGET = document.getElementById("target"); 141cb0ef41Sopenharmony_ci var evt = document.createEvent("Event"); 151cb0ef41Sopenharmony_ci evt.initEvent(EVENT, true, true); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci TARGET.addEventListener(EVENT, this.step_func(function(e) { 181cb0ef41Sopenharmony_ci e.preventDefault(); 191cb0ef41Sopenharmony_ci assert_true(e.defaultPrevented, "during dispatch"); 201cb0ef41Sopenharmony_ci }), true); 211cb0ef41Sopenharmony_ci TARGET.dispatchEvent(evt); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci assert_true(evt.defaultPrevented, "after dispatch"); 241cb0ef41Sopenharmony_ci assert_equals(evt.target, TARGET); 251cb0ef41Sopenharmony_ci assert_equals(evt.srcElement, TARGET); 261cb0ef41Sopenharmony_ci}, "Default prevention via preventDefault"); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_citest(function() { 291cb0ef41Sopenharmony_ci var EVENT = "foo"; 301cb0ef41Sopenharmony_ci var TARGET = document.getElementById("target"); 311cb0ef41Sopenharmony_ci var evt = document.createEvent("Event"); 321cb0ef41Sopenharmony_ci evt.initEvent(EVENT, true, true); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci TARGET.addEventListener(EVENT, this.step_func(function(e) { 351cb0ef41Sopenharmony_ci e.returnValue = false; 361cb0ef41Sopenharmony_ci assert_true(e.defaultPrevented, "during dispatch"); 371cb0ef41Sopenharmony_ci }), true); 381cb0ef41Sopenharmony_ci TARGET.dispatchEvent(evt); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci assert_true(evt.defaultPrevented, "after dispatch"); 411cb0ef41Sopenharmony_ci assert_equals(evt.target, TARGET); 421cb0ef41Sopenharmony_ci assert_equals(evt.srcElement, TARGET); 431cb0ef41Sopenharmony_ci}, "Default prevention via returnValue"); 441cb0ef41Sopenharmony_ci</script> 45