summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/resize-single-axis.html
blob: 9b8487ea8ebc59745fd4d910ceb7b81dde328482 (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
<style>
    div {
        width: 50px;
        height: 50px;
        overflow: hidden;
        -webkit-box-sizing: border-box;
        border: solid;
        margin: 10px;
    }

    #both {
        resize: both;
    }

    #horizontal {
        resize: horizontal;
    }

    #vertical {
        resize: vertical;
    }
</style>

<pre id="console"></pre>
<div id="both"></div>
<div id="horizontal"></div>
<div id="vertical"></div>

<script type="text/javascript">
    function log(message)
    {
        document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
    }

    function resize(target)
    {
        var x = document.body.offsetLeft + target.offsetLeft + target.offsetWidth;
        var y = document.body.offsetTop + target.offsetTop + target.offsetHeight;
        eventSender.mouseMoveTo(x - 6, y - 6);
        eventSender.mouseDown();
        eventSender.mouseMoveTo(x + 44, y + 44);
        eventSender.mouseUp();
    }

    function assertSize(target, width, height)
    {
        var computedStyle = getComputedStyle(target);
        var actualWidth = computedStyle.width;
        var actualHeight = computedStyle.height;

        if (actualWidth === width && actualHeight === height)
            log("'" + target.id + "' resized as expected to (" + width + ", " + height + ").");
        else
            log("FAIL: '" + target.id + "' resized to (" + actualWidth + ", " + actualHeight + ") instead of (" + width + ", " + height + ").");
    }

    if (window.testRunner) {
        testRunner.dumpAsText();

        var both = document.getElementById("both");
        var horizontal = document.getElementById("horizontal");
        var vertical = document.getElementById("vertical");

        resize(both);
        resize(horizontal);
        resize(vertical);

        assertSize(both, "100px", "100px");
        assertSize(horizontal, "100px", "50px");
        assertSize(vertical, "50px", "100px");
    }
</script>