dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
author Nils Maier <maierman@web.de>
Wed, 28 Nov 2012 13:13:13 -0500
changeset 114378 0e5ca55005ae8ef9002ac12472740104fb79fd47
parent 59573 5ff3997a30c282edef635b58255dfaf6a1691a00
child 125725 74c06a7308d19bf5501dfcbf91f5c8093d52d1d6
permissions -rw-r--r--
Bug 719180: Part 2 - Add jar channel unit tests; r=taras

<!DOCTYPE html>
<html>
<head>
  <title>Bug 602580 - Test getting and setting innerWidth and Height after using setCSSViewport</title>
  <script class="testbody" type="text/javascript">
  function runSubTest()
  {
    // get ability to set innerWidth and height without setting a pref
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

    // Firefox doesn't support the metaviewport tag, so we force a css viewport
    // here using nsIDomWindowUtils
    var cwu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                     getInterface(Components.interfaces.nsIDOMWindowUtils);
    cwu.setCSSViewport(320, 320);

    var oldWidth = window.innerWidth;
    var oldHeight = window.innerHeight;

    /* Test that return values are now from viewport */
    window.opener.is(window.innerWidth, 320, "innerWidth is css viewport width");
    window.opener.is(window.innerHeight, 320, "innerHeight is css viewport height");

    window.innerWidth = 300;
    window.opener.is(window.innerWidth, 300, "innerWidth returns value that was set");
    window.innerWidth = oldWidth;

    window.innerHeight = 300;
    window.opener.is(window.innerHeight, 300, "innerHeight returns value that was set");
    window.innerHeight = oldHeight;

    window.opener.finish();
  }
  </script>
</head>
<body onload="runSubTest()">
</body>
</html>