tor-browser

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

test_image_selection_3.html (1874B)


      1 <!doctype html>
      2 <title>Test for bug 1754459</title>
      3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      4 <script src="/tests/SimpleTest/EventUtils.js"></script>
      5 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      6 <style>
      7  /* This avoids the draggable image check that our code does to avoid handling the mousedown. */
      8  img { pointer-events: none }
      9 </style>
     10 <div id="block">
     11  Some text <img width="100" height="100" id="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyAQMAAACQ%2B%2Bz9AAAAA1BMVEUA%2FwA0XsCoAAAAD0lEQVQoFWNgGAWjYGgCAAK8AAEb3eOQAAAAAElFTkSuQmCC"> and more.
     12 </div>
     13 <script>
     14 const image = document.getElementById("image");
     15 const block = document.getElementById("block");
     16 const selection = window.getSelection();
     17 
     18 function clickOnImage(x, y) {
     19  synthesizeMouse(image, x, y, {});
     20 }
     21 
     22 add_task(async function test_click_pointer_events_none() {
     23  await SimpleTest.promiseFocus(window);
     24  clickOnImage(10, 10);
     25  ok(selection.isCollapsed, "Should be collapsed");
     26  is(selection.focusNode, block, "Should be at block");
     27  is(selection.focusOffset, 1, "Should be at start of image");
     28 
     29  clickOnImage(60, 10);
     30  ok(selection.isCollapsed, "Should be collapsed");
     31  is(selection.focusNode, block, "Should be at block");
     32  is(selection.focusOffset, 2, "Should be at end of image");
     33 });
     34 
     35 add_task(async function test_click_pointer_events_none_vertical() {
     36  block.style.writingMode = "vertical-lr";
     37  block.getBoundingClientRect();
     38  clickOnImage(10, 10);
     39  ok(selection.isCollapsed, "Should be collapsed");
     40  is(selection.focusNode, block, "Should be at start of image");
     41  is(selection.focusOffset, 1, "Should be at start of image");
     42 
     43  clickOnImage(10, 60);
     44  ok(selection.isCollapsed, "Should be collapsed");
     45  is(selection.focusNode, block, "Should be at block");
     46  is(selection.focusOffset, 2, "Should be at end of image");
     47 });
     48 </script>