summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-backgrounds/background-attachment-353.html
blob: ca5a41d05ab9e13541e2725289a59d8908b51e41 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html class="reftest-wait">
  <meta charset="UTF-8">

  <title>CSS Background and Borders Test: 'background-attachment: local' and 'overflow: hidden'</title>

  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
  <link rel="help" href="http://www.w3.org/TR/css3-background/#the-background-attachment">
  <link rel="match" href="../reference/ref-filled-green-100px-square.xht">
  <script src="/common/reftest-wait.js"></script>
  <link rel="preload" as="image" href="support/100x100-gr-rr.png" onload="takeScreenshot()" />
  <link rel="stylesheet" type="text/css" href="/fonts/ahem.css">

  <!--

  More info:

  Re: [css3-background] background-attachment: local
  http://lists.w3.org/Archives/Public/www-style/2013May/0542.html

  -->

  <meta content="This test checks that when an element has 'background-attachment: local', then the background image is fixed with regard to what is the element's scrollable area and not to its viewport. In this test, what would be the scrollable area for the div#target element is where the red area of its background image 100x100-gr-rr.png is and such area is clipped due to 'overflow: hidden'." name="assert">

  <style>
  div#control
    {
      background-color: red;
      border: solid green;
      border-width: 50px 0 0 50px;
      height: 50px;
      margin-bottom: -100px;
      width: 50px;
    }

  div#target
    {
      background-attachment: local;
      background-image: url("support/100x100-gr-rr.png");
      background-repeat: no-repeat;
      background-position: center;
      font-family: Ahem;
      font-size: 100px;
      line-height: 1;
      height: 100px;
      overflow: hidden;
      width: 100px;
    }
  </style>

  <body>

  <p>Test passes if there is a filled green square and <strong>no red</strong>.

  <div id="control"></div>

  <div id="target">&nbsp;&nbsp;<br>&nbsp;&nbsp;</div>

  <!--

  div#control is

  (0px, 0px)              (100px, 0px)
  +.......................+
  |                       |
  |                       |
  |     green  area       |
  |                       |
  |                       |
  |     green  area       |
  |                       |
  |             +........+|
  |   green     |  red   ||
  |    area     | area   ||
  |             |        ||
  |             +........+|
  +.......................+
(0px, 100px)            (100px, 100px)


  =   =   =   =   =   =   =


  div#target with background-position: top left

  (0px, 0px)              (100px, 0px)
  +.......................+
  | +........+            |
  | | green  |    red     |
  | |  area  |    area    |
  | |        |            |
  | +........+            |
  |                       |
  |      red  area        |
  |                       |
  |                       |
  |      red  area        |
  |                       |
  |                       |
  +.......................+
(0px, 100px)            (100px, 100px)


  =   =   =   =   =   =   =


  div#target with background-position: center

  (0px, 0px)              (100px, 0px)
  +.......................+
  |                       |
  |     green  area       |
  |                       |   overflowed
  |                       |      area
  |     green  area       |        |
  |                       |        V
  |           +...........| ...........+
  |           | +........+|             |
  |   green   | |  green ||     red     |
  |    area   | |  area  ||    area     |
  |           | |        ||             |
  |           | +........+|             |
  +.......................+             |
              |                         |
              |        red  area        |   <==  overflowed
              |                         |   <==     area
              |        red  area        |
              |                         |
              |                         |
              +.........................+

  -->