11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<title>Synthetic click event "magic"</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<div id=dump style=display:none></div> 71cb0ef41Sopenharmony_ci<script> 81cb0ef41Sopenharmony_civar dump = document.getElementById("dump") 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciasync_test(function(t) { 111cb0ef41Sopenharmony_ci var input = document.createElement("input") 121cb0ef41Sopenharmony_ci input.type = "checkbox" 131cb0ef41Sopenharmony_ci dump.appendChild(input) 141cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 151cb0ef41Sopenharmony_ci assert_true(input.checked) 161cb0ef41Sopenharmony_ci }) 171cb0ef41Sopenharmony_ci input.click() 181cb0ef41Sopenharmony_ci}, "basic with click()") 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciasync_test(function(t) { 211cb0ef41Sopenharmony_ci var input = document.createElement("input") 221cb0ef41Sopenharmony_ci input.type = "checkbox" 231cb0ef41Sopenharmony_ci dump.appendChild(input) 241cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 251cb0ef41Sopenharmony_ci assert_true(input.checked) 261cb0ef41Sopenharmony_ci }) 271cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click", {bubbles:true})) // equivalent to the above 281cb0ef41Sopenharmony_ci}, "basic with dispatchEvent()") 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciasync_test(function(t) { 311cb0ef41Sopenharmony_ci var input = document.createElement("input") 321cb0ef41Sopenharmony_ci input.type = "checkbox" 331cb0ef41Sopenharmony_ci dump.appendChild(input) 341cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 351cb0ef41Sopenharmony_ci assert_false(input.checked) 361cb0ef41Sopenharmony_ci }) 371cb0ef41Sopenharmony_ci input.dispatchEvent(new Event("click", {bubbles:true})) // no MouseEvent 381cb0ef41Sopenharmony_ci}, "basic with wrong event class") 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciasync_test(function(t) { 411cb0ef41Sopenharmony_ci var input = document.createElement("input") 421cb0ef41Sopenharmony_ci input.type = "checkbox" 431cb0ef41Sopenharmony_ci dump.appendChild(input) 441cb0ef41Sopenharmony_ci var child = input.appendChild(new Text("does not matter")) 451cb0ef41Sopenharmony_ci child.dispatchEvent(new MouseEvent("click")) // does not bubble 461cb0ef41Sopenharmony_ci assert_false(input.checked) 471cb0ef41Sopenharmony_ci t.done() 481cb0ef41Sopenharmony_ci}, "look at parents only when event bubbles") 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciasync_test(function(t) { 511cb0ef41Sopenharmony_ci var input = document.createElement("input") 521cb0ef41Sopenharmony_ci input.type = "checkbox" 531cb0ef41Sopenharmony_ci dump.appendChild(input) 541cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 551cb0ef41Sopenharmony_ci assert_true(input.checked) 561cb0ef41Sopenharmony_ci }) 571cb0ef41Sopenharmony_ci var child = input.appendChild(new Text("does not matter")) 581cb0ef41Sopenharmony_ci child.dispatchEvent(new MouseEvent("click", {bubbles:true})) 591cb0ef41Sopenharmony_ci}, "look at parents when event bubbles") 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ciasync_test(function(t) { 621cb0ef41Sopenharmony_ci var input = document.createElement("input") 631cb0ef41Sopenharmony_ci input.type = "checkbox" 641cb0ef41Sopenharmony_ci dump.appendChild(input) 651cb0ef41Sopenharmony_ci input.onclick = t.step_func(function() { 661cb0ef41Sopenharmony_ci assert_false(input.checked, "input pre-click must not be triggered") 671cb0ef41Sopenharmony_ci }) 681cb0ef41Sopenharmony_ci var child = input.appendChild(document.createElement("input")) 691cb0ef41Sopenharmony_ci child.type = "checkbox" 701cb0ef41Sopenharmony_ci child.onclick = t.step_func(function() { 711cb0ef41Sopenharmony_ci assert_true(child.checked, "child pre-click must be triggered") 721cb0ef41Sopenharmony_ci }) 731cb0ef41Sopenharmony_ci child.dispatchEvent(new MouseEvent("click", {bubbles:true})) 741cb0ef41Sopenharmony_ci t.done() 751cb0ef41Sopenharmony_ci}, "pick the first with activation behavior <input type=checkbox>") 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ciasync_test(function(t) { // as above with <a> 781cb0ef41Sopenharmony_ci window.hrefComplete = t.step_func(function(a) { 791cb0ef41Sopenharmony_ci assert_equals(a, 'child'); 801cb0ef41Sopenharmony_ci t.done(); 811cb0ef41Sopenharmony_ci }); 821cb0ef41Sopenharmony_ci var link = document.createElement("a") 831cb0ef41Sopenharmony_ci link.href = "javascript:hrefComplete('link')" // must not be triggered 841cb0ef41Sopenharmony_ci dump.appendChild(link) 851cb0ef41Sopenharmony_ci var child = link.appendChild(document.createElement("a")) 861cb0ef41Sopenharmony_ci child.href = "javascript:hrefComplete('child')" 871cb0ef41Sopenharmony_ci child.dispatchEvent(new MouseEvent("click", {bubbles:true})) 881cb0ef41Sopenharmony_ci}, "pick the first with activation behavior <a href>") 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ciasync_test(function(t) { 911cb0ef41Sopenharmony_ci var input = document.createElement("input") 921cb0ef41Sopenharmony_ci input.type = "checkbox" 931cb0ef41Sopenharmony_ci dump.appendChild(input) 941cb0ef41Sopenharmony_ci var clickEvent = new MouseEvent("click") 951cb0ef41Sopenharmony_ci input.onchange = t.step_func_done(function() { 961cb0ef41Sopenharmony_ci assert_false(clickEvent.defaultPrevented) 971cb0ef41Sopenharmony_ci assert_true(clickEvent.returnValue) 981cb0ef41Sopenharmony_ci assert_equals(clickEvent.eventPhase, 0) 991cb0ef41Sopenharmony_ci assert_equals(clickEvent.currentTarget, null) 1001cb0ef41Sopenharmony_ci assert_equals(clickEvent.target, input) 1011cb0ef41Sopenharmony_ci assert_equals(clickEvent.srcElement, input) 1021cb0ef41Sopenharmony_ci assert_equals(clickEvent.composedPath().length, 0) 1031cb0ef41Sopenharmony_ci }) 1041cb0ef41Sopenharmony_ci input.dispatchEvent(clickEvent) 1051cb0ef41Sopenharmony_ci}, "event state during post-click handling") 1061cb0ef41Sopenharmony_ci 1071cb0ef41Sopenharmony_ciasync_test(function(t) { 1081cb0ef41Sopenharmony_ci var input = document.createElement("input") 1091cb0ef41Sopenharmony_ci input.type = "checkbox" 1101cb0ef41Sopenharmony_ci dump.appendChild(input) 1111cb0ef41Sopenharmony_ci var clickEvent = new MouseEvent("click") 1121cb0ef41Sopenharmony_ci var finalTarget = document.createElement("doesnotmatter") 1131cb0ef41Sopenharmony_ci finalTarget.onclick = t.step_func_done(function() { 1141cb0ef41Sopenharmony_ci assert_equals(clickEvent.target, finalTarget) 1151cb0ef41Sopenharmony_ci assert_equals(clickEvent.srcElement, finalTarget) 1161cb0ef41Sopenharmony_ci }) 1171cb0ef41Sopenharmony_ci input.onchange = t.step_func(function() { 1181cb0ef41Sopenharmony_ci finalTarget.dispatchEvent(clickEvent) 1191cb0ef41Sopenharmony_ci }) 1201cb0ef41Sopenharmony_ci input.dispatchEvent(clickEvent) 1211cb0ef41Sopenharmony_ci}, "redispatch during post-click handling") 1221cb0ef41Sopenharmony_ci 1231cb0ef41Sopenharmony_ciasync_test(function(t) { 1241cb0ef41Sopenharmony_ci var input = document.createElement("input") 1251cb0ef41Sopenharmony_ci input.type = "checkbox" 1261cb0ef41Sopenharmony_ci dump.appendChild(input) 1271cb0ef41Sopenharmony_ci var child = input.appendChild(document.createElement("input")) 1281cb0ef41Sopenharmony_ci child.type = "checkbox" 1291cb0ef41Sopenharmony_ci child.disabled = true 1301cb0ef41Sopenharmony_ci child.click() 1311cb0ef41Sopenharmony_ci assert_false(input.checked) 1321cb0ef41Sopenharmony_ci assert_false(child.checked) 1331cb0ef41Sopenharmony_ci t.done() 1341cb0ef41Sopenharmony_ci}, "disabled checkbox still has activation behavior") 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ciasync_test(function(t) { 1371cb0ef41Sopenharmony_ci var state = "start" 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci var form = document.createElement("form") 1401cb0ef41Sopenharmony_ci form.onsubmit = t.step_func(() => { 1411cb0ef41Sopenharmony_ci if(state == "start" || state == "checkbox") { 1421cb0ef41Sopenharmony_ci state = "failure" 1431cb0ef41Sopenharmony_ci } else if(state == "form") { 1441cb0ef41Sopenharmony_ci state = "done" 1451cb0ef41Sopenharmony_ci } 1461cb0ef41Sopenharmony_ci return false 1471cb0ef41Sopenharmony_ci }) 1481cb0ef41Sopenharmony_ci dump.appendChild(form) 1491cb0ef41Sopenharmony_ci var button = form.appendChild(document.createElement("button")) 1501cb0ef41Sopenharmony_ci button.type = "submit" 1511cb0ef41Sopenharmony_ci var checkbox = button.appendChild(document.createElement("input")) 1521cb0ef41Sopenharmony_ci checkbox.type = "checkbox" 1531cb0ef41Sopenharmony_ci checkbox.onclick = t.step_func(() => { 1541cb0ef41Sopenharmony_ci if(state == "start") { 1551cb0ef41Sopenharmony_ci assert_unreached() 1561cb0ef41Sopenharmony_ci } else if(state == "checkbox") { 1571cb0ef41Sopenharmony_ci assert_true(checkbox.checked) 1581cb0ef41Sopenharmony_ci } 1591cb0ef41Sopenharmony_ci }) 1601cb0ef41Sopenharmony_ci checkbox.disabled = true 1611cb0ef41Sopenharmony_ci checkbox.click() 1621cb0ef41Sopenharmony_ci assert_equals(state, "start") 1631cb0ef41Sopenharmony_ci 1641cb0ef41Sopenharmony_ci state = "checkbox" 1651cb0ef41Sopenharmony_ci checkbox.disabled = false 1661cb0ef41Sopenharmony_ci checkbox.click() 1671cb0ef41Sopenharmony_ci assert_equals(state, "checkbox") 1681cb0ef41Sopenharmony_ci 1691cb0ef41Sopenharmony_ci state = "form" 1701cb0ef41Sopenharmony_ci button.click() 1711cb0ef41Sopenharmony_ci assert_equals(state, "done") 1721cb0ef41Sopenharmony_ci 1731cb0ef41Sopenharmony_ci t.done() 1741cb0ef41Sopenharmony_ci}, "disabled checkbox still has activation behavior, part 2") 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_ciasync_test(function(t) { 1771cb0ef41Sopenharmony_ci var input = document.createElement("input") 1781cb0ef41Sopenharmony_ci input.type = "checkbox" 1791cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 1801cb0ef41Sopenharmony_ci assert_true(input.checked) 1811cb0ef41Sopenharmony_ci }) 1821cb0ef41Sopenharmony_ci input.click() 1831cb0ef41Sopenharmony_ci}, "disconnected checkbox should be checked") 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ciasync_test(function(t) { 1861cb0ef41Sopenharmony_ci var input = document.createElement("input") 1871cb0ef41Sopenharmony_ci input.type = "radio" 1881cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(function() { 1891cb0ef41Sopenharmony_ci assert_true(input.checked) 1901cb0ef41Sopenharmony_ci }) 1911cb0ef41Sopenharmony_ci input.click() 1921cb0ef41Sopenharmony_ci}, "disconnected radio should be checked") 1931cb0ef41Sopenharmony_ci 1941cb0ef41Sopenharmony_ciasync_test(t => { 1951cb0ef41Sopenharmony_ci const input = document.createElement('input'); 1961cb0ef41Sopenharmony_ci input.type = 'checkbox'; 1971cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(() => { 1981cb0ef41Sopenharmony_ci assert_true(input.checked); 1991cb0ef41Sopenharmony_ci }); 2001cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent('click')); 2011cb0ef41Sopenharmony_ci}, `disconnected checkbox should be checked from dispatchEvent(new MouseEvent('click'))`); 2021cb0ef41Sopenharmony_ci 2031cb0ef41Sopenharmony_ciasync_test(t => { 2041cb0ef41Sopenharmony_ci const input = document.createElement('input'); 2051cb0ef41Sopenharmony_ci input.type = 'radio'; 2061cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(() => { 2071cb0ef41Sopenharmony_ci assert_true(input.checked); 2081cb0ef41Sopenharmony_ci }); 2091cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent('click')); 2101cb0ef41Sopenharmony_ci}, `disconnected radio should be checked from dispatchEvent(new MouseEvent('click'))`); 2111cb0ef41Sopenharmony_ci 2121cb0ef41Sopenharmony_citest(() => { 2131cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2141cb0ef41Sopenharmony_ci input.type = "checkbox"; 2151cb0ef41Sopenharmony_ci input.disabled = true; 2161cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click")); 2171cb0ef41Sopenharmony_ci assert_true(input.checked); 2181cb0ef41Sopenharmony_ci}, `disabled checkbox should be checked from dispatchEvent(new MouseEvent("click"))`); 2191cb0ef41Sopenharmony_ci 2201cb0ef41Sopenharmony_citest(() => { 2211cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2221cb0ef41Sopenharmony_ci input.type = "radio"; 2231cb0ef41Sopenharmony_ci input.disabled = true; 2241cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click")); 2251cb0ef41Sopenharmony_ci assert_true(input.checked); 2261cb0ef41Sopenharmony_ci}, `disabled radio should be checked from dispatchEvent(new MouseEvent("click"))`); 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ciasync_test(t => { 2291cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2301cb0ef41Sopenharmony_ci input.type = "checkbox"; 2311cb0ef41Sopenharmony_ci input.disabled = true; 2321cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(); 2331cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click")); 2341cb0ef41Sopenharmony_ci}, `disabled checkbox should fire onclick`); 2351cb0ef41Sopenharmony_ci 2361cb0ef41Sopenharmony_ciasync_test(t => { 2371cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2381cb0ef41Sopenharmony_ci input.type = "radio"; 2391cb0ef41Sopenharmony_ci input.disabled = true; 2401cb0ef41Sopenharmony_ci input.onclick = t.step_func_done(); 2411cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click")); 2421cb0ef41Sopenharmony_ci}, `disabled radio should fire onclick`); 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_ciasync_test(t => { 2451cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2461cb0ef41Sopenharmony_ci input.type = "checkbox"; 2471cb0ef41Sopenharmony_ci input.disabled = true; 2481cb0ef41Sopenharmony_ci input.onclick = t.step_func(ev => { 2491cb0ef41Sopenharmony_ci assert_true(input.checked); 2501cb0ef41Sopenharmony_ci ev.preventDefault(); 2511cb0ef41Sopenharmony_ci queueMicrotask(t.step_func_done(() => { 2521cb0ef41Sopenharmony_ci assert_false(input.checked); 2531cb0ef41Sopenharmony_ci })); 2541cb0ef41Sopenharmony_ci }); 2551cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click", { cancelable: true })); 2561cb0ef41Sopenharmony_ci}, `disabled checkbox should get legacy-canceled-activation behavior`); 2571cb0ef41Sopenharmony_ci 2581cb0ef41Sopenharmony_ciasync_test(t => { 2591cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2601cb0ef41Sopenharmony_ci input.type = "radio"; 2611cb0ef41Sopenharmony_ci input.disabled = true; 2621cb0ef41Sopenharmony_ci input.onclick = t.step_func(ev => { 2631cb0ef41Sopenharmony_ci assert_true(input.checked); 2641cb0ef41Sopenharmony_ci ev.preventDefault(); 2651cb0ef41Sopenharmony_ci queueMicrotask(t.step_func_done(() => { 2661cb0ef41Sopenharmony_ci assert_false(input.checked); 2671cb0ef41Sopenharmony_ci })); 2681cb0ef41Sopenharmony_ci }); 2691cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click", { cancelable: true })); 2701cb0ef41Sopenharmony_ci}, `disabled radio should get legacy-canceled-activation behavior`); 2711cb0ef41Sopenharmony_ci 2721cb0ef41Sopenharmony_citest(t => { 2731cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2741cb0ef41Sopenharmony_ci input.type = "checkbox"; 2751cb0ef41Sopenharmony_ci input.disabled = true; 2761cb0ef41Sopenharmony_ci const ev = new MouseEvent("click", { cancelable: true }); 2771cb0ef41Sopenharmony_ci ev.preventDefault(); 2781cb0ef41Sopenharmony_ci input.dispatchEvent(ev); 2791cb0ef41Sopenharmony_ci assert_false(input.checked); 2801cb0ef41Sopenharmony_ci}, `disabled checkbox should get legacy-canceled-activation behavior 2`); 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_citest(t => { 2831cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2841cb0ef41Sopenharmony_ci input.type = "radio"; 2851cb0ef41Sopenharmony_ci input.disabled = true; 2861cb0ef41Sopenharmony_ci const ev = new MouseEvent("click", { cancelable: true }); 2871cb0ef41Sopenharmony_ci ev.preventDefault(); 2881cb0ef41Sopenharmony_ci input.dispatchEvent(ev); 2891cb0ef41Sopenharmony_ci assert_false(input.checked); 2901cb0ef41Sopenharmony_ci}, `disabled radio should get legacy-canceled-activation behavior 2`); 2911cb0ef41Sopenharmony_ci 2921cb0ef41Sopenharmony_cifor (const type of ["checkbox", "radio"]) { 2931cb0ef41Sopenharmony_ci for (const handler of ["oninput", "onchange"]) { 2941cb0ef41Sopenharmony_ci async_test(t => { 2951cb0ef41Sopenharmony_ci const input = document.createElement("input"); 2961cb0ef41Sopenharmony_ci input.type = type; 2971cb0ef41Sopenharmony_ci input.onclick = t.step_func(ev => { 2981cb0ef41Sopenharmony_ci input.disabled = true; 2991cb0ef41Sopenharmony_ci }); 3001cb0ef41Sopenharmony_ci input[handler] = t.step_func(ev => { 3011cb0ef41Sopenharmony_ci assert_equals(input.checked, true); 3021cb0ef41Sopenharmony_ci t.done(); 3031cb0ef41Sopenharmony_ci }); 3041cb0ef41Sopenharmony_ci dump.append(input); 3051cb0ef41Sopenharmony_ci input.click(); 3061cb0ef41Sopenharmony_ci }, `disabling ${type} in onclick listener shouldn't suppress ${handler}`); 3071cb0ef41Sopenharmony_ci } 3081cb0ef41Sopenharmony_ci} 3091cb0ef41Sopenharmony_ci 3101cb0ef41Sopenharmony_ciasync_test(function(t) { 3111cb0ef41Sopenharmony_ci var form = document.createElement("form") 3121cb0ef41Sopenharmony_ci var didSubmit = false 3131cb0ef41Sopenharmony_ci form.onsubmit = t.step_func(() => { 3141cb0ef41Sopenharmony_ci didSubmit = true 3151cb0ef41Sopenharmony_ci return false 3161cb0ef41Sopenharmony_ci }) 3171cb0ef41Sopenharmony_ci var input = form.appendChild(document.createElement("input")) 3181cb0ef41Sopenharmony_ci input.type = "submit" 3191cb0ef41Sopenharmony_ci input.click() 3201cb0ef41Sopenharmony_ci assert_false(didSubmit) 3211cb0ef41Sopenharmony_ci t.done() 3221cb0ef41Sopenharmony_ci}, "disconnected form should not submit") 3231cb0ef41Sopenharmony_ci 3241cb0ef41Sopenharmony_ciasync_test(t => { 3251cb0ef41Sopenharmony_ci const form = document.createElement("form"); 3261cb0ef41Sopenharmony_ci form.onsubmit = t.step_func(ev => { 3271cb0ef41Sopenharmony_ci ev.preventDefault(); 3281cb0ef41Sopenharmony_ci assert_unreached("The form is unexpectedly submitted."); 3291cb0ef41Sopenharmony_ci }); 3301cb0ef41Sopenharmony_ci dump.append(form); 3311cb0ef41Sopenharmony_ci const input = form.appendChild(document.createElement("input")); 3321cb0ef41Sopenharmony_ci input.type = "submit" 3331cb0ef41Sopenharmony_ci input.disabled = true; 3341cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click", { cancelable: true })); 3351cb0ef41Sopenharmony_ci t.done(); 3361cb0ef41Sopenharmony_ci}, "disabled submit button should not activate"); 3371cb0ef41Sopenharmony_ci 3381cb0ef41Sopenharmony_ciasync_test(t => { 3391cb0ef41Sopenharmony_ci const form = document.createElement("form"); 3401cb0ef41Sopenharmony_ci form.onsubmit = t.step_func(ev => { 3411cb0ef41Sopenharmony_ci ev.preventDefault(); 3421cb0ef41Sopenharmony_ci assert_unreached("The form is unexpectedly submitted."); 3431cb0ef41Sopenharmony_ci }); 3441cb0ef41Sopenharmony_ci dump.append(form); 3451cb0ef41Sopenharmony_ci const input = form.appendChild(document.createElement("input")); 3461cb0ef41Sopenharmony_ci input.onclick = t.step_func(() => { 3471cb0ef41Sopenharmony_ci input.disabled = true; 3481cb0ef41Sopenharmony_ci }); 3491cb0ef41Sopenharmony_ci input.type = "submit" 3501cb0ef41Sopenharmony_ci input.dispatchEvent(new MouseEvent("click", { cancelable: true })); 3511cb0ef41Sopenharmony_ci t.done(); 3521cb0ef41Sopenharmony_ci}, "submit button should not activate if the event listener disables it"); 3531cb0ef41Sopenharmony_ci 3541cb0ef41Sopenharmony_ciasync_test(t => { 3551cb0ef41Sopenharmony_ci const form = document.createElement("form"); 3561cb0ef41Sopenharmony_ci form.onsubmit = t.step_func(ev => { 3571cb0ef41Sopenharmony_ci ev.preventDefault(); 3581cb0ef41Sopenharmony_ci assert_unreached("The form is unexpectedly submitted."); 3591cb0ef41Sopenharmony_ci }); 3601cb0ef41Sopenharmony_ci dump.append(form); 3611cb0ef41Sopenharmony_ci const input = form.appendChild(document.createElement("input")); 3621cb0ef41Sopenharmony_ci input.onclick = t.step_func(() => { 3631cb0ef41Sopenharmony_ci input.type = "submit" 3641cb0ef41Sopenharmony_ci input.disabled = true; 3651cb0ef41Sopenharmony_ci }); 3661cb0ef41Sopenharmony_ci input.click(); 3671cb0ef41Sopenharmony_ci t.done(); 3681cb0ef41Sopenharmony_ci}, "submit button that morphed from checkbox should not activate"); 3691cb0ef41Sopenharmony_ci</script> 370