summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/selection/select-end-of-line-image.tentative.html
blob: 572296c4439572d66095e4d6d98c84739f50c504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
  <meta charset="utf-8">
  <title>Selection: Select the image at the end of the line</title>
  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
  <link rel="author" title="Mozilla" href="https://www.mozilla.org/">
  <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1745435">

  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/resources/testdriver.js"></script>
  <script src="/resources/testdriver-actions.js"></script>
  <script src='/resources/testdriver-vendor.js'></script>

  <style>
  img {
    inline-size: 100px;
    block-size: 20px;
    background: orange;
  }
  </style>

  <body>
    You shouldn't see an orange image at the end of this line
    <img id="target" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text>hello</text></svg>'>
  </body>

  <script>
  promise_test(async function() {
    let target = document.getElementById("target");
    let actions = new test_driver.Actions();

    // Move the pointer from the left edge of the image, to the right for about
    // 3/4 width of the image. This should be sufficient to select the image.
    await actions.pointerMove(0, 10, {origin: target})
                 .pointerDown()
                 .pointerMove(75, 10, {origin: target})
                 .pointerUp()
                 .send();

    // Delete the image to verify the image is selected. It's tricky to verify
    // it using Range API.
    window.getSelection().deleteFromDocument();

    assert_equals(document.getElementById("target"), null,
                  "The image should be selected and then deleted.")
  }, "Select image at the end of the line.");
  </script>
</html>