Bug 1465616 - Add a mochitest for fixed position hit-testing. r=botond draft
authorKashav Madan <kshvmdn@gmail.com>
Wed, 04 Jul 2018 16:17:31 -0400
changeset 830110 ff297bc935576a9fa7f4ee3a9f23803d96d74046
parent 830109 84137acdf43c38ad91ccbac36ae2c034cd6dfb61
child 830111 24023dd4bbb020e0ee71599a4f81a37a1642d80b
push id118813
push userbmo:kshvmdn@gmail.com
push dateSun, 19 Aug 2018 00:42:00 +0000
reviewersbotond
bugs1465616
milestone63.0a1
Bug 1465616 - Add a mochitest for fixed position hit-testing. r=botond MozReview-Commit-ID: IC82JZoVgPs
gfx/layers/apz/test/mochitest/helper_fixed_position_scroll_hittest.html
gfx/layers/apz/test/mochitest/test_group_zoom.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_fixed_position_scroll_hittest.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=2.0">
+  <title>Hittest position:fixed zoomed scroll</title>
+  <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;
+    }
+    #fixed {
+      position: fixed;
+      height: 30px;
+      width: 100%;
+      background: linear-gradient(135deg, white, black);
+    }
+    #fixed > input {
+      position: absolute;
+      top: 0;
+      right: 0;
+      height: 100%;
+    }
+  </style>
+</head>
+<body>
+  <div id="fixed"><input type="button" value="Button" /></div>
+  <script>
+    const input = document.querySelector("input");
+    function* test(testDriver) {
+      SpecialPowers.Services.obs.addObserver(testDriver, "APZ:TransformEnd");
+      yield synthesizeNativeTouchDrag(document.body, 10, 10, -2000, 0);
+      SpecialPowers.Services.obs.removeObserver(testDriver, "APZ:TransformEnd", false);
+
+      yield waitForApzFlushedRepaints(testDriver);
+
+      // TODO: We're unsure why, but adding this observer substantially
+      // decreases the rate of intermittents that we see. We should figure out
+      // why and/or rewrite this test entirely.
+      SpecialPowers.Services.obs.addObserver(testDriver, "mouseevent");
+      yield synthesizeNativeClick(input, 0, 0, testDriver);
+      SpecialPowers.Services.obs.removeObserver(testDriver, "mouseevent", false);
+    }
+    window.addEventListener("click", (e) => {
+      is(e.target, input, "got click");
+      subtestDone();
+    });
+    waitUntilApzStable().then(runContinuation(test));
+  </script>
+</body>
+</html>
+
--- a/gfx/layers/apz/test/mochitest/test_group_zoom.html
+++ b/gfx/layers/apz/test/mochitest/test_group_zoom.html
@@ -35,16 +35,17 @@ var doubletap_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_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);
   SimpleTest.waitForExplicitFinish();
   window.onload = function() {