delete-img.tentative.html (2139B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="flags" content="may"> 6 <title>Testing normalizing white-space sequence after deleting image surrounded by white-spaces</title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="../../include/editor-test-utils.js"></script> 10 <script> 11 "use strict"; 12 13 addEventListener("load", () => { 14 // README: 15 // These tests based on the behavior of Chrome 134. This test does NOT define 16 // nor suggest any standard behavior (actually, some expected results might 17 // look odd), but this test must help you to understand how other browsers 18 // use different logic to normalize white-space sequence. 19 20 const editingHost = document.querySelector("div[contenteditable]"); 21 const utils = new EditorTestUtils(editingHost); 22 const img = document.querySelector("img"); 23 const imgURL = img.getAttribute("src"); 24 25 async function addPromiseTest(aInitHTML, aExpectedHTML) { 26 promise_test(async () => { 27 utils.setupEditingHost(aInitHTML); 28 document.execCommand("delete"); 29 assert_equals(editingHost.innerHTML, aExpectedHTML); 30 }, `document.execCommand("delete") when "${aInitHTML.replaceAll(/src=".+"/g, 'src="${src}"')}"`); 31 } 32 33 const src = "../../../images/green-16x16.png"; 34 addPromiseTest( 35 `<img src="${src}">[] `, 36 ` ` 37 ); 38 addPromiseTest( 39 `<img src="${src}">[] b`, 40 ` b` 41 ); 42 addPromiseTest( 43 `a<img src="${src}">[] b`, 44 `a b` 45 ); 46 addPromiseTest( 47 `a <img src="${src}">[] b`, 48 `a b` 49 ); 50 addPromiseTest( 51 `a <img src="${src}">[]b`, 52 `a b` 53 ); 54 addPromiseTest( 55 `a <img src="${src}">{}`, 56 `a ` 57 ); 58 addPromiseTest( 59 `a <img src="${src}">{}`, 60 `a ` 61 ); 62 }, {once: true}); 63 </script> 64 </head> 65 <body> 66 <div><img src="../../../images/green-16x16.png"></div> 67 <div contenteditable></div> 68 </body> 69 </html>