Add attribute tests for CanvasFilter ConvolveMatrix

Previously the ref test only tested kernelMatrix, this one has a
draw for every attribute on SVG ConvolveMatrix filters:
https://drafts.fxtf.org/filter-effects-1/#elementdef-feconvolvematrix

Currently the bias test is disabled because for reasons unknown we're
getting different results from bias in canvas and bias in svg. As of
right now I have no idea why this would be. Filed a bug:
crbug.com/1213510

Bug: 1169216
Change-Id: I2ec91de4b34ffe9ac3693c8e3248a8403a918554
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2920586
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#887195}
diff --git a/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix-expected.html b/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix-expected.html
index f8dba9b..896a935 100644
--- a/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix-expected.html
+++ b/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix-expected.html
@@ -1,21 +1,55 @@
+<!DOCTYPE html>
+<style type="text/css">
+  canvas {
+    margin: 5px;
+  }
+</style>
 <body>
-  <canvas id="canvas"></canvas>
   <svg width="0" height="0">
-    <filter id="emboss">
-          <feConvolveMatrix
-              kernelMatrix="3 0 0
-                            0 0 0
-                            0 0 -3"/>
+    <filter color-interpolation-filters='sRGB' id="justKernel">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"/>
+    </filter>
+    <filter color-interpolation-filters='sRGB' id="preserveAlpha">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"
+          preserveAlpha="true"/>
+    </filter>
+    <filter color-interpolation-filters='sRGB' id="target">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"
+          targetX="2" targetY="2"/>
+    </filter>
+    <filter color-interpolation-filters='sRGB' id="divisor">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"
+          divisor="3"/>
+    </filter>
+    <filter color-interpolation-filters='sRGB' id="bias">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"
+          bias="0.5"/>
+    </filter>
+    <filter color-interpolation-filters='sRGB' id="edgeMode">
+      <feConvolveMatrix
+          kernelMatrix="3 0 0 0 0 0 0 0 -3"
+          edgeMode="wrap"/>
     </filter>
   </svg>
 </body>
 <script type="text/javascript">
 
-const canvas = document.getElementById("canvas");
-const ctx = canvas.getContext("2d");
+const filters = [
+  "url('#justKernel')",
+  "url('#preserveAlpha')",
+  "url('#target')",
+  "url('#divisor')",
+  "url('#bias')",
+  "url('#edgeMode')",
+];
 
-function draw() {
-  ctx.fillRect(20, 20, 100, 100);
+function draw(ctx) {
+  ctx.fillRect(0, 20, 120, 100);
 
   ctx.beginPath();
   ctx.arc(150, 70, 50, 0, 2*Math.PI);
@@ -29,10 +63,15 @@
   ctx.fill();
 }
 
-ctx.fillStyle = "rgba(0,255,0,0.5)";
-draw();
-ctx.fillStyle = "rgba(255,0,255,0.5)";
-ctx.filter = "url('#emboss')";
-draw();
-
+for (f of filters) {
+  const canvas = document.createElement("canvas");
+  document.body.prepend(canvas);
+  const ctx = canvas.getContext("2d");
+  ctx.filter = "blur(0px)";
+  ctx.fillStyle = "rgba(0,255,0,0.5)";
+  draw(ctx);
+  ctx.fillStyle = "rgba(255,0,255,0.5)";
+  ctx.filter = f;
+  draw(ctx);
+}
 </script>
diff --git a/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix.html b/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix.html
index c565107..157deec 100644
--- a/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix.html
+++ b/html/canvas/element/manual/filters/canvas-filter-object-convolve-matrix.html
@@ -1,38 +1,59 @@
+<!DOCTYPE html>
 <head>
     <link rel="match" href="canvas-filter-object-convolve-matrix-expected.html">
+    <style type="text/css">
+      canvas {
+        margin: 5px;
+      }
+    </style>
 </head>
 <body>
-  <canvas id="canvas"></canvas>
 </body>
 <script>
-  const canvas = document.getElementById("canvas");
+function makeConvolveFilter(options) {
+  const KERNEL_MATRIX = [
+    [3, 0, 0],
+    [0, 0, 0],
+    [0, 0, -3],
+  ];
+
+  options = Object.assign(options, {kernelMatrix: KERNEL_MATRIX});
+  return new CanvasFilter({convolveMatrix: options});
+}
+
+const test_cases = [
+  {},
+  {preserveAlpha: true},
+  {targetX: 2, targetY: 2},
+  {divisor: 3},
+  {bias: 0.5},
+  {edgeMode: "wrap"}
+];
+
+function draw(ctx) {
+  ctx.fillRect(0, 20, 120, 100);
+
+  ctx.beginPath();
+  ctx.arc(150, 70, 50, 0, 2*Math.PI);
+  ctx.fill();
+
+  ctx.beginPath();
+  ctx.moveTo(220, 20);
+  ctx.lineTo(170, 120);
+  ctx.lineTo(270, 120);
+  ctx.lineTo(220, 20);
+  ctx.fill();
+}
+
+for (tc of test_cases) {
+  const canvas = document.createElement("canvas");
+  document.body.prepend(canvas);
   const ctx = canvas.getContext("2d");
-
-  const convolveFilter = new CanvasFilter({convolveMatrix: {
-    kernelMatrix: [
-      [3, 0, 0],
-      [0, 0, 0],
-      [0, 0, -3],
-    ],
-  }});
-
-  function draw() {
-    ctx.fillRect(20, 20, 100, 100);
-
-    ctx.beginPath();
-    ctx.arc(150, 70, 50, 0, 2*Math.PI);
-    ctx.fill();
-
-    ctx.beginPath();
-    ctx.moveTo(220, 20);
-    ctx.lineTo(170, 120);
-    ctx.lineTo(270, 120);
-    ctx.lineTo(220, 20);
-    ctx.fill();
-  }
+  ctx.filter = "blur(0px)";
   ctx.fillStyle = "rgba(0,255,0,0.5)";
-  draw();
+  draw(ctx);
   ctx.fillStyle = "rgba(255,0,255,0.5)";
-  ctx.filter = convolveFilter;
-  draw();
+  ctx.filter = makeConvolveFilter(tc);
+  draw(ctx);
+}
 </script>