inert-node-is-uneditable.html (2071B)
1 <!DOCTYPE html> 2 <link rel=author href="mailto:jarhar@chromium.org"> 3 <link rel=author href="mailto:falken@chromium.org"> 4 <link rel=help href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element"> 5 <link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=252071"> 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-actions.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 12 <span id="not-editable" contenteditable>I'm not editable while the dialog is showing.</span> 13 <dialog> 14 <span id="editable" contenteditable>I'm editable.</span> 15 </dialog> 16 17 <script> 18 promise_test(async () => { 19 async function clickOn(element) { 20 let absoluteTop = 0; 21 let absoluteLeft = 0; 22 for (let parentNode = element; parentNode; parentNode = parentNode.offsetParent) { 23 absoluteLeft += parentNode.offsetLeft; 24 absoluteTop += parentNode.offsetTop; 25 } 26 27 const x = Math.round(absoluteLeft + element.offsetWidth / 2); 28 const y = Math.round(absoluteTop + element.offsetHeight / 2); 29 const actions = new test_driver.Actions() 30 .pointerMove(x, y) 31 .pointerDown() 32 .pointerUp() 33 .pointerMove(0, 0); 34 await actions.send(); 35 } 36 37 dialog = document.querySelector('dialog'); 38 dialog.showModal(); 39 notEditable = document.querySelector('#not-editable'); 40 editable = document.querySelector('#editable'); 41 42 await clickOn(notEditable); 43 oldValue = notEditable.textContent; 44 await (new test_driver.Actions().keyDown('a').keyUp('a').send()); 45 assert_equals(notEditable.textContent, oldValue); 46 47 await clickOn(editable); 48 oldValue = editable.textContent; 49 await (new test_driver.Actions().keyDown('a').keyUp('a').send()); 50 assert_not_equals(editable.textContent, oldValue); 51 52 notEditable.remove(); 53 editable.remove(); 54 }, 'Test that inert nodes cannot be edited. The test passes if the only text you can edit is in the dialog.'); 55 </script>