Backed out 4 changesets (bug 1570147) for causing failures in test_drawSnapshot.html
authorMihai Alexandru Michis <malexandru@mozilla.com>
Thu, 15 Aug 2019 11:25:58 +0300
changeset 488197 1f3fcdc28dfddb3b0afdd53cbf2c65394332d0da
parent 488196 9a51c0c9a0f7b16b0fbaa675300e8b4b29add727
child 488198 c1683d4d191a40572b799947933b65aa94384209
push id36437
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:33:18 +0000
treeherdermozilla-central@44aac6fc3352 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1570147
milestone70.0a1
backs outb5d442a2f457cc5f9879224879be1775769944e8
7a24b90275194ce426881b0075c2ea0cd85d9c47
4d528be8bae4048f06fb4c2333a6e852146f25d0
4b4feec0a4e28887f61a53ec5e5d423db2cfb251
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
Backed out 4 changesets (bug 1570147) for causing failures in test_drawSnapshot.html Backed out changeset b5d442a2f457 (bug 1570147) Backed out changeset 7a24b9027519 (bug 1570147) Backed out changeset 4d528be8bae4 (bug 1570147) Backed out changeset 4b4feec0a4e2 (bug 1570147)
dom/canvas/test/chrome/test_drawWindow_widget_layers.html
dom/canvas/test/file_drawWindow_common.js
dom/canvas/test/mochitest.ini
dom/canvas/test/test_drawSnapshot.html
dom/canvas/test/test_drawWindow.html
testing/specialpowers/content/SpecialPowersAPI.jsm
testing/specialpowers/content/SpecialPowersAPIParent.jsm
--- a/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
+++ b/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
@@ -29,26 +29,22 @@
 
     // Need to open as a toplevel chrome window so that
     // DRAWWINDOW_USE_WIDGET_LAYERS is honored.
     sourceWindow = window.open("file_drawWindow_source.html", "",
                                `chrome,width=${WINDOW_INNER_WIDTH},height=${WINDOW_INNER_HEIGHT}`);
     SimpleTest.waitForFocus(runTests, sourceWindow);
   }
 
-  async function runTests() {
+  function runTests() {
     var cxInterfaceWrap = SpecialPowers.wrap(CanvasRenderingContext2D);
-    
-    let snapshot = function(context, x, y, width, height, bg) {
-      var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
-                  cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
-                  cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
-      context.drawWindow(sourceWindow, x, y, width, height, bg, flags);
-    }
-    await runDrawWindowTests(snapshot, true);
+    var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
+                cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
+                cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
+    runDrawWindowTests(sourceWindow, flags, true);
 
     sourceWindow.close();
 
     SimpleTest.finish();
   }
 
   </script>
 </head>
--- a/dom/canvas/test/file_drawWindow_common.js
+++ b/dom/canvas/test/file_drawWindow_common.js
@@ -1,12 +1,12 @@
 const CANVAS_WIDTH = 200;
 const CANVAS_HEIGHT = 100;
 
-async function runDrawWindowTests(snapshotCallback, transparentBackground) {
+function runDrawWindowTests(win, drawWindowFlags, transparentBackground) {
   function make_canvas() {
     var canvas = document.createElement("canvas");
     canvas.setAttribute("height", CANVAS_HEIGHT);
     canvas.setAttribute("width", CANVAS_WIDTH);
     document.body.appendChild(canvas);
     return canvas;
   }
 
@@ -32,23 +32,24 @@ async function runDrawWindowTests(snapsh
   function clear(fillStyle) {
     clearRef(fillStyle);
     clearTest(fillStyle);
   }
 
   // Basic tests of drawing the whole document on a background
 
   clear("white");
-  await snapshotCallback(
-    testWrapCx,
+  testWrapCx.drawWindow(
+    win,
     0,
     0,
     CANVAS_WIDTH,
     CANVAS_HEIGHT,
-    "rgb(255, 255, 255)"
+    "rgb(255, 255, 255)",
+    drawWindowFlags
   );
   refCx.fillStyle = "fuchsia";
   refCx.fillRect(10, 10, 20, 20);
   refCx.fillStyle = "aqua";
   refCx.fillRect(50, 10, 20, 20);
   refCx.fillStyle = "yellow";
   refCx.fillRect(90, 10, 20, 20);
   assertSnapshots(
@@ -56,23 +57,24 @@ async function runDrawWindowTests(snapsh
     refCanvas,
     true /* equal */,
     null /*no fuzz*/,
     "full draw of source on white background",
     "reference"
   );
 
   clearTest("white");
-  await snapshotCallback(
-    testWrapCx,
+  testWrapCx.drawWindow(
+    win,
     0,
     0,
     CANVAS_WIDTH,
     CANVAS_HEIGHT,
-    "rgb(255, 255, 0)"
+    "rgb(255, 255, 0)",
+    drawWindowFlags
   );
   assertSnapshots(
     testCanvas,
     refCanvas,
     !transparentBackground /* not equal */,
     null /*no fuzz*/,
     "full draw of source on yellow background",
     "reference"
@@ -95,34 +97,34 @@ async function runDrawWindowTests(snapsh
     "reference"
   );
 
   // Test drawing a region within the document.
 
   clear("white");
 
   testCx.translate(17, 31);
-  await snapshotCallback(testWrapCx, 40, 0, 40, 40, "white");
+  testWrapCx.drawWindow(win, 40, 0, 40, 40, "white", drawWindowFlags);
 
   refCx.fillStyle = "aqua";
   refCx.fillRect(17 + 10, 31 + 10, 20, 20);
 
   assertSnapshots(
     testCanvas,
     refCanvas,
     true /* equal */,
     null /*no fuzz*/,
     "draw of subrect of source with matching background",
     "reference"
   );
 
   clear("blue");
 
   testCx.translate(17, 31);
-  await snapshotCallback(testWrapCx, 40, 0, 35, 45, "green");
+  testWrapCx.drawWindow(win, 40, 0, 35, 45, "green", drawWindowFlags);
 
   if (transparentBackground) {
     refCx.fillStyle = "green";
   } else {
     refCx.fillStyle = "white";
   }
   refCx.fillRect(17, 31, 35, 45);
   refCx.fillStyle = "aqua";
@@ -136,17 +138,17 @@ async function runDrawWindowTests(snapsh
     "draw of subrect of source with different background",
     "reference"
   );
 
   // Test transparency of background not disturbing what is behind
   clear("blue");
 
   testCx.translate(17, 31);
-  await snapshotCallback(testWrapCx, 40, 0, 35, 45, "transparent");
+  testWrapCx.drawWindow(win, 40, 0, 35, 45, "transparent", drawWindowFlags);
 
   if (!transparentBackground) {
     refCx.fillStyle = "white";
     refCx.fillRect(17, 31, 35, 45);
   }
   refCx.fillStyle = "aqua";
   refCx.fillRect(17 + 10, 31 + 10, 20, 20);
 
@@ -159,22 +161,22 @@ async function runDrawWindowTests(snapsh
     "reference"
   );
 
   // Test that multiple drawWindow calls draw at correct positions.
   clear("blue");
 
   testCx.translate(9, 3);
   // 5, 8 is 5, 2 from the corner of the fuchsia square
-  await snapshotCallback(testWrapCx, 5, 8, 30, 25, "maroon");
+  testWrapCx.drawWindow(win, 5, 8, 30, 25, "maroon", drawWindowFlags);
   // 35, 0 is 15, 10 from the corner of the aqua square
-  await snapshotCallback(testWrapCx, 35, 0, 50, 40, "transparent");
+  testWrapCx.drawWindow(win, 35, 0, 50, 40, "transparent", drawWindowFlags);
   testCx.translate(15, 0);
   // 85, 5 is 5, 5 from the corner of the yellow square
-  await snapshotCallback(testWrapCx, 85, 5, 30, 25, "transparent");
+  testWrapCx.drawWindow(win, 85, 5, 30, 25, "transparent", drawWindowFlags);
 
   if (transparentBackground) {
     refCx.fillStyle = "maroon";
     refCx.fillRect(9, 3, 30, 25);
     refCx.fillStyle = "fuchsia";
     refCx.fillRect(9 + 5, 3 + 2, 20, 20);
   } else {
     refCx.fillStyle = "white";
--- a/dom/canvas/test/mochitest.ini
+++ b/dom/canvas/test/mochitest.ini
@@ -221,18 +221,16 @@ skip-if = os == "android"
 [test_canvas_strokeStyle_getter.html]
 [test_capture.html]
 support-files = captureStream_common.js
 [test_drawImageIncomplete.html]
 [test_drawImage_document_domain.html]
 [test_drawImage_edge_cases.html]
 [test_drawWindow.html]
 support-files = file_drawWindow_source.html file_drawWindow_common.js
-[test_drawSnapshot.html]
-support-files = file_drawWindow_source.html file_drawWindow_common.js
 [test_imagebitmap.html]
 skip-if = android_version == '19' # bug 1336581
 tags = imagebitmap
 [test_imagebitmap_close.html]
 tags = imagebitmap
 [test_imagebitmap_cropping.html]
 skip-if = android_version >= '17' # bug 1336581
 tags = imagebitmap
deleted file mode 100644
--- a/dom/canvas/test/test_drawSnapshot.html
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for drawSnapshot</title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
-  <script type="application/javascript" src="file_drawWindow_common.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript">
-
-  SimpleTest.waitForExplicitFinish();
-  window.addEventListener("load", runTests);
-
-  async function runTests(event) {
-    let snapshot = async function(context, x, y, width, height, bg) {
-      let elem = document.getElementById("source");
-
-      var rect = new window.DOMRect(x, y, width, height);
-
-      let image = await SpecialPowers.snapshotContext(elem, rect, bg);
-      context.drawImage(image, 0, 0);
-    }
-
-    // Run the tests with the source document in an <iframe> within this
-    // page, which we expect to have transparency.
-    await runDrawWindowTests(snapshot, true);
-
-    SimpleTest.finish();
-  }
-
-  </script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
-<iframe id="source" src="file_drawWindow_source.html" width="200" height="100"></iframe>
-</body>
-</html>
--- a/dom/canvas/test/test_drawWindow.html
+++ b/dom/canvas/test/test_drawWindow.html
@@ -18,35 +18,33 @@
     if (event.target != document) {
       return;
     }
 
     sourceWindow = window.open("file_drawWindow_source.html", "",
                                "width=200,height=100");
     sourceWindow.addEventListener("load", runTests);
   }
-    
-  async function runTests(event) {
+
+  function runTests(event) {
     if (event.target != sourceWindow.document) {
       return;
     }
 
-    let win = document.getElementById("source").contentWindow;
-    let snapshot = function(context, x, y, width, height, bg) {
-      context.drawWindow(win, x, y, width, height, bg, 0);
-    }
-
     // Run the tests with the source document in an <iframe> within this
     // page, which we expect to have transparency.
-    await runDrawWindowTests(snapshot, true);
+    runDrawWindowTests(document.getElementById("source").contentWindow,
+                       0, true);
 
     // Run the tests on the same source document, but in a window opened
-    // by window.open.  We do not expect this to have transparency.
-    win = sourceWindow;
-    await runDrawWindowTests(snapshot, false);
+    // by window.open.  We do not expect this to have transparency...
+    // except on B2G.  (This is *probably* a bug in B2G.)
+    var isB2G = /Mobile|Tablet/.test(navigator.userAgent) &&
+                !navigator.userAgent.includes("Android");
+    runDrawWindowTests(sourceWindow, 0, isB2G);
 
     sourceWindow.close();
 
     SimpleTest.finish();
   }
 
   </script>
 </head>
--- a/testing/specialpowers/content/SpecialPowersAPI.jsm
+++ b/testing/specialpowers/content/SpecialPowersAPI.jsm
@@ -1358,27 +1358,16 @@ class SpecialPowersAPI extends JSWindowA
         obj = obj[p];
       } else {
         return null;
       }
     }
     return obj;
   }
 
-  _browsingContextForTarget(target) {
-    if (BrowsingContext.isInstance(target)) {
-      return target;
-    }
-    if (Element.isInstance(target)) {
-      return target.browsingContext;
-    }
-
-    return BrowsingContext.getFromWindow(target);
-  }
-
   /**
    * Runs a task in the context of the given frame, and returns a
    * promise which resolves to the return value of that task.
    *
    * The given frame may be in-process or out-of-process. Either way,
    * the task will run asynchronously, in a sandbox with access to the
    * frame's content window via its `content` global. Any arguments
    * passed will be copied via structured clone, as will its return
@@ -1407,38 +1396,33 @@ class SpecialPowersAPI extends JSWindowA
    * @returns {Promise<any>}
    *        A promise which resolves to the return value of the task, or
    *        which rejects if the task raises an exception. As this is
    *        being written, the rejection value will always be undefined
    *        in the cases where the task throws an error, though that may
    *        change in the future.
    */
   spawn(target, args, task) {
-    let browsingContext = this._browsingContextForTarget(target);
+    let browsingContext;
+    if (BrowsingContext.isInstance(target)) {
+      browsingContext = target;
+    } else if (Element.isInstance(target)) {
+      browsingContext = target.browsingContext;
+    } else {
+      browsingContext = BrowsingContext.getFromWindow(target);
+    }
 
     return this.sendQuery("Spawn", {
       browsingContext,
       args,
       task: String(task),
       caller: SpecialPowersSandbox.getCallerInfo(Components.stack.caller),
     });
   }
 
-  snapshotContext(target, rect, background) {
-    let browsingContext = this._browsingContextForTarget(target);
-
-    return this.sendQuery("Snapshot", {
-      browsingContext,
-      rect,
-      background,
-    }).then(imageData => {
-      return this.contentWindow.createImageBitmap(imageData);
-    });
-  }
-
   _spawnTask(task, args, caller, taskId) {
     let sb = new SpecialPowersSandbox(null, data => {
       this.sendAsyncMessage("ProxiedAssert", { taskId, data });
     });
 
     sb.sandbox.SpecialPowers = this;
     Object.defineProperty(sb.sandbox, "content", {
       get: () => {
--- a/testing/specialpowers/content/SpecialPowersAPIParent.jsm
+++ b/testing/specialpowers/content/SpecialPowersAPIParent.jsm
@@ -12,17 +12,16 @@ var { XPCOMUtils } = ChromeUtils.import(
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   ExtensionData: "resource://gre/modules/Extension.jsm",
   ExtensionTestCommon: "resource://testing-common/ExtensionTestCommon.jsm",
   PerTestCoverageUtils: "resource://testing-common/PerTestCoverageUtils.jsm",
   ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
   SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.jsm",
-  HiddenFrame: "resource://gre/modules/HiddenFrame.jsm",
 });
 
 class SpecialPowersError extends Error {
   get name() {
     return "SpecialPowersError";
   }
 }
 
@@ -855,38 +854,16 @@ class SpecialPowersAPIParent extends JSW
 
         return spParent
           .sendQuery("Spawn", { task, args, caller, taskId })
           .finally(() => {
             spParent._taskActors.delete(taskId);
           });
       }
 
-      case "Snapshot": {
-        let { browsingContext, rect, background } = aMessage.data;
-
-        return browsingContext.currentWindowGlobal
-          .drawSnapshot(rect, 1.0, background)
-          .then(async image => {
-            let hiddenFrame = new HiddenFrame();
-            let win = await hiddenFrame.get();
-
-            let canvas = win.document.createElement("canvas");
-            canvas.width = image.width;
-            canvas.height = image.height;
-
-            const ctx = canvas.getContext("2d");
-            ctx.drawImage(image, 0, 0);
-
-            let data = ctx.getImageData(0, 0, image.width, image.height);
-            hiddenFrame.destroy();
-            return data;
-          });
-      }
-
       case "ProxiedAssert": {
         let { taskId, data } = aMessage.data;
         let actor = this._taskActors.get(taskId);
 
         actor.sendAsyncMessage("Assert", data);
         return undefined;
       }