tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

merge-span-with-style-after-backspace-having-contenteditable.html (1568B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>Merge Span with style after backspace having contenteditable</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 </head>
     12 <body>
     13 <div contenteditable><h1><span style="background-color:red;">Back</span></h1>
     14 <h1><span style="background-color: red;" id="space">space</span></h1></div>
     15 <script>
     16 "use strict";
     17 
     18 const kBackspaceKey = "\uE003";
     19 
     20 function sendBackspaceKey() {
     21  return new test_driver.Actions()
     22    .keyDown(kBackspaceKey)
     23    .keyUp(kBackspaceKey)
     24    .send();
     25 }
     26 
     27 promise_test(async () => {
     28  const editableDiv = document.querySelector("div[contenteditable]");
     29  const spaceSpan = editableDiv.querySelectorAll('span')[1];
     30  await new test_driver.click(document.querySelector('#space'));
     31  const range = document.createRange();
     32  const selection = window.getSelection();
     33  const textNode = spaceSpan.firstChild;
     34  range.setStart(textNode, 0);
     35  range.setEnd(textNode, 0);
     36  selection.removeAllRanges();
     37  selection.addRange(range);
     38  await sendBackspaceKey();
     39  assert_equals(
     40    editableDiv.innerHTML,
     41    "<h1><span style=\"background-color:red;\">Back</span><span style=\"background-color: red;\">space</span></h1>",
     42    "Style is not preserved for the span after pressing backspace in contenteditable"
     43  );
     44 }, "waiting for command to execute");
     45 </script>
     46 </body>
     47 </html>