Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | <script src="viewport_helpers.js"></script> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <p>No <meta name="viewport"> tag</p> |
michael@0 | 12 | <script type="application/javascript;version=1.7"> |
michael@0 | 13 | "use strict"; |
michael@0 | 14 | |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | |
michael@0 | 17 | let tests = []; |
michael@0 | 18 | |
michael@0 | 19 | tests.push(function test1() { |
michael@0 | 20 | SpecialPowers.pushPrefEnv(scaleRatio(1.0), |
michael@0 | 21 | function() { |
michael@0 | 22 | let info = getViewportInfo(800, 480); |
michael@0 | 23 | is(info.defaultZoom, 0, "initial scale is unspecified"); |
michael@0 | 24 | is(info.minZoom, 0, "minumum scale defaults to the absolute minumum"); |
michael@0 | 25 | is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum"); |
michael@0 | 26 | is(info.width, 980, "width is the default width"); |
michael@0 | 27 | is(info.height, 588, "height is proportional to displayHeight"); |
michael@0 | 28 | is(info.autoSize, false, "autoSize is disabled by default"); |
michael@0 | 29 | is(info.allowZoom, true, "zooming is enabled by default"); |
michael@0 | 30 | |
michael@0 | 31 | info = getViewportInfo(490, 600); |
michael@0 | 32 | is(info.width, 980, "width is still the default width"); |
michael@0 | 33 | is(info.height, 1200, "height is proportional to the new displayHeight"); |
michael@0 | 34 | |
michael@0 | 35 | nextTest(); |
michael@0 | 36 | }); |
michael@0 | 37 | }); |
michael@0 | 38 | |
michael@0 | 39 | tests.push(function test2() { |
michael@0 | 40 | SpecialPowers.pushPrefEnv(scaleRatio(1.5), |
michael@0 | 41 | function() { |
michael@0 | 42 | let info = getViewportInfo(800, 480); |
michael@0 | 43 | is(info.width, 980, "width is still the default width"); |
michael@0 | 44 | is(info.height, 588, "height is still proportional to displayHeight"); |
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> |