Bug 1525570 - Add a test for preventDefault on pinch zooms. r=botond
☠☠ backed out by 48b049ff10f1 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 28 Feb 2019 18:40:45 +0000
changeset 519875 ee394d0b085d8c44884284246841b98f45c884dc
parent 519874 77625f533af6a3628ad4203530dbe1b4526aceb6
child 519876 277d70b1fd3964c42bdeb73da196c4c2b036035c
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1525570
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525570 - Add a test for preventDefault on pinch zooms. r=botond Differential Revision: https://phabricator.services.mozilla.com/D21421
gfx/layers/apz/test/mochitest/helper_zoom_prevented.html
gfx/layers/apz/test/mochitest/test_group_zoom.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_zoom_prevented.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width">
+  <title>Checking prevent-default for zooming</title>
+  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <script type="application/javascript">
+
+function* testPreventDefault(testDriver, aTouchStartToCancel) {
+  var initial_resolution = getResolution();
+  ok(initial_resolution > 0,
+      "The initial_resolution is " + initial_resolution + ", which is some sane value");
+
+  // preventDefault exactly one touchstart based on the value of aTouchStartToCancel
+  var touchStartCount = 0;
+  var canceller = function(e) {
+    dump("touchstart listener hit, count: " + touchStartCount + "\n");
+    touchStartCount++;
+    if (touchStartCount == aTouchStartToCancel) {
+      dump("calling preventDefault on touchstart\n");
+      e.preventDefault();
+      document.documentElement.removeEventListener("touchstart", canceller, {passive: false});
+    }
+  };
+  document.documentElement.addEventListener("touchstart", canceller, {passive: false});
+
+  // Ensure that APZ gets updated hit-test info
+  yield waitForAllPaints(testDriver);
+
+  var zoom_in = [
+      [ { x: 125, y: 250 }, { x: 175, y: 350 } ],
+      [ { x: 120, y: 220 }, { x: 180, y: 380 } ],
+      [ { x: 115, y: 190 }, { x: 185, y: 410 } ],
+      [ { x: 110, y: 160 }, { x: 190, y: 440 } ],
+      [ { x: 105, y: 130 }, { x: 195, y: 470 } ],
+      [ { x: 100, y: 100 }, { x: 200, y: 500 } ],
+  ];
+
+  var touchIds = [0, 1];
+  yield* synthesizeNativeTouchSequences(document.body, zoom_in, null, touchIds);
+
+  // Flush state and get the resolution we're at now
+  yield waitForApzFlushedRepaints(testDriver);
+  let final_resolution = getResolution();
+  is(final_resolution, initial_resolution, "The final resolution (" + final_resolution + ") matches the initial resolution");
+}
+
+function* test(testDriver) {
+  // Register a listener that fails the test if the APZ:TransformEnd event fires,
+  // because this test shouldn't actually be triggering any transforms
+  SpecialPowers.Services.obs.addObserver(function() {
+    ok(false, "The test fired an unexpected APZ:TransformEnd");
+  }, "APZ:TransformEnd");
+
+  yield* testPreventDefault(testDriver, 1);
+  yield* testPreventDefault(testDriver, 2);
+}
+
+waitUntilApzStable()
+.then(runContinuation(test))
+.then(subtestDone);
+
+  </script>
+</head>
+<body>
+  Here is some text to stare at as the test runs. It serves no functional
+  purpose, but gives you an idea of the zoom level. It's harder to tell what
+  the zoom level is when the page is just solid white.
+</body>
+</html>
--- a/gfx/layers/apz/test/mochitest/test_group_zoom.html
+++ b/gfx/layers/apz/test/mochitest/test_group_zoom.html
@@ -27,29 +27,33 @@ var prefs = [
   // offset values.
   ["browser.chrome.dynamictoolbar", false],
   // Explicitly enable pinch-zooming, so this test can run on desktop
   // even though zooming isn't enabled by default on desktop yet.
   ["apz.allow_zooming", true],
   // Pinch-zooming currently requires meta viewport support (this requirement
   // will eventually be removed).
   ["dom.meta-viewport.enabled", true],
+  // Increase the content response timeout because some tests do preventDefault
+  // and we want to make sure APZ actually waits for them.
+  ["apz.content_response_timeout", 60000],
 ];
 
 // Increase the tap timeouts so the double-tap is still detected in case of
 // random delays during testing.
 var doubletap_prefs = [
   ...prefs,
   ["ui.click_hold_context_menus.delay", 10000],
   ["apz.max_tap_time", 10000],
 ];
 
 var subtests = [
   {"file": "helper_bug1280013.html", "prefs": prefs},
   {"file": "helper_basic_zoom.html", "prefs": prefs},
+  {"file": "helper_zoom_prevented.html", "prefs": prefs},
   {"file": "helper_zoomed_pan.html", "prefs": prefs},
   {"file": "helper_fixed_position_scroll_hittest.html", "prefs": prefs},
   {"file": "helper_basic_doubletap_zoom.html", "prefs": doubletap_prefs},
 ];
 
 if (isApzEnabled()) {
   // This has a lot of subtests, and Android emulators are slow.
   SimpleTest.requestLongerTimeout(2);