File: align.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 (59 lines) | stat: -rw-r--r-- 2,234 bytes parent folder | download | duplicates (23)
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
<!doctype html>
<title>align attribute mapping on replaced elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<img id="replaced" src="/images/green.png">
<something id="non-replaced"></something>
<script>
const kMapping = {
  "left": ["float", "left"],
  "right": ["float", "right"],

  "top": ["vertical-align", "top"],

  // This one requires a magic value (`-moz-middle-with-baseline` on Gecko,
  // `-webkit-baseline-middle` on WebKit-based browsers).
  "middle": ["vertical-align", undefined],
  // These are inconsistent across browsers. WebKit maps it to "middle", Gecko
  // to the aforementioned value.
  "center": ["vertical-align", undefined],

  "baseline": ["vertical-align", "baseline"],
  "bottom": ["vertical-align", "baseline"], // *shrug*

  "texttop": ["vertical-align", "text-top"],
  "absmiddle": ["vertical-align", "middle"],
  "abscenter": ["vertical-align", "middle"],
  "absbottom": ["vertical-align", "bottom"],
};

const kInitialValues = {
  "vertical-align": "baseline",
  "float": "none",
};

let replaced = document.getElementById("replaced");
let nonReplaced = document.getElementById("non-replaced");
let t = async_test("align attribute mapping");
onload = t.step_func_done(function() {
  for (const attributeValue in kMapping) {
    for (const element of [replaced, nonReplaced]) {
      test(function() {
        element.setAttribute("align", attributeValue);
        let [property, expected] = kMapping[attributeValue];
        let actual = getComputedStyle(element).getPropertyValue(property);
        if (element == nonReplaced) {
          assert_equals(actual, kInitialValues[property], "align shouldn't map to non-replaced elements")
        } else {
          if (expected) {
            assert_equals(actual, expected, `align=${attributeValue} should map to ${property}: ${expected}`);
          } else {
            assert_equals(property, "vertical-align");
            assert_not_equals(actual, "baseline", `align=${attributeValue} should map a vertical-align value`);
          }
        }
      }, `align=${attributeValue} on ${element == replaced ? "replaced" : "non-replaced"} elements`);
    }
  }
});
</script>