Bug 1495773 [wpt PR 13315] - Refactor drawimage_svg_image_1.html., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Tue, 09 Oct 2018 04:12:35 +0000
changeset 495915 339db7b866123a09388635cd70dcee6ad534163f
parent 495914 becdf312fccfadf499092c0c0f1f73a7d08a854d
child 495916 074ddf320f70ed497e083a136cbf7402ca9f8fa4
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1495773, 13315
milestone64.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 1495773 [wpt PR 13315] - Refactor drawimage_svg_image_1.html., a=testonly Automatic update from web-platform-testsRefactor drawimage_svg_image_1.html. In particular, stop using generate_tests() for things that needn't be subtests anyway. -- wpt-commits: 576d359295a7279d31e8319b6cbafb7d6c1ac843 wpt-pr: 13315
testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html
--- a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html
+++ b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html
@@ -1,46 +1,31 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Load a 100x100 image to a SVG image and draw it to a 100x100 canvas.</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
+<script src="/common/canvas-tests.js"></script>
+<div id="log"></div>
 <canvas id="dest" height="100" width="100"></canvas>
-
 <script>
-var sourceWidth = 100;
-var sourceHeight = 100;
-var smoothingEnabled = false;
-var destCanvas = document.getElementById('dest');
-var sourceImg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
-sourceImg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', '../2x2.png');
-sourceImg.width = sourceWidth;
-sourceImg.height = sourceHeight;
-var destCtx = destCanvas.getContext('2d');
+async_test(t => {
+  var sourceImg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
+  sourceImg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', '../2x2.png');
+  sourceImg.width = 100;
+  sourceImg.height = 100;
 
-function checkPixel(x, y, expected, epsilon) {
-    var actual = destCtx.getImageData(x, y, 1, 1).data;
-    assert_true(actual.length === expected.length);
-    for (var i=0; i < actual.length; i++)
-        assert_approx_equals(actual[i], expected[i], epsilon);
-}
-
-var pixelTests = [
-    ['Pixel Top Left Image', 0, 0, [253, 140, 245, 255], 1],
-    ['Pixel Top Right Image', 0, 99, [253, 140, 245, 255], 1],
-    ['Pixel Bottom Left Image', 99, 0, [253, 140, 245, 255], 1],
-    ['Pixel Bottom Right Image', 99, 99, [253, 140, 245, 255], 1],
-];
-
-function runTest() {
+  window.onload = t.step_func_done(() => {
+    var destCanvas = document.getElementById('dest');
+    var destCtx = destCanvas.getContext('2d');
     destCtx.fillStyle = "#FF0000";
     destCtx.fillRect(0, 0,  destCanvas.width, destCanvas.height);
-    destCtx.imageSmoothingEnabled = smoothingEnabled;
+    destCtx.imageSmoothingEnabled = false;
     // 2 arguments, the dest origin is 0,0
     // The source canvas will copied to the 0,0 position of the destination canvas
     destCtx.drawImage(sourceImg, 0, 0);
-    generate_tests(checkPixel, pixelTests);
-}
-
-async_test(t => {
-        window.onload = function() {
-            t.step(runTest);
-            t.done();
-        }
-}, 'Load a 100x100 image to a SVG image and draw it to a 100x100 canvas.');
-</script>
\ No newline at end of file
+    _assertPixel(destCanvas, 0, 0, 253, 140, 245, 255);
+    _assertPixel(destCanvas, 0, 99, 253, 140, 245, 255);
+    _assertPixel(destCanvas, 99, 0, 253, 140, 245, 255);
+    _assertPixel(destCanvas, 99, 99, 253, 140, 245, 255);
+  });
+});
+</script>