Bug 1415225 - Add a couple of mochitests for event-regions overrides. r=botond
☠☠ backed out by 95985f660be1 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 08 Nov 2017 20:47:19 -0500
changeset 444158 27403a9dec13a8d6c37b764782db51ca81ce9436
parent 444157 9e671058653199248a401a379f787fef0ccced89
child 444159 7ae07e7920fec8d066b757acfc112746a2ab7c1c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1415225
milestone58.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 1415225 - Add a couple of mochitests for event-regions overrides. r=botond These two tests exercise the codepaths where an event regions override is set on (a) the root layer of a layer tree and (b) on an in-process subdocument. I verified that case (b) was failing with webrender enabled without the patchset and passes now. MozReview-Commit-ID: GMwk5iQstj
gfx/layers/apz/test/mochitest/helper_override_root.html
gfx/layers/apz/test/mochitest/helper_override_subdoc.html
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_group_overrides.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_override_root.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Simple wheel scroll cancellation</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">
+
+// Add a non-passive listener on the document, so that we have a document-level
+// APZ-aware listener, and the entire document is put in the dispatch-to-content
+// region
+document.addEventListener('wheel', function(e) {
+    dump("Wheel listener running...\n");
+
+    // spin for 2 seconds to give APZ time to scroll, if the event region override
+    // is broken and it decides not to wait for the main thread. Note that it's
+    // possible the APZ controller thread is busy for whatever reason so APZ
+    // may not scroll. That might cause this test to only fail intermittently
+    // instead of consistently if the behaviour being tested regresses.
+    var now = Date.now();
+    while (Date.now() - now < 2000);
+
+    // Cancel the scroll. If this works then we know APZ waited for this listener
+    // to run.
+    e.preventDefault();
+
+    setTimeout(function() {
+        flushApzRepaints(checkScroll);
+    }, 0);
+}, false);
+
+function scrollPage() {
+  synthesizeNativeWheel(document.body, 100, 100, 0, -50);
+  dump("Finished native wheel, waiting for listener to run...\n");
+}
+
+function checkScroll() {
+  is(window.scrollY, 0, "check that the window didn't scroll");
+  subtestDone();
+}
+
+if (window.top != window) {
+    dump("Running inside an iframe! stealing functions from window.top...\n");
+    window.subtestDone = window.top.subtestDone;
+    window.SimpleTest = window.top.SimpleTest;
+    window.is = window.top.is;
+    window.ok = window.top.ok;
+}
+
+waitUntilApzStable().then(scrollPage);
+
+  </script>
+</head>
+<body style="height: 5000px; background-image: linear-gradient(green,red);">
+  This page should not be wheel-scrollable.
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_override_subdoc.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Wheel scroll cancellation inside iframe</title>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+</head>
+<body>
+    This just loads helper_override_root in an iframe, so that we test event
+    regions overriding on in-process subdocuments.
+    <iframe src="helper_override_root.html"></iframe>
+</body>
+</html>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -16,16 +16,18 @@
     helper_div_pan.html
     helper_drag_click.html
     helper_drag_scroll.html
     helper_iframe_pan.html
     helper_iframe1.html
     helper_iframe2.html
     helper_key_scroll.html
     helper_long_tap.html
+    helper_override_root.html
+    helper_override_subdoc.html
     helper_scroll_inactive_perspective.html
     helper_scroll_inactive_zindex.html
     helper_scroll_on_position_fixed.html
     helper_scroll_over_scrollbar.html
     helper_scroll_tables_perspective.html
     helper_scrollto_tap.html
     helper_subframe_style.css
     helper_tall.html
@@ -67,8 +69,10 @@ skip-if = os == 'win' && os_version == '
 [test_scroll_subframe_scrollbar.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_touch_listeners_impacting_wheel.html]
   skip-if = (toolkit == 'android') || (toolkit == 'cocoa') # wheel events not supported on mobile, and synthesized wheel smooth-scrolling not supported on OS X
 [test_wheel_scroll.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_wheel_transactions.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
+[test_group_overrides.html]
+  skip-if = (os == 'android') # wheel events not supported on mobile
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/test_group_overrides.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Various tests for event regions overrides</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+var prefs = [
+  // turn off smooth scrolling so that we don't have to wait for
+  // APZ animations to finish before sampling the scroll offset
+  ['general.smoothScroll', false],
+  // Increase the content response timeout because these tests do preventDefault
+  // and we want to make sure APZ actually waits for them.
+  ['apz.content_response_timeout', 10000],
+]
+
+var subtests = [
+  {'file': 'helper_override_root.html', 'prefs': prefs},
+  {'file': 'helper_override_subdoc.html', 'prefs': prefs},
+];
+
+if (isApzEnabled()) {
+  SimpleTest.waitForExplicitFinish();
+  window.onload = function() {
+    runSubtestsSeriallyInFreshWindows(subtests)
+    .then(SimpleTest.finish);
+  };
+}
+
+  </script>
+</head>
+<body>
+</body>
+</html>