summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/nested-percent-height-on-replaced.html
blob: 3517b4b49cd670d69c80e5fcc9957f82cca698b1 (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
<!DOCTYPE html>
<script src="../../resources/check-layout.js"></script>
<body>

<div style="overflow: scroll; height: 200px; width: 400px; background-color: salmon">
    <div style="overflow: scroll; height: 100%; background-color: purple">
        <div style="overflow: scroll; height: 100%; background-color: purple">
            <div style="border: 0; height: 100%; width: 100%; background-color: orange"></div>
        </div>
    </div>
</div>

<div style="overflow: scroll; height: 200px; width: 400px; background-color: salmon">
    <div style="overflow: scroll; height: 100%; background-color: purple">
        <div style="overflow: scroll; height: 100%; background-color: purple;line-height: 0">
            <iframe style="border: 0; height: 100%; width: 100%; background-color: orange"></iframe>
        </div>
    </div>
</div>

<script>
var dummy = document.createElement('div');
dummy.style.overflow = "scroll";
document.body.appendChild(dummy);
var scrollbarWidth = dummy.offsetWidth - dummy.clientWidth;
document.body.removeChild(dummy);

function setExpected(node, width, height)
{
    node.setAttribute('data-expected-width', width);
    node.setAttribute('data-expected-height', height);
}

var containers = document.querySelectorAll('body > div');
for (var i = 0; i < containers.length; i++) {
    var width = containers[i].offsetWidth;
    var height = containers[i].offsetHeight;

    width -= scrollbarWidth;
    height -= scrollbarWidth;
    var first = containers[i].querySelector('div');
    setExpected(first, width, height);

    width -= scrollbarWidth;
    height -= scrollbarWidth;
    var second = first.querySelector('div');
    setExpected(second, width, height);

    width -= scrollbarWidth;
    height -= scrollbarWidth;
    var third = second.querySelector('*');
    setExpected(third, width, height);
}

checkLayout('body > div')
</script>

</body>