File: margin-002.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (93 lines) | stat: -rw-r--r-- 4,537 bytes parent folder | download | duplicates (10)
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>margin</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that margin is taken into account.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
  math {
    font: 25px/1 Ahem;
  }
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="/mathml/support/box-comparison.js"></script>
<script src="/mathml/support/fonts.js"></script>
<script>
  var epsilon = 2;

  setup({ explicit_done: true });
  window.addEventListener("load", () => { loadAllFonts().then(runTests); });

  function runTests() {

    for (tag in MathMLFragments) {
        if (!FragmentHelper.isValidChildOfMrow(tag))
            continue;

        var style = "margin-left: 30px; margin-right: 40px;  margin-top: 50px; margin-bottom: 60px;";

        if (FragmentHelper.isEmpty(tag)) {
            test(function() {
                assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
                var s = compareSizeWithAndWithoutStyle(tag, style);
                assert_approx_equals(s.width_delta, 30 + 40, epsilon, "left/right margin");
                assert_approx_equals(s.height_delta, 50 + 60, epsilon, "top/bottom margin");
                assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
                assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
                assert_approx_equals(s.preferred_width_delta, 30 + 40, epsilon, "preferred width");
            }, `Margin properties on ${tag}`);
            continue;
        }

        test(function() {
            assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
            var s = compareSpaceWithAndWithoutStyle(tag, style);
            assert_approx_equals(s.left_delta, 30, epsilon, "left margin");
            assert_approx_equals(s.right_delta, 40, epsilon, "right margin");
            assert_approx_equals(s.top_delta, 50, epsilon, "top margin");
            assert_approx_equals(s.bottom_delta, 60, epsilon, "bottom margin");
            assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
            assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
            assert_approx_equals(s.preferred_width_delta, 30 + 40, epsilon, "preferred width");
        }, `Margin properties on ${tag}`);

        test(function() {
            assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
            var s = compareSpaceWithAndWithoutStyle(tag, style, null, "rtl");
            assert_approx_equals(s.left_delta, 30, epsilon, "left margin");
            assert_approx_equals(s.right_delta, 40, epsilon, "right margin");
            assert_approx_equals(s.top_delta, 50, epsilon, "top margin");
            assert_approx_equals(s.bottom_delta, 60, epsilon, "bottom margin");
            assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
            assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
            assert_approx_equals(s.preferred_width_delta, 30 + 40, epsilon, "preferred width");
        }, `Margin properties on ${tag} (rtl)`);

        test(function() {
            assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
            // Apply the same margin style on the parent mrow.
            // The margins are not collapsed so they should be added twice.
            var s = compareSpaceWithAndWithoutStyle(tag, style, style);
            assert_approx_equals(s.left_delta, 30 * 2, epsilon, "left margin");
            assert_approx_equals(s.right_delta, 40 * 2, epsilon, "right margin");
            assert_approx_equals(s.top_delta, 50 * 2, epsilon, "top margin");
            assert_approx_equals(s.bottom_delta, 60 * 2, epsilon, "bottom margin");
            assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
            assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
            assert_approx_equals(s.preferred_width_delta, (30 + 40) * 2, epsilon, "preferred width");
        }, `Margin properties on ${tag} (no margin-collapsing)`);
    }

    done();
  }
</script>
</head>
<body>
  <div id="log"></div>
</body>
</html>