File: marker-computed-size.html

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (85 lines) | stat: -rw-r--r-- 2,937 bytes parent folder | download | duplicates (3)
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
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: Computed size of ::marker</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
<link rel="help" href="https://drafts.csswg.org/css-lists/#content-property">
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<meta name="assert" content="This test checks that getComputedStyle exposes the resolved sizes of a ::marker." />
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
:root {
  --image: url('/images/green-100x50.png');
}
:root::after {
  /* Preload image */
  content: var(--image);
}
#target {
  font: 10px/1 Ahem;
  --content: normal;
}
#target::marker {
  content: var(--content);
}
</style>
<div id="log"></div>
<ul>
  <li id="target"></li>
</ul>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const target = document.getElementById("target");
function checkMarkerSize(expectedWidth, expectedHeight) {
  const {width, height} = getComputedStyle(target, "::marker");
  assert_equals(width, expectedWidth, "width");
  assert_equals(height, expectedHeight, "height");
}
setup({explicit_done: true});
addEventListener("load", () => {
  document.fonts.load("10px Ahem").then(() => {
    test(() => {
      // Marker string: "1. "
      target.style.listStyleType = "decimal";
      checkMarkerSize("30px", "10px");
    }, "Decimal ::marker");
    test(() => {
      // Marker string: "10. "
      target.setAttribute("value", "10");
      checkMarkerSize("40px", "10px");
    }, "Decimal ::marker with custom value");
    test(() => {
      // Marker string: "st"
      target.style.listStyleType = "'st'";
      checkMarkerSize("20px", "10px");
    }, "String ::marker");
    test(() => {
      // No marker box
      target.style.listStyleType = "none";
      checkMarkerSize("auto", "auto");
    }, "::marker with no box due to 'list-style'");
    test(() => {
      // Marker contents: "foo", "bar"
      target.style.setProperty("--content", "'foo' 'bar'");
      checkMarkerSize("60px", "10px");
    }, "::marker with custom string contents");
    test(() => {
      // Marker contents: 100x50 image (+2px due to baseline alignment)
      target.style.setProperty("--content", "var(--image)");
      checkMarkerSize("100px", "52px");
    }, "::marker with custom image contents");
    test(() => {
      // Marker contents: "foo", 100x50 image (+2px due to baseline alignment)
      target.style.setProperty("--content", "'foo' var(--image)");
      checkMarkerSize("130px", "52px");
    }, "::marker with custom string and image contents");
    test(() => {
      // No marker box
      target.style.listStyleType = "";
      target.style.setProperty("--content", "none");
      checkMarkerSize("auto", "auto");
    }, "::marker with no box due to 'content'");
    done();
  });
}, {once: true});
</script>