Bug 1570147 - Modify existing drawWindow tests to take a callback for the inner draw function. r=kmag
☠☠ backed out by 1f3fcdc28dfd ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 15 Aug 2019 06:10:09 +0000
changeset 488189 4d528be8bae4048f06fb4c2333a6e852146f25d0
parent 488188 4b4feec0a4e28887f61a53ec5e5d423db2cfb251
child 488190 7a24b90275194ce426881b0075c2ea0cd85d9c47
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)
reviewerskmag
bugs1570147
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 1570147 - Modify existing drawWindow tests to take a callback for the inner draw function. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D41827
dom/canvas/test/chrome/test_drawWindow_widget_layers.html
dom/canvas/test/file_drawWindow_common.js
dom/canvas/test/test_drawWindow.html
--- a/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
+++ b/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
@@ -29,22 +29,26 @@
 
     // 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);
   }
 
-  function runTests() {
+  async function runTests() {
     var cxInterfaceWrap = SpecialPowers.wrap(CanvasRenderingContext2D);
-    var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
-                cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
-                cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
-    runDrawWindowTests(sourceWindow, flags, true);
+    
+    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);
 
     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;
 
-function runDrawWindowTests(win, drawWindowFlags, transparentBackground) {
+async function runDrawWindowTests(snapshotCallback, 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,24 +32,23 @@ function runDrawWindowTests(win, drawWin
   function clear(fillStyle) {
     clearRef(fillStyle);
     clearTest(fillStyle);
   }
 
   // Basic tests of drawing the whole document on a background
 
   clear("white");
-  testWrapCx.drawWindow(
-    win,
+  await snapshotCallback(
+    testWrapCx,
     0,
     0,
     CANVAS_WIDTH,
     CANVAS_HEIGHT,
     "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(
@@ -57,24 +56,23 @@ function runDrawWindowTests(win, drawWin
     refCanvas,
     true /* equal */,
     null /*no fuzz*/,
     "full draw of source on white background",
     "reference"
   );
 
   clearTest("white");
-  testWrapCx.drawWindow(
-    win,
+  await snapshotCallback(
+    testWrapCx,
     0,
     0,
     CANVAS_WIDTH,
     CANVAS_HEIGHT,
     "rgb(255, 255, 0)",
-    drawWindowFlags
   );
   assertSnapshots(
     testCanvas,
     refCanvas,
     !transparentBackground /* not equal */,
     null /*no fuzz*/,
     "full draw of source on yellow background",
     "reference"
@@ -97,34 +95,34 @@ function runDrawWindowTests(win, drawWin
     "reference"
   );
 
   // Test drawing a region within the document.
 
   clear("white");
 
   testCx.translate(17, 31);
-  testWrapCx.drawWindow(win, 40, 0, 40, 40, "white", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 40, 0, 40, 40, "white");
 
   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);
-  testWrapCx.drawWindow(win, 40, 0, 35, 45, "green", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 40, 0, 35, 45, "green");
 
   if (transparentBackground) {
     refCx.fillStyle = "green";
   } else {
     refCx.fillStyle = "white";
   }
   refCx.fillRect(17, 31, 35, 45);
   refCx.fillStyle = "aqua";
@@ -138,17 +136,17 @@ function runDrawWindowTests(win, drawWin
     "draw of subrect of source with different background",
     "reference"
   );
 
   // Test transparency of background not disturbing what is behind
   clear("blue");
 
   testCx.translate(17, 31);
-  testWrapCx.drawWindow(win, 40, 0, 35, 45, "transparent", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 40, 0, 35, 45, "transparent");
 
   if (!transparentBackground) {
     refCx.fillStyle = "white";
     refCx.fillRect(17, 31, 35, 45);
   }
   refCx.fillStyle = "aqua";
   refCx.fillRect(17 + 10, 31 + 10, 20, 20);
 
@@ -161,22 +159,22 @@ function runDrawWindowTests(win, drawWin
     "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
-  testWrapCx.drawWindow(win, 5, 8, 30, 25, "maroon", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 5, 8, 30, 25, "maroon");
   // 35, 0 is 15, 10 from the corner of the aqua square
-  testWrapCx.drawWindow(win, 35, 0, 50, 40, "transparent", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 35, 0, 50, 40, "transparent");
   testCx.translate(15, 0);
   // 85, 5 is 5, 5 from the corner of the yellow square
-  testWrapCx.drawWindow(win, 85, 5, 30, 25, "transparent", drawWindowFlags);
+  await snapshotCallback(testWrapCx, 85, 5, 30, 25, "transparent");
 
   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/test_drawWindow.html
+++ b/dom/canvas/test/test_drawWindow.html
@@ -18,33 +18,35 @@
     if (event.target != document) {
       return;
     }
 
     sourceWindow = window.open("file_drawWindow_source.html", "",
                                "width=200,height=100");
     sourceWindow.addEventListener("load", runTests);
   }
-
-  function runTests(event) {
+    
+  async 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.
-    runDrawWindowTests(document.getElementById("source").contentWindow,
-                       0, true);
+    await runDrawWindowTests(snapshot, 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...
-    // 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);
+    // by window.open.  We do not expect this to have transparency.
+    win = sourceWindow;
+    await runDrawWindowTests(snapshot, false);
 
     sourceWindow.close();
 
     SimpleTest.finish();
   }
 
   </script>
 </head>