File: snap-events-with-pseudo-target.tentative.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (86 lines) | stat: -rw-r--r-- 2,820 bytes parent folder | download | duplicates (13)
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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title> CSS Scroll Snap 2 Test: Snap Events with pseudo-element targets.</title>
    <link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#snap-events">
    <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>
    <script src="/css/css-scroll-snap/snap-events/resources/common.js"></script>
    <script src="/css/css-scroll-snap/snap-events/resources/user-scroll-common.js"></script>
    <script src="/dom/events/scrolling/scroll_support.js"></script>
  </head>
  <body>
    <style>
      .scroller {
        overflow: scroll;
        width: 200px;
        height: 200px;
        border: solid 1px black;
        scroll-snap-type: y mandatory;
        position: absolute;
        resize: both;
      }
      .space {
        height: 300vh;
        width: 300vw;
        position: absolute;
      }
      .scroller::before, .scroller::after {
        scroll-snap-align: start;
        height: 50px;
        width: 50px;
        color: white;
        display: block;
      }
      .scroller::before {
        content: "before";
        background-color: blue;
      }
      .scroller::after {
        content: "after";
        background-color: orange;
        margin-top: 100px;
      }
    </style>
    <div class="scroller" id="scroller">
      <div class="space"></div>
    </div>

    <script>
      const start_pos = {
        x: scroller.clientWidth / 2,
        y: scroller.clientHeight / 2,
      };
      const end_pos = { x: scroller.clientWidth / 2, y: 0 };
      // The top of the ::after pseudo element is the sum of the
      // ::before pseudo-element's height (50) and the ::after
      // pseudo-element's margin-top (100).
      const after_pseudo_element_top = 50 + 100;
      const test_data = {
        scroller: scroller,
        scrolling_function: async () => {
          await snap_event_touch_scroll_helper(start_pos, end_pos);
        },
        expected_snap_targets: { block: scroller, inline: null },
        expected_scroll_offsets: {
          x: 0,
          y: after_pseudo_element_top,
        }
      };

      promise_test(async (t) => {
        await test_scrollsnapchange(t, test_data);
      }, "snapTarget for scrollsnapchange is the owning element when a snap area " +
         "belongs to a pseudo-element");

      promise_test(async (t) => {
        await test_snap_event(t, test_data, "scrollsnapchanging");
      }, "snapTarget for scrollsnapchanging is the owning element when a snap area " +
         "belongs to a pseudo-element");
    </script>
  </body>
</html>