Index: LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html |
diff --git a/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html b/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c37c5ac3b3966f38b1ae82a31ed73ccd8fa7ce29 |
--- /dev/null |
+++ b/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html |
@@ -0,0 +1,144 @@ |
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
+<script src="../../../resources/js-test.js"></script> |
+<style> |
+ body { |
+ padding: 0px; |
+ margin: 0px; |
+ } |
+ |
+ .spacer { |
+ position: absolute; |
+ left: 0px; |
+ top: 0px; |
+ margin: 0px; |
+ padding: 0px; |
+ width: 2000px; |
+ height: 1500px; |
+ } |
+</style> |
+<script language="JavaScript" type="text/javascript"> |
+ if (window.testRunner && window.eventSender) { |
+ window.eventSender.setPageScaleFactorLimits(0.5, 4.0); |
bokan
2014/11/18 23:21:51
I changed the min scale factor to 0.5 so that ther
Rick Byers
2014/11/20 19:23:31
SGTM
|
+ window.jsTestIsAsync = true; |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+ } |
+ |
+ description("This test makes sure the window properties related to the\ |
+ viewport remain correct under pinch-to-zoom."); |
+ |
+ debug('===Unscaled==='); |
+ debug(''); |
+ shouldBe('window.innerWidth', '800'); |
+ shouldBe('window.innerHeight', '600'); |
+ |
+ function testPinchedIn() { |
+ debug(''); |
+ debug('===Pinch Zoom in to 2X==='); |
+ debug(''); |
+ window.eventSender.setPageScaleFactor(2.0, 0, 0); |
+ shouldBe('window.innerWidth', '400'); |
+ shouldBe('window.innerHeight', '300'); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ |
+ window.scrollBy(10, 20); |
+ shouldBe('window.scrollX', '10'); |
+ shouldBe('window.scrollY', '20'); |
+ window.scrollBy(1590, 1180); |
+ shouldBe('window.scrollX', '1600'); |
+ shouldBe('window.scrollY', '1200'); |
+ window.scrollBy(-1600, -1200); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ window.scrollTo(1600, 1200); |
+ shouldBe('window.scrollX', '1600'); |
+ shouldBe('window.scrollY', '1200'); |
+ window.scrollTo(0, 0); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ } |
+ |
+ function testMaximallyPinchedOut() { |
+ debug(''); |
+ debug('===Pinch Out to 0.5X==='); |
+ debug(''); |
+ window.eventSender.setPageScaleFactor(0.5, 0, 0); |
+ shouldBe('window.innerWidth', '1600'); |
+ shouldBe('window.innerHeight', '1200'); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ |
+ window.scrollBy(10, 20); |
+ shouldBe('window.scrollX', '10'); |
+ shouldBe('window.scrollY', '20'); |
+ window.scrollBy(390, 280); |
+ shouldBe('window.scrollX', '400'); |
+ shouldBe('window.scrollY', '300'); |
+ window.scrollBy(-400, -300); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ window.scrollTo(400, 300); |
+ shouldBe('window.scrollX', '400'); |
+ shouldBe('window.scrollY', '300'); |
+ window.scrollTo(0, 0); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ } |
+ |
+ function testOnScroll() { |
+ debug(''); |
+ debug('===Test OnScroll==='); |
+ debug(''); |
+ window.eventSender.setPageScaleFactor(1.0, 0, 0); |
+ shouldBe('window.innerWidth', '800'); |
+ shouldBe('window.innerHeight', '600'); |
+ shouldBe('window.scrollX', '0'); |
+ shouldBe('window.scrollY', '0'); |
+ |
+ // First scroll scrolls only the outer viewport. |
+ // Second scrolls the outer and the inner. |
+ // Third scrolls only the inner. |
+ var scrolls = [100, 400, 100]; |
+ var scrollsReceived = 0; |
+ |
+ document.onscroll = function() { |
+ ++scrollsReceived; |
+ debug('PASS OnScroll called for scroll #' + scrollsReceived); |
+ if (scrollsReceived < scrolls.length) { |
+ var scrollAmount = scrolls[scrollsReceived]; |
+ window.scrollBy(scrollAmount, 0); |
+ } else if (scrollsReceived == scrolls.length) { |
+ window.scrollTo(1200, 0); |
+ } else { |
+ debug(''); |
+ finishJSTest(); |
+ } |
+ } |
+ |
+ window.scrollBy(scrolls[0], 0); |
+ |
+ // Each onscroll should be dispatched in adjacent frames so 4*16ms. Wait a little longer in case |
+ // we miss a frame or two but anything more and assume the scroll event wasn't fired. |
+ setTimeout(function() { |
+ testFailed("Failed to receive scroll event #" + (scrollsReceived+1)); |
+ finishJSTest(); |
+ }, 200); |
+ } |
+ |
+ function forceLayout() { |
+ window.scrollTo(0, 0); |
+ } |
+ |
+ function runTests() { |
+ if (window.testRunner && window.eventSender) { |
+ forceLayout(); |
+ testPinchedIn(); |
+ testMaximallyPinchedOut(); |
+ testOnScroll(); |
+ } |
+ } |
+ |
+ onload = runTests; |
+</script> |
+<div class="spacer"></div> |