Bug 1423011 - Part 3: Add mochitests. r?botond draft
authorKashav Madan <kmadan@mozilla.com>
Thu, 07 Jun 2018 17:16:12 -0400
changeset 805967 4cb14f8ae2688a31e8485b3e03030090b0c7030d
parent 805481 ede9c944925dc348f208ca704771764eea3e0e66
child 807304 d99f673c5d5a3959c44e23839e1841a2d7eb53bc
push id112831
push userbmo:kmadan@mozilla.com
push dateFri, 08 Jun 2018 21:01:57 +0000
reviewersbotond
bugs1423011
milestone62.0a1
Bug 1423011 - Part 3: Add mochitests. r?botond MozReview-Commit-ID: Cb1kDLaM1RJ
gfx/layers/apz/test/mochitest/helper_pinched_pan.html
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_group_touchevents.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_pinched_pan.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1">
+  <title>Ensure layout viewport responds to panning while pinched</title>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <style>
+  body {
+    margin: 0;
+    padding: 0;
+  }
+  #content {
+    height: 5000px;
+    width: 5000px;
+    background: repeating-linear-gradient(#EEE, #EEE 100px, #DDD 100px, #DDD 200px);
+  }
+  </style>
+  <script type="application/javascript">
+    var utils = SpecialPowers.getDOMWindowUtils(window);
+    utils.setResolutionAndScaleTo(1);
+    var layout = {height: window.innerHeight, width: window.innerWidth};
+    utils.setResolutionAndScaleTo(2);
+
+    function getScrollbarSize() {
+      var scrollbar = {height: {}, width: {}};
+      utils.getScrollbarSize(true, scrollbar.height, scrollbar.width);
+      return {height: scrollbar.height.value, width: scrollbar.width.value};
+    }
+
+    function* test(testDriver) {
+      var target = document.getElementById('content');
+      var scrollbar = getScrollbarSize();
+
+      // Pan horizontally to exceed the right boundary by 50 pixels.
+      yield synthesizeNativeTouchDrag(target, 0, 0,
+          -(layout.width - scrollbar.width + TOUCH_SLOP + 50), 0, testDriver);
+      yield flushApzRepaints(testDriver);
+      is(window.scrollX, 25, "main thread offset-x changed");
+      is(window.scrollY, 0, "main-thread offset-y didn't change");
+
+      // Pan vertically to exceed the bottom boundary by 50 pixels.
+      yield synthesizeNativeTouchDrag(target, 25, 0, 0,
+          -(layout.height - scrollbar.height + TOUCH_SLOP + 50), testDriver);
+      yield flushApzRepaints(testDriver);
+      is(window.scrollX, 25, "main thread offset-x didn't change");
+      is(window.scrollY, 25, "main thread offset-y changed");
+    }
+
+    waitUntilApzStable()
+    .then(runContinuation(test))
+    .then(subtestDone);
+  </script>
+</head>
+<body>
+  <div id="content"></div>
+</body>
+</html>
+
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -44,16 +44,17 @@
     helper_tall.html
     helper_tap.html
     helper_tap_default_passive.html
     helper_tap_fullzoom.html
     helper_tap_passive.html
     helper_touch_action.html
     helper_touch_action_regions.html
     helper_touch_action_complex.html
+    helper_pinched_pan.html
   tags = apz
 [test_bug982141.html]
   skip-if = webrender # bug 1424752
 [test_bug1151663.html]
 [test_bug1151667.html]
   skip-if = (os == 'android') || webrender # wheel events not supported on mobile, bug 1424752 for webrender
 [test_bug1253683.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
--- a/gfx/layers/apz/test/mochitest/test_group_touchevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_touchevents.html
@@ -32,16 +32,19 @@ var basic_pan_prefs = [
 ];
 
 var touch_action_prefs = basic_pan_prefs.slice(); // make a copy
 touch_action_prefs.push(["layout.css.touch_action.enabled", true]);
 
 var isWindows = (getPlatform() == "windows");
 touch_action_prefs.push(["apz.test.fails_with_native_injection", isWindows]);
 
+var pan_action_prefs = basic_pan_prefs.slice();
+pan_action_prefs.push(["apz.allow_zooming", true], ["dom.meta-viewport.enabled", true])
+
 var subtests = [
   // Simple tests to exercise basic panning behaviour
   {'file': 'helper_basic_pan.html', 'prefs': basic_pan_prefs},
   {'file': 'helper_div_pan.html', 'prefs': basic_pan_prefs},
   {'file': 'helper_iframe_pan.html', 'prefs': basic_pan_prefs},
 
   // Simple test to exercise touch-tapping behaviour
   {'file': 'helper_tap.html'},
@@ -81,16 +84,20 @@ var subtests = [
 
   // Simple test to exercise touch-action CSS property
   {'file': 'helper_touch_action.html', 'prefs': touch_action_prefs},
   // More complex touch-action tests, with overlapping regions and such
   {'file': 'helper_touch_action_complex.html', 'prefs': touch_action_prefs},
   // Tests that touch-action CSS properties are handled in APZ without waiting
   // on the main-thread, when possible
   {'file': 'helper_touch_action_regions.html', 'prefs': touch_action_prefs},
+
+  // Tests that pan while we're pinched in and check that the main thread
+  // receives layout viewport changes from APZ.
+  {'file': 'helper_pinched_pan.html', 'prefs': pan_action_prefs},
 ];
 
 if (isApzEnabled()) {
   ok(window.TouchEvent, "Check if TouchEvent is supported (it should be, the test harness forces it on everywhere)");
   if (getPlatform() == "android") {
     // This has a lot of subtests, and Android emulators are slow.
     SimpleTest.requestLongerTimeout(2);
   }