Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / css3 / device-adapt / opera / constrain-005.html
blobf7c44efb743457cca7f21f253846b2a1fc7c90fb
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title>CSS Test: @viewport constrained - min-width greater than max-width</title>
6 <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com">
7 <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure">
8 <meta name="flags" content="visual scroll dom">
9 <meta name="assert" content="If min-width is greater than max-width, min-width will overrule max-width.">
10 <script src="../../../resources/testharness.js" type="text/javascript"></script>
11 <script src="../../../resources/testharnessreport.js" type="text/javascript"></script>
12 <style type="text/css">
13 body { margin: 0; }
14 html, body, #test { width: 100%; height: 100%; }
15 #log { padding: 1em; display: none; }
16 /* Reset viewport values to initial values to ignore UA stylesheet. */
17 @viewport {
18 width: auto;
19 height: auto;
20 zoom: auto;
21 min-zoom: auto;
22 max-zoom: auto;
23 user-zoom: zoom;
24 orientation: auto;
25 resolution: auto;
27 </style>
28 <style type="text/css">
29 /* CSS for the test below. */
30 @viewport { min-width: 10000px; max-width: 200px }
31 /* Set root element font-size to something different from the initial
32 font-size to make sure 'rem' and 'em' for @viewport is based on the
33 initial font-size, not the root element font-size. */
34 html { font-size: 2rem; }
35 body { font-size: 0.5rem; }
36 </style>
37 <script type="text/javascript">
38 var test = async_test("CSS Test: @viewport constrained - min-width greater than max-width");
39 window.onload = function(){
41 var testStyleSheet = document.styleSheets.item(1);
43 /* Initialize an object to store viewport values to be used by the test
44 asserts. */
45 var viewport = new Object();
47 /* An element with the same size as the initial containing block. */
48 var testElm = document.getElementById("test");
50 if (window.testRunner) {
51 viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
52 viewport.initialWidth = 320;
53 viewport.initialHeight = 352;
55 var vpString = internals.viewportAsText(document, 1,
56 viewport.initialWidth,
57 viewport.initialHeight);
59 var match = /viewport size (.+)x(.+) scale (.+ )/.exec(vpString);
61 if (match) {
62 viewport.actualWidth = parseFloat(match[1]);
63 viewport.actualHeight = parseFloat(match[2]);
64 viewport.zoom = parseFloat(match[3]);
67 else {
68 /* Disable the stylesheet that contains the @viewport to test. */
69 testStyleSheet.disabled = true;
71 /* Retrieve the initial viewport values before applying the @viewport to
72 test. */
73 viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
74 viewport.initialWidth = testElm.offsetWidth;
75 viewport.initialHeight = testElm.offsetHeight;
77 /* Enable the stylesheet that contains the @viewport to test. */
78 testStyleSheet.disabled = false;
80 /* Retrieve the actual viewport values for the test. */
81 viewport.actualWidth = testElm.offsetWidth;
82 viewport.actualHeight = testElm.offsetHeight;
83 viewport.zoom = viewport.initialWidth / window.innerWidth;
86 /* Check viewport values. */
87 test.step(function(){
88 assert_equals(viewport.actualWidth, 10000);
89 });
91 /* Finished. Show the results. */
92 test.done();
93 testStyleSheet.disabled = true;
94 document.getElementById("log").style.display = "block";
96 </script>
97 </head>
98 <body>
99 <div id="test">
100 <div id="log"></div>
101 </div>
102 </body>
103 </html>