Bug 1574221: Hack around tests that sometimes try to snapshot 0 width/height rects. r=mccr8
authorKris Maglione <maglione.k@gmail.com>
Thu, 15 Aug 2019 21:34:29 +0000
changeset 488359 0dce79612a6d823e56c09724b9c02f1420cb50d3
parent 488358 476c9068a66937becf5950a0eb4829e981d6a723
child 488360 2fce06fd642bada80669049de12f9b15924c979b
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1574221
milestone70.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 1574221: Hack around tests that sometimes try to snapshot 0 width/height rects. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D42166
testing/specialpowers/content/SpecialPowersAPI.jsm
--- a/testing/specialpowers/content/SpecialPowersAPI.jsm
+++ b/testing/specialpowers/content/SpecialPowersAPI.jsm
@@ -1197,23 +1197,31 @@ class SpecialPowersAPI extends JSWindowA
     let toCanvas = imageData => {
       let el = this.document.createElementNS(
         "http://www.w3.org/1999/xhtml",
         "canvas"
       );
       el.width = imageData.width;
       el.height = imageData.height;
 
-      let ctx = el.getContext("2d");
-      ctx.putImageData(imageData, 0, 0);
+      if (ImageData.isInstance(imageData)) {
+        let ctx = el.getContext("2d");
+        ctx.putImageData(imageData, 0, 0);
+      }
 
       return el;
     };
 
     if (Window.isInstance(content)) {
+      // Hack around tests that try to snapshot 0 width or height
+      // elements.
+      if (rect && !(rect.width && rect.height)) {
+        return toCanvas(rect);
+      }
+
       // This is an in-process window. Snapshot it synchronously.
       return toCanvas(getImageData(rect, bgcolor, options));
     }
 
     // This is a remote window or frame. Snapshot it asynchronously and
     // return a promise for the result. Alas, consumers expect us to
     // return a <canvas> element rather than an ImageData object, so we
     // need to convert the result from the remote snapshot to a local