summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-tables/html-to-css-mapping-1.html
blob: c29fd1db9db0670d43b50141df1fc413022c7aea (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
<!doctype html>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<link rel='stylesheet' href='./support/base.css' />
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#fixup">
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#mapping">
<main>

    <h1>HTML-2-CSS Mapping</h1>
    <p>Checks that browsers implement properly the html2css stylesheet (rules without attributes)</p>

    <hr/>
    <p>You should see a 5 2px blue square here, separated by 2px each:</p>
    <p>Because of the lack of the table element, border-spacing is 0; padding on each td should be 1px on each side. 1px*2*5=10px.</p>
    <div><table><tbody style="background: blue; height: 2px"><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>

    <hr/>
    <p>You should see a 10px blue square here:</p>
    <p>Because of the lack of the table element, border-spacing is 0; padding on each td should be 1px on each side. 1px*2*5=10px.</p>
    <div><table class="to-remove"><tbody style="background: blue; height: 10px"><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>

    <hr/>
    <p>You should see a 12px blue square here:</p>
    <p>The table has the background; x-td elements have no padding, only the border-spacing remains. 6*2px=12px.</p>
    <div><table style="height: 12px; background: blue;" class="no-td"><tbody><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>

    <hr/>
    <p>You shouldn't see anything here:</p>
    <p>The table has the background but is empty; it does not apply border-spacing in this case.</p>
    <div><table style="height: 2px; background: red"></table></div>

    <script>void function() { var table; while(table = document.querySelector('.to-remove')) table.parentNode.replaceChild(table.firstChild,table) }();</script>
    <script>void function() { var td; while(td = document.querySelector('table.no-td td')) td.parentNode.replaceChild(document.createElement('x-td'),td) }();</script>

</main>

<script>

    var i = 1;
    generate_tests(assert_equals, [
        [
            "HTML -> CSS Mapping is applied correctly on proper table markup (border-spacing, padding)",
            document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
            22
        ],
        [
            "HTML -> CSS Mapping is applied correctly on improper table markup (no table => no border-spacing, but padding)",
            document.querySelector("main > div:nth-of-type("+(i++)+") tbody").offsetWidth,
            10
        ],
        [
            "HTML -> CSS Mapping is applied correctly on improper table markup (no td => border-spacing, but no padding)",
            document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
            12
        ],
        [
            "HTML -> CSS Mapping is applied correctly on empty table markup (no content => no border-spacing, no padding)",
            document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
            0
        ],
    ])

</script>