tor-browser

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

fire-selection-change-on-deleting-empty-element.html (1641B)


      1 <!doctype HTML>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/resources/testdriver.js"></script>
      5 <script src="/resources/testdriver-vendor.js"></script>
      6 
      7 <body>
      8  <div contenteditable="true" id="target"></div>
      9  <script>
     10    // Selection should be updated when removing element in contenteditable div
     11    promise_test(async () => {
     12        const target = document.getElementById("target");
     13        const backSpaceKey = "\uE003";
     14        target.innerHTML = "<h1>A</h1>";
     15        let selectionChangeCount = 0;
     16        await new test_driver.click(target);
     17        // Waits a short time to allow any events to be processed.
     18        await new Promise(resolve => step_timeout(resolve, 500));
     19        await new test_driver.send_keys(target, backSpaceKey);
     20        // Waits a short time to process all selectionchange events currently in the queue.
     21        await new Promise(resolve => step_timeout(resolve, 500));
     22        const expectedHTML = "<h1><br></h1>";
     23        assert_equals(target.innerHTML, expectedHTML, "Character should be removed");
     24        document.addEventListener("selectionchange", () => ++selectionChangeCount);
     25        // Remove the <h1> element
     26        await new test_driver.send_keys(target, backSpaceKey);
     27        // Waits a short time to process all selectionchange events currently in the queue.
     28        await new Promise(resolve => step_timeout(resolve, 500));
     29        assert_equals(selectionChangeCount, 1, "Selection change count should match");
     30    }, "Selection is updated after removing the element in contenteditable div");
     31  </script>
     32 </body>