Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset="utf-8"> |
michael@0 | 5 | <title>meta viewport test</title> |
michael@0 | 6 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 8 | <meta name="viewport" content="width=2000, minimum-scale=0.75"> |
michael@0 | 9 | <script src="viewport_helpers.js"></script> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <p>width=2000, minimum-scale=0.75</p> |
michael@0 | 13 | <script type="application/javascript;version=1.7"> |
michael@0 | 14 | "use strict"; |
michael@0 | 15 | |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | |
michael@0 | 18 | let tests = []; |
michael@0 | 19 | |
michael@0 | 20 | tests.push(function test1() { |
michael@0 | 21 | SpecialPowers.pushPrefEnv(scaleRatio(1.0), |
michael@0 | 22 | function() { |
michael@0 | 23 | let info = getViewportInfo(800, 480); |
michael@0 | 24 | is(info.minZoom, 0.75, "minumum scale is set explicitly"); |
michael@0 | 25 | is(info.defaultZoom, 0.75, "initial scale is bounded by the minimum scale"); |
michael@0 | 26 | is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum"); |
michael@0 | 27 | is(info.width, 2000, "width is set explicitly"); |
michael@0 | 28 | is(info.height, 1200, "height is proportional to displayHeight"); |
michael@0 | 29 | is(info.autoSize, false, "autoSize is disabled by default"); |
michael@0 | 30 | is(info.allowZoom, true, "zooming is enabled by default"); |
michael@0 | 31 | |
michael@0 | 32 | info = getViewportInfo(2000, 1000); |
michael@0 | 33 | is(info.minZoom, 0.75, "minumum scale is still set explicitly"); |
michael@0 | 34 | is(info.defaultZoom, 1, "initial scale fits the width"); |
michael@0 | 35 | is(info.width, 2000, "width is set explicitly"); |
michael@0 | 36 | is(info.height, 1000, "height is proportional to the new displayHeight"); |
michael@0 | 37 | |
michael@0 | 38 | nextTest(); |
michael@0 | 39 | }); |
michael@0 | 40 | }); |
michael@0 | 41 | |
michael@0 | 42 | tests.push(function test2() { |
michael@0 | 43 | SpecialPowers.pushPrefEnv(scaleRatio(1.5), |
michael@0 | 44 | function() { |
michael@0 | 45 | let info = getViewportInfo(800, 480); |
michael@0 | 46 | is(info.minZoom, 1.125, "minumum scale is converted to device pixel scale"); |
michael@0 | 47 | is(info.defaultZoom, 1.125, "initial scale is bounded by the minimum scale"); |
michael@0 | 48 | is(info.maxZoom, 15, "maximum scale defaults to the absolute maximum"); |
michael@0 | 49 | is(info.width, 2000, "width is still set explicitly"); |
michael@0 | 50 | is(info.height, 1200, "height is still proportional to displayHeight"); |
michael@0 | 51 | |
michael@0 | 52 | nextTest(); |
michael@0 | 53 | }); |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | function getViewportInfo(aDisplayWidth, aDisplayHeight) { |
michael@0 | 57 | let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {}, |
michael@0 | 58 | width = {}, height = {}, autoSize = {}; |
michael@0 | 59 | |
michael@0 | 60 | let cwu = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 61 | cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom, |
michael@0 | 62 | minZoom, maxZoom, width, height, autoSize); |
michael@0 | 63 | return { |
michael@0 | 64 | defaultZoom: defaultZoom.value, |
michael@0 | 65 | minZoom: minZoom.value, |
michael@0 | 66 | maxZoom: maxZoom.value, |
michael@0 | 67 | width: width.value, |
michael@0 | 68 | height: height.value, |
michael@0 | 69 | autoSize: autoSize.value, |
michael@0 | 70 | allowZoom: allowZoom.value |
michael@0 | 71 | }; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | function nextTest() { |
michael@0 | 75 | if (tests.length) |
michael@0 | 76 | (tests.shift())(); |
michael@0 | 77 | else |
michael@0 | 78 | SimpleTest.finish(); |
michael@0 | 79 | } |
michael@0 | 80 | addEventListener("load", nextTest); |
michael@0 | 81 | </script> |
michael@0 | 82 | </body> |
michael@0 | 83 | </html> |