summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/min-device-aspect-ratio.html
blob: 220035f9482e8cefb7b255e7a40b6556cc604f85 (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head id="myhead">
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
<script src="../js/resources/js-test-post-function.js"></script>
<script>
if (window.layoutTestController) {
    window.layoutTestController.waitUntilDone();
}

var count = 0;
var maxCount = 10;
var timeout = 100;

function doTest()
{
    var headElement = document.getElementById("myhead");
    var linkElement = document.createElement("link");
    linkElement.rel = "stylesheet";
    var width;
    var height;
    if (screen.width > screen.height) {
        // For a landscape screen, a ratio of 1/1 will always be less than the screen (e.g., 16/9)
        width = 1;
        height = 1;
    } else {
        // For a portrait screen, a ratio of 1/100 should always be less than the screen (e.g., 9/16)
        // For a square screen, a ratio of 1/100 will always be less than the screen (e.g., 9/9)
        width = 1;
        height = 100;
    }
    linkElement.media = "screen and (min-device-aspect-ratio: " + width + "/" + height + ")";
    linkElement.href = "resources/device-aspect-ratio.css";
    headElement.appendChild(linkElement);
    description("This text is green if the min-device-aspect-ratio media query works properly.");
    setTimeout("waitForStylesheetLoad()", timeout);
}

function waitForStylesheetLoad()
{
    count++;

    if (document.defaultView.getComputedStyle(document.getElementById('description'), null).color == "rgb(0, 128, 0)") {
        shouldBe("document.defaultView.getComputedStyle(document.getElementById('description'), null).color", "'rgb(0, 128, 0)'");
        window.successfullyParsed = true;
        isSuccessfullyParsed();
        if (window.layoutTestController) {
            window.layoutTestController.notifyDone();
        }
        return;
    }

    if (count > maxCount) {
        testFailed("Stylesheet did not load in " + (maxCount * timeout / 1000) + " second(s).");
        return;
    }

    setTimeout("waitForStylesheetLoad()", timeout);
}
</script>
</head>
<body onload="doTest()">
<p id="description"></p>
<div id="console"></div>
</body>
</html>