inert-and-contenteditable.html (1913B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Inert and contenteditable</title> 4 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert"> 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable"> 7 <meta assert="assert" content=" 8 Executing an editing command in a node marked as both inert and editable 9 should have the same result regardless of which ancestors trigger each effect. 10 Only testing for consistency, the exact result is not interoperable."> 11 12 <div id="log"></div> 13 14 <div class="wrapper" contenteditable inert> 15 {<p class="target">target</p>} 16 </div> 17 18 <div class="wrapper" contenteditable> 19 {<p class="target" inert>target</p>} 20 </div> 21 22 <div class="wrapper" inert> 23 {<p class="target" contenteditable>target</p>} 24 </div> 25 26 <div class="wrapper"> 27 {<p class="target" contenteditable inert>target</p>} 28 </div> 29 30 <script src="/resources/testharness.js"></script> 31 <script src="/resources/testharnessreport.js"></script> 32 <script> 33 const results = []; 34 const textContents = []; 35 setup(function() { 36 const selection = getSelection(); 37 for (let wrapper of document.querySelectorAll(".wrapper")) { 38 const target = wrapper.querySelector(".target"); 39 selection.collapse(target.firstChild, 3); 40 results.push(document.execCommand("delete")); 41 textContents.push(wrapper.textContent.trim()); 42 } 43 }); 44 function testSameValues(array, description) { 45 test(function() { 46 assert_greater_than(array.length, 0, "Array shouldn't be empty"); 47 for (let i = 1; i < array.length; ++i) { 48 assert_equals(array[i], array[0], `${JSON.stringify(array)} at index ${i}`); 49 } 50 }, description); 51 } 52 testSameValues(results, "execCommand should return the same value"); 53 testSameValues(textContents, "The resulting textContent should be the same value"); 54 </script>