Bug 1273137 - Add a mochitest that creates a drag block on a dispatch-to-content-region. r=rbarker
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 07 Jun 2016 11:07:55 -0400
changeset 300955 1cd13955b7290dc8c287c738140cca86b81376f2
parent 300954 528945d5a054a46071fc46e3e3dbf3924409a7ef
child 300956 2bc047b037a0e143475e821429bf15333af7cbc7
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker
bugs1273137
milestone50.0a1
Bug 1273137 - Add a mochitest that creates a drag block on a dispatch-to-content-region. r=rbarker MozReview-Commit-ID: LRKyOUGvFP9
gfx/layers/apz/test/mochitest/apz_test_utils.js
gfx/layers/apz/test/mochitest/helper_click.html
gfx/layers/apz/test/mochitest/test_group_mouseevents.html
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -312,8 +312,29 @@ function getSnapshot(rect) {
   if (typeof getSnapshot.chromeHelper == 'undefined') {
     // This is the first time getSnapshot is being called; do initialization
     getSnapshot.chromeHelper = SpecialPowers.loadChromeScript(parentProcessSnapshot);
     SimpleTest.registerCleanupFunction(function() { getSnapshot.chromeHelper.destroy() });
   }
 
   return getSnapshot.chromeHelper.sendSyncMessage('snapshot', JSON.stringify(rect)).toString();
 }
+
+// Takes the document's query string and parses it, assuming the query string
+// is composed of key-value pairs where the value is in JSON format. The object
+// returned contains the various values indexed by their respective keys. In
+// case of duplicate keys, the last value be used.
+// Examples:
+//   ?key="value"&key2=false&key3=500
+//     produces { "key": "value", "key2": false, "key3": 500 }
+//   ?key={"x":0,"y":50}&key2=[1,2,true]
+//     produces { "key": { "x": 0, "y": 0 }, "key2": [1, 2, true] }
+function getQueryArgs() {
+  var args = {};
+  if (location.search.length > 0) {
+    var params = location.search.substr(1).split('&');
+    for (var p of params) {
+      var [k, v] = p.split('=');
+      args[k] = JSON.parse(v);
+    }
+  }
+  return args;
+}
--- a/gfx/layers/apz/test/mochitest/helper_click.html
+++ b/gfx/layers/apz/test/mochitest/helper_click.html
@@ -4,29 +4,38 @@
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width; initial-scale=1.0">
   <title>Sanity mouse-clicking test</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 clickButton() {
+function* clickButton(testDriver) {
   document.addEventListener('click', clicked, false);
 
+  if (getQueryArgs()['dtc']) {
+    // force a dispatch-to-content region on the document
+    document.addEventListener('wheel', function() { /* no-op */ }, { passive: false });
+    yield waitForAllPaints(function() {
+      flushApzRepaints(testDriver);
+    });
+  }
+
   synthesizeNativeClick(document.getElementById('b'), 5, 5, function() {
     dump("Finished synthesizing click, waiting for button to be clicked...\n");
   });
 }
 
 function clicked(e) {
   is(e.target, document.getElementById('b'), "Clicked on button, yay! (at " + e.clientX + "," + e.clientY + ")");
   subtestDone();
 }
 
-waitUntilApzStable().then(clickButton);
+waitUntilApzStable()
+.then(runContinuation(clickButton));
 
   </script>
 </head>
 <body>
  <button id="b" style="width: 10px; height: 10px"></button>
 </body>
 </html>
--- a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
@@ -5,17 +5,20 @@
   <title>Various mouse tests that spawn in new windows</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 subtests = [
   // Sanity test to synthesize a mouse click
-  {'file': 'helper_click.html'},
+  {'file': 'helper_click.html?dtc=false'},
+  // Same as above, but with a dispatch-to-content region that exercises the
+  // main-thread notification codepaths for mouse events
+  {'file': 'helper_click.html?dtc=true'},
   // Sanity test for click but with some mouse movement between the down and up
   {'file': 'helper_drag_click.html'}
 ];
 
 if (isApzEnabled()) {
   SimpleTest.waitForExplicitFinish();
   window.onload = function() {
     runSubtestsSeriallyInFreshWindows(subtests)