Bug 602580 - Return CSSViewport from innerWidth and innerHeight (tests). r=tn, a=blocking-fennec
authorWes Johnston <wjohnston@mozilla.com>
Tue, 21 Dec 2010 14:36:08 -0800
changeset 59573 5ff3997a30c282edef635b58255dfaf6a1691a00
parent 59572 db27d37d7879a942db12401a8dea37fe145c1b1f
child 59574 a2a3a6e8b0e0e1351ed92658583aa3c7ed1e441f
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerstn, blocking-fennec
bugs602580
milestone2.0b9pre
Bug 602580 - Return CSSViewport from innerWidth and innerHeight (tests). r=tn, a=blocking-fennec
dom/tests/mochitest/dom-level0/Makefile.in
dom/tests/mochitest/dom-level0/innerWidthHeight_metaviewport.html
dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
dom/tests/mochitest/dom-level0/test_innerWidthHeight_metaviewport.html
dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html
--- a/dom/tests/mochitest/dom-level0/Makefile.in
+++ b/dom/tests/mochitest/dom-level0/Makefile.in
@@ -48,12 +48,21 @@ include $(topsrcdir)/config/rules.mk
 		test_crossdomainprops.html \
 		file_crossdomainprops_inner.html \
 		test_setting_document.domain_to_shortened_ipaddr.html \
 		child_ip_address.html \
 		test_setting_document.domain_idn.html \
 		idn_child.html \
 		file_location.html \
 		test_location.html \
+		test_innerWidthHeight_script.html \
+		innerWidthHeight_script.html \
 		$(NULL)
 
+ifeq (mobile,$(MOZ_BUILD_APP))
+_TEST_FILES += \
+		test_innerWidthHeight_metaviewport.html \
+		innerWidthHeight_metaviewport.html \
+		$(NULL)
+endif
+
 libs:: 	$(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/innerWidthHeight_metaviewport.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta name="viewport" content="width=320; height=320; user-scalable=false"/>
+  <title>Bug 602580 - Test getting and setting innerWidth and Height with a CSSViewport</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");
+
+    /* 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.opener.finish();
+  }
+  </script>
+</head>
+<body onload="runSubTest()">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
@@ -0,0 +1,38 @@
+<!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>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_innerWidthHeight_metaviewport.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Bug 602580 - Test getting and setting innerWidth and Height with a CSSViewport</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <!--
+    This acts funny when run in the normal content frame
+    so instead We load it in a separate window.
+  -->
+</head>
+<body onload="runTest()">
+  <script class="testbody" type="text/javascript">
+  SimpleTest.waitForExplicitFinish();
+  var newWin = null;
+  function runTest() {
+     newWin = window.open("innerWidthHeight_metaviewport.html", '_new', 'width=600,height=400');
+  }
+
+  function finish() {
+    newWin.close();
+    SimpleTest.finish();
+  }
+  </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Bug 602580 - Test getting and setting innerWidth and Height after using setCSSViewport</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <!--
+    This acts funny when run in the normal content frame
+    so instead We load it in a separate window.
+  -->
+</head>
+<body onload="runTest()">
+  <script class="testbody" type="text/javascript">
+  SimpleTest.waitForExplicitFinish();
+  var newWin = null;
+  function runTest() {
+     newWin = window.open("innerWidthHeight_script.html", '_new', 'width=600,height=400');
+  }
+
+  function finish() {
+    newWin.close();
+    SimpleTest.finish();
+  }
+  </script>
+</body>
+</html>