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=device-width"> |
michael@0 | 9 | <script src="viewport_helpers.js"></script> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <p>width=device-width</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.defaultZoom, 1, "initial zoom is 100%"); |
michael@0 | 25 | is(info.width, 800, "width is the same as the displayWidth"); |
michael@0 | 26 | is(info.height, 480, "height is the same as the displayHeight"); |
michael@0 | 27 | is(info.autoSize, true, "width=device-width enables autoSize"); |
michael@0 | 28 | is(info.allowZoom, true, "zooming is enabled by default"); |
michael@0 | 29 | |
michael@0 | 30 | info = getViewportInfo(900, 600); |
michael@0 | 31 | is(info.width, 900, "changing the displayWidth changes the width"); |
michael@0 | 32 | is(info.height, 600, "changing the displayHeight changes the height"); |
michael@0 | 33 | |
michael@0 | 34 | nextTest(); |
michael@0 | 35 | }); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | tests.push(function test2() { |
michael@0 | 39 | SpecialPowers.pushPrefEnv(scaleRatio(1.5), |
michael@0 | 40 | function() { |
michael@0 | 41 | let info = getViewportInfo(900, 600); |
michael@0 | 42 | is(info.defaultZoom, 1.5, "initial zoom is 150%"); |
michael@0 | 43 | is(info.width, 600, "width equals displayWidth/1.5"); |
michael@0 | 44 | is(info.height, 400, "height equals displayHeight/1.5"); |
michael@0 | 45 | |
michael@0 | 46 | nextTest(); |
michael@0 | 47 | }); |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | function getViewportInfo(aDisplayWidth, aDisplayHeight) { |
michael@0 | 51 | let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {}, |
michael@0 | 52 | width = {}, height = {}, autoSize = {}; |
michael@0 | 53 | |
michael@0 | 54 | let cwu = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 55 | cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom, |
michael@0 | 56 | minZoom, maxZoom, width, height, autoSize); |
michael@0 | 57 | return { |
michael@0 | 58 | defaultZoom: defaultZoom.value, |
michael@0 | 59 | minZoom: minZoom.value, |
michael@0 | 60 | maxZoom: maxZoom.value, |
michael@0 | 61 | width: width.value, |
michael@0 | 62 | height: height.value, |
michael@0 | 63 | autoSize: autoSize.value, |
michael@0 | 64 | allowZoom: allowZoom.value |
michael@0 | 65 | }; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function nextTest() { |
michael@0 | 69 | if (tests.length) |
michael@0 | 70 | (tests.shift())(); |
michael@0 | 71 | else |
michael@0 | 72 | SimpleTest.finish(); |
michael@0 | 73 | } |
michael@0 | 74 | addEventListener("load", nextTest); |
michael@0 | 75 | </script> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |