1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_meta_viewport4.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"> 1.8 + <title>meta viewport test</title> 1.9 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.11 + <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 1.12 + <script src="viewport_helpers.js"></script> 1.13 +</head> 1.14 +<body> 1.15 + <p>initial-scale=1.0, user-scalable=no</p> 1.16 + <script type="application/javascript;version=1.7"> 1.17 + "use strict"; 1.18 + 1.19 + SimpleTest.waitForExplicitFinish(); 1.20 + 1.21 + let tests = []; 1.22 + 1.23 + tests.push(function test1() { 1.24 + SpecialPowers.pushPrefEnv(scaleRatio(1.0), 1.25 + function() { 1.26 + let info = getViewportInfo(800, 480); 1.27 + is(info.defaultZoom, 1, "initial zoom is set explicitly"); 1.28 + is(info.width, 800, "width fits the initial zoom level"); 1.29 + is(info.height, 480, "height fits the initial zoom level"); 1.30 + is(info.autoSize, true, "initial-scale=1 enables autoSize"); 1.31 + is(info.allowZoom, false, "zooming is explicitly disabled"); 1.32 + 1.33 + info = getViewportInfo(480, 800); 1.34 + is(info.defaultZoom, 1, "initial zoom is still set explicitly"); 1.35 + is(info.width, 480, "width changes to match the displayWidth"); 1.36 + is(info.height, 800, "height changes to match the displayHeight"); 1.37 + 1.38 + nextTest(); 1.39 + }); 1.40 + }); 1.41 + 1.42 + tests.push(function test2() { 1.43 + SpecialPowers.pushPrefEnv(scaleRatio(1.5), 1.44 + function() { 1.45 + let info = getViewportInfo(800, 480); 1.46 + is(info.defaultZoom, 1.5, "initial zoom is adjusted for device pixel ratio"); 1.47 + is(info.width, 533, "width fits the initial zoom"); 1.48 + is(info.height, 320, "height fits the initial zoom"); 1.49 + 1.50 + nextTest(); 1.51 + }); 1.52 + }); 1.53 + 1.54 + function getViewportInfo(aDisplayWidth, aDisplayHeight) { 1.55 + let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {}, 1.56 + width = {}, height = {}, autoSize = {}; 1.57 + 1.58 + let cwu = SpecialPowers.getDOMWindowUtils(window); 1.59 + cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom, 1.60 + minZoom, maxZoom, width, height, autoSize); 1.61 + return { 1.62 + defaultZoom: defaultZoom.value, 1.63 + minZoom: minZoom.value, 1.64 + maxZoom: maxZoom.value, 1.65 + width: width.value, 1.66 + height: height.value, 1.67 + autoSize: autoSize.value, 1.68 + allowZoom: allowZoom.value 1.69 + }; 1.70 + } 1.71 + 1.72 + function nextTest() { 1.73 + if (tests.length) 1.74 + (tests.shift())(); 1.75 + else 1.76 + SimpleTest.finish(); 1.77 + } 1.78 + addEventListener("load", nextTest); 1.79 + </script> 1.80 +</body> 1.81 +</html>