Bug 1492582 - Fix screenshot tests for htmlified browser.xhtml. r=bgrins
authorBrendan Dahl <bdahl@mozilla.com>
Fri, 08 Nov 2019 23:34:18 +0000
changeset 501421 9644ee96a51a03a8f4e50e9777fb7278f246383c
parent 501420 c2b41600ce78924d6a8b0cfd649fd8a7867ee6d1
child 501422 d967ac6c56aeec99c2fba3814c8550a1c5971384
push id100191
push userbdahl@mozilla.com
push dateSat, 09 Nov 2019 12:23:34 +0000
treeherderautoland@9644ee96a51a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1492582
milestone72.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 1492582 - Fix screenshot tests for htmlified browser.xhtml. r=bgrins The <html> element does not have screenX and screenY like XULElement. Instead use window location and element offset to calculate it. Differential Revision: https://phabricator.services.mozilla.com/D52420
browser/base/content/browser.xhtml
browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -681,18 +681,18 @@
                aria-live="off"
                flex="1"
                crop="end"/>
       </hbox>
     </hbox>
   </popupset>
   <box id="appMenu-viewCache" hidden="true"/>
 
-  <!-- Temporary wrapper until we move away from XUL flex to fix fullscreen
-       layout-->
+  <!-- Temporary wrapper until we move away from XUL flex to allow a negative
+       margin-top to slide the toolbox off screen in fullscreen layout.-->
   <box>
   <toolbox id="navigator-toolbox" flex="1">
 
     <vbox id="titlebar">
       <!-- Menu -->
       <toolbar type="menubar" id="toolbar-menubar"
                class="browser-toolbar chromeclass-menubar titlebar-color"
                customizable="true"
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
@@ -293,19 +293,22 @@ var TestRunner = {
       }
 
       if (!element) {
         throw new Error(`No element for '${selector}' found.`);
       }
 
       // Calculate box region, convert to Rect
       let elementRect = element.getBoundingClientRect();
+      // ownerGlobal doesn't exist in content privileged windows.
+      // eslint-disable-next-line mozilla/use-ownerGlobal
+      let win = element.ownerDocument.defaultView;
       let rect = new Rect(
-        element.screenX * scale,
-        element.screenY * scale,
+        (win.mozInnerScreenX + elementRect.left) * scale,
+        (win.mozInnerScreenY + elementRect.top) * scale,
         elementRect.width * scale,
         elementRect.height * scale
       );
       rect.inflateFixed(this.croppingPadding * scale);
       rect.left = Math.max(rect.left, windowLeft);
       rect.top = Math.max(rect.top, windowTop);
       rect.right = Math.min(rect.right, windowLeft + windowWidth);
       rect.bottom = Math.min(rect.bottom, windowTop + windowHeight);