content/html/document/test/test_viewport.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/test/test_viewport.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=436083
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    1.11 +  <meta name="viewport" content="height=398, width=4224, minimum-scale=0.1,
    1.12 +  initial-scale=2.3, maximum-scale=45.2, user-scalable=no">
    1.13 +  <title>Test for Viewport META Tag Parsing</title>
    1.14 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.15 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.16 +</head>
    1.17 +<body>
    1.18 +<a target="_blank"
    1.19 +href="https://bugzilla.mozilla.org/show_bug.cgi?id=436083">Mozilla Bug 436083</a>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +/** Test for Viewport META Tag **/
    1.24 +
    1.25 +SimpleTest.waitForExplicitFinish();
    1.26 +
    1.27 +function testViewport() {
    1.28 +
    1.29 +  /* We need to access the document headers, which are chrome-only. */
    1.30 +
    1.31 +  /* Grab Viewport Metadata from the document header. */
    1.32 +  var windowUtils = SpecialPowers.getDOMWindowUtils(window);
    1.33 +  var vpWidth =
    1.34 +    parseInt(windowUtils.getDocumentMetadata("viewport-width"));
    1.35 +  var vpHeight =
    1.36 +    parseInt(windowUtils.getDocumentMetadata("viewport-height"));
    1.37 +  var vpInitialScale = 
    1.38 +    parseFloat(windowUtils.getDocumentMetadata("viewport-initial-scale"));
    1.39 +  var vpMaxScale = 
    1.40 +    parseFloat(windowUtils.getDocumentMetadata("viewport-maximum-scale"));
    1.41 +  var vpMinScale = 
    1.42 +    parseFloat(windowUtils.getDocumentMetadata("viewport-minimum-scale"));
    1.43 +  var vpUserScalable = 
    1.44 +    windowUtils.getDocumentMetadata("viewport-user-scalable");
    1.45 +
    1.46 +  is(vpWidth, 4224, "Should get proper width");
    1.47 +  is(vpHeight, 398, "Should get proper height");
    1.48 +  is(vpInitialScale, 2.3, "Should get proper initial scale");
    1.49 +  is(vpMaxScale, 45.2, "Should get proper max scale");
    1.50 +  is(vpMinScale, 0.1, "Should get proper min scale");
    1.51 +  is(vpUserScalable, "no", "Should get proper user scalable parameter");
    1.52 +}
    1.53 +
    1.54 +addLoadEvent(testViewport);
    1.55 +addLoadEvent(SimpleTest.finish);
    1.56 +
    1.57 +</script>
    1.58 +</pre>
    1.59 +</body>
    1.60 +</html>

mercurial