test_meta_viewport3.html (1635B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>meta viewport test</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 <meta name="viewport" content="width=320"> 9 <script src="viewport_helpers.js"></script> 10 </head> 11 <body> 12 <p>width=320</p> 13 <script type="application/javascript"> 14 "use strict"; 15 16 add_task(async function test1() { 17 await SpecialPowers.pushPrefEnv(scaleRatio(1.0)); 18 19 let info = getViewportInfo(800, 80); 20 is(info.defaultZoom, 2.5, "initial zoom fits the displayWidth"); 21 is(info.width, 320, "width is set explicitly"); 22 is(info.height, 40, "height is at the absolute minimum"); 23 is(info.autoSize, false, "width=device-width enables autoSize"); 24 is(info.allowZoom, true, "zooming is enabled by default"); 25 26 info = getViewportInfo(480, 800); 27 is(info.defaultZoom, 1.5, "initial zoom fits the new displayWidth"); 28 is(info.width, 320, "explicit width is unchanged"); 29 is(info.height, 533, "height changes proportional to displayHeight"); 30 }); 31 32 add_task(async function test2() { 33 await SpecialPowers.pushPrefEnv(scaleRatio(1.5)); 34 35 // With an explicit width in CSS px, the scaleRatio has no effect. 36 let info = getViewportInfo(800, 80); 37 is(info.defaultZoom, 2.5, "initial zoom still fits the displayWidth"); 38 is(info.width, 320, "width is still set explicitly"); 39 is(info.height, 40, "height is still minimum height"); 40 }); 41 </script> 42 </body> 43 </html>