restyle-textcontrol-during-beforeinput.html (1268B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Restyle text control at `beforeinput`</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 <script src="/resources/testdriver-actions.js"></script> 11 <script src="../include/editor-test-utils.js"></script> 12 <script> 13 "use strict"; 14 15 addEventListener("load", () => { 16 for (const selector of ["input", "textarea"]) { 17 promise_test(async () => { 18 const textControl = document.querySelector(selector); 19 textControl.focus(); 20 textControl.addEventListener("beforeinput", () => { 21 textControl.style.display = textControl.style.display == "block" ? "inline" : "block"; 22 textControl.getBoundingClientRect(); // Flush the restyle before back to the builtin editor 23 }); 24 await new test_driver.Actions() 25 .keyDown("a") 26 .keyUp("a") 27 .keyDown("b") 28 .keyUp("b") 29 .send(); 30 assert_equals(textControl.value, "ab"); 31 }, `${selector} should accept text input even after restyled`); 32 } 33 }, {once: true}); 34 </script> 35 </head> 36 <body> 37 <input> 38 <textarea></textarea> 39 </body> 40 </html>