Bug 1467918 - Fix APZ utils to work with GeckoView r=botond draft
authorJames Willcox <snorp@snorp.net>
Fri, 01 Jun 2018 11:14:37 -0500
changeset 806115 37b2e28ea7c3738e2733e2af91e672e78b645f7f
parent 806114 028db303e4024092ad336a8627f696a0d0e6ad25
child 806116 aa3c8d4205188979f940c9104728328b3e30ad50
push id112841
push userbmo:snorp@snorp.net
push dateFri, 08 Jun 2018 22:03:31 +0000
reviewersbotond
bugs1467918
milestone62.0a1
Bug 1467918 - Fix APZ utils to work with GeckoView r=botond MozReview-Commit-ID: 9fKAgqnigGw
gfx/layers/apz/test/mochitest/apz_test_utils.js
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -289,17 +289,20 @@ async function waitUntilApzStable() {
     // the parent-process layer tree in the compositor has the appropriate
     // RefLayer pointing to the content-process layer tree.
 
     // Sadly this helper function cannot reuse any code from other places because
     // it must be totally self-contained to be shipped over to the parent process.
     function parentProcessFlush() {
       addMessageListener("apz-flush", function() {
         ChromeUtils.import("resource://gre/modules/Services.jsm");
-        var topWin = Services.wm.getMostRecentWindow("navigator:browser");
+        var topWin = Services.wm.getMostRecentWindow('navigator:browser');
+        if (!topWin) {
+          topWin = Services.wm.getMostRecentWindow('navigator:geckoview');
+        }
         var topUtils = topWin.QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIDOMWindowUtils);
 
         var repaintDone = function() {
           Services.obs.removeObserver(repaintDone, "apz-repaints-flushed");
           // send message back to content process
           sendAsyncMessage("apz-flush-done", null);
         };
@@ -427,16 +430,19 @@ function runContinuation(testFunction) {
 // the snapshot. If the rect extends outside the browser window then the
 // results are undefined.
 // The snapshot is returned in the form of a data URL.
 function getSnapshot(rect) {
   function parentProcessSnapshot() {
     addMessageListener('snapshot', function(rect) {
       ChromeUtils.import('resource://gre/modules/Services.jsm');
       var topWin = Services.wm.getMostRecentWindow('navigator:browser');
+      if (!topWin) {
+        topWin = Services.wm.getMostRecentWindow('navigator:geckoview');
+      }
 
       // reposition the rect relative to the top-level browser window
       rect = JSON.parse(rect);
       rect.x -= topWin.mozInnerScreenX;
       rect.y -= topWin.mozInnerScreenY;
 
       // take the snapshot
       var canvas = topWin.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");