tor-browser

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

test_contenteditable_copy_empty_selection.html (1020B)


      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1857303
      5 -->
      6 <head>
      7    <meta charset="utf-8">
      8    <title>Test for contenteditable copy event fired even when selection is empty</title>
      9    <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10    <script src="/tests/SimpleTest/EventUtils.js"></script>
     11    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     12 </head>
     13 <body>
     14    <div contenteditable=true id="elem">Copy</div>
     15    <script>
     16        SimpleTest.waitForExplicitFinish();
     17        SimpleTest.waitForFocus(() => {
     18            let copyEventFired = false;
     19            const editableDiv = document.getElementById("elem");
     20 
     21            editableDiv.addEventListener("copy", function () {
     22                copyEventFired = true;
     23            });
     24 
     25            editableDiv.focus();
     26            synthesizeKey("c", { accelKey: true });
     27            ok(copyEventFired, "Copy event should be fired");
     28 
     29            SimpleTest.finish();
     30        });
     31    </script>
     32 </body>
     33 </html>