summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-tables/html5-table-formatting-1.html
blob: f0c96dd707c0ecefafbf9e767192906104aefcad (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
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
94
95
96
97
98
<!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/#table-layout-algorithm">
<main>

    <h1>HTML5 Table Formatting algorithm (row/column grid computation)</h1>
    <p>Verifies how browser define and act on empty tables</p>

    <hr/>
    <p>This should be a 50px by 50px blue square:</p>
    <p>The table grid is 0x0, so the table is empty and follows step 3B of the table layout algorithm</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;"></x-table>

    <hr/>
    <p>This should be a 50px by 50px blue square:</p>
    <p>The table grid is 2x0, so the table is empty and follows step 3B of the table layout algorithm</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;">
        <x-col style="width: 100px"></x-col>
        <x-col style="width: 100px"></x-col>
    </x-table>

    <hr/>
    <p>This should be a 50px by 50px blue square:</p>
    <p>The table grid is 0x1, so the table is empty and follows step 3B of the table layout algorithm</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;">
        <x-tr style="height: 100px; background: orange;"></x-tr>
    </x-table>

    <hr/>
    <p>This should be a 200px by 100px blue rectangle:</p>
    <p>The table grid is 2x1, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;">
        <x-col style="width: 100px"></x-col>
        <x-col style="width: 100px"></x-col>
        <x-tr style="height: 100px; background: orange;"></x-tr>
    </x-table>

    <hr/>
    <p>This should be a 200px by 100px half-blue half-orange rectangle:</p>
    <p>The table grid is 2x1, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;">
        <x-col style="width: 100px"></x-col>
        <x-col style="width: 100px"></x-col>
        <x-tr style="height: 100px; background: orange;"><x-td></x-td></x-tr>
    </x-table>

    <hr/>
    <p>This should be a 200px by 100px orange rectangle:</p>
    <p>The table grid is 2x1, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p>
    <x-table style="min-width: 50px; height: 50px; background: blue;">
        <x-col style="width: 100px"></x-col>
        <x-col style="width: 100px"></x-col>
        <x-tr style="height: 100px; background: orange;"><x-td></x-td><x-td></x-td></x-tr>
    </x-table>

</main>

<script>

    generate_tests(assert_equals, [
        [
            "Empty tables can still get a lsyout",
            document.querySelector("x-table:nth-of-type(1)").offsetWidth,
            50
        ],
        [
            "Empty tables do not take table-columns into account",
            document.querySelector("x-table:nth-of-type(2)").offsetWidth,
            50
        ],
        [
            "Empty tables do not take table-rows into account",
            document.querySelector("x-table:nth-of-type(3)").offsetHeight,
            50
        ],
    ])

    generate_tests(assert_equals, [
        [
            "Table-columns are taken into account after missing cells are generated (empty line)",
            document.querySelector("x-table:nth-of-type(4)").offsetWidth,
            200
        ],
        [
            "Table-columns are taken into account after missing cells are generated (partially empty line)",
            document.querySelector("x-table:nth-of-type(5)").offsetWidth,
            200
        ],
        [
            "Table-columns are taken into account after missing cells are generated (non-empty line)",
            document.querySelector("x-table:nth-of-type(6)").offsetWidth,
            200
        ],
    ])

</script>