summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-pseudo/active-selection-043.html
blob: 944bf5526ecbea16695303a11b1176f61f79a1d3 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>

<html class="reftest-wait">

  <meta charset="UTF-8">

  <title>CSS Pseudo-Elements Test: active selection and image (complex)</title>

  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
  <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-bounds">
  <link rel="match" href="../reference/ref-nothing-below.xht">

  <meta name="assert" content="In this test, a filled red image has a padding belt painted red and a red border. This test checks that the associated overlay for an image must not leak outside the image's border box.">

  <!--

  "
   For replaced content, the associated overlay must cover
   at least the entire replaced object, and may extend
   outward to include the element's entire content box.
   The overlay may also include other other areas within
   the border-box of an element (...)
  "
  coming from
  https://www.w3.org/TR/css-pseudo-4/#highlight-bounds

  -->

  <style>
  div
    {
      font-size: 300%;
    }

  img
    {
      background-color: red;
      /* so that the padding belt is painted red */
      border: red solid 10px;
      padding: 10px;
    }

  /*
  Chromium 80+ highlights the descender space
  below the baseline on which the image "sits" while
  Firefox 72+ only highlights the image itself.
  */

  img::selection
    {
      background-color: red;
      color: red;
    }

  span#masking
    {
      background-color: white;
      display: inline-block;
      height: 100px;
      position: relative;
      right: 100px;
      width: 100px;
    }
  </style>

  <script>
  function startTest()
  {
  var targetRange = document.createRange();
  /* We first create an empty range */
  targetRange.selectNodeContents(document.getElementById("test"));
  /* Then we set the range boundaries to the children of div#test */
  window.getSelection().addRange(targetRange);
  /* Finally, we now select such range of content */
  document.documentElement.className = "";
  }
  </script>

  <body onload="startTest();">

  <p>Test passes if there is nothing below.

  <div id="test"><img src="support/60x60-red.png" alt="Image download support must be enabled"><span id="masking"></span></div>