Bug 1473404 [wpt PR 11786] - Add a test for the bounds-checking in createImageBitmap., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Sat, 07 Jul 2018 00:29:03 +0000
changeset 426153 8e9a5ab5c1dae84e4b91419835cb0ea693b1b7e1
parent 426152 d6eef7f3762eaf4dc767bfcdafa831db644a9b00
child 426154 ed20fb6ed981fb40c7521ba3948fde52a954bd7b
push id34267
push userrgurzau@mozilla.com
push dateWed, 11 Jul 2018 22:05:21 +0000
treeherdermozilla-central@3aca103e4915 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1473404, 11786
milestone63.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 1473404 [wpt PR 11786] - Add a test for the bounds-checking in createImageBitmap., a=testonly Automatic update from web-platform-testsAdd a test for the bounds-checking in createImageBitmap. -- wpt-commits: 3634f42a67eeb156aceb8d4e337b62f01908cdf8 wpt-pr: 11786
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-bounds.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -306180,16 +306180,22 @@
     ]
    ],
    "2dcontext/image-smoothing/imagesmoothing.html": [
     [
      "/2dcontext/image-smoothing/imagesmoothing.html",
      {}
     ]
    ],
+   "2dcontext/imagebitmap/createImageBitmap-bounds.html": [
+    [
+     "/2dcontext/imagebitmap/createImageBitmap-bounds.html",
+     {}
+    ]
+   ],
    "2dcontext/imagebitmap/createImageBitmap-drawImage.html": [
     [
      "/2dcontext/imagebitmap/createImageBitmap-drawImage.html",
      {}
     ]
    ],
    "2dcontext/imagebitmap/createImageBitmap-invalid-args.html": [
     [
@@ -412367,16 +412373,20 @@
   "2dcontext/image-smoothing/imagesmoothing.html": [
    "a50b997a4c738f68360f4aa450e1ea7f12687770",
    "testharness"
   ],
   "2dcontext/imagebitmap/common.sub.js": [
    "5da74cfd37ef072aa5b50c9a5fb658754984216b",
    "support"
   ],
+  "2dcontext/imagebitmap/createImageBitmap-bounds.html": [
+   "cf1d9de3474c61c5827094cead43313883bc2408",
+   "testharness"
+  ],
   "2dcontext/imagebitmap/createImageBitmap-drawImage.html": [
    "adef50e6043c6ecb80bdc4a6b7f9d9a599a80656",
    "testharness"
   ],
   "2dcontext/imagebitmap/createImageBitmap-invalid-args.html": [
    "ea323d1c0adfa41e6f5c56be2006a4cd178c470d",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-bounds.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<title>createImageBitmap: clipping to the bitmap</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/canvas-tests.js"></script>
+<script>
+promise_test(function(t) {
+    return new Promise(function(resolve, reject) {
+        const image = new Image();
+        image.onload = function() { resolve(image); };
+        image.onerror = function() { reject(); };
+        image.src = "/images/green-16x16.png";
+    }).then(function(image) {
+        return createImageBitmap(image, 8, 8, 16, 16);
+    }).then(function(imageBitmap) {
+        const color = 204;
+
+        const canvas = document.createElement("canvas");
+        canvas.width = 16;
+        canvas.height = 16;
+
+        // debug
+        document.body.appendChild(canvas);
+        canvas.setAttribute("style", "width: 100px; height: 100px;");
+
+        const ctx = canvas.getContext("2d");
+        ctx.fillStyle = `rgb(${color}, ${color}, ${color})`;
+        ctx.fillRect(0, 0, 20, 20);
+        ctx.drawImage(imageBitmap, 0, 0);
+
+        const expected = [
+            [ 4,  4, 0,255,0,255],
+            [12,  4, color,color,color,255],
+            [ 4, 12, color,color,color,255],
+            [12, 12, color,color,color,255],
+        ];
+        for (let [x, y, r, g, b, a] of expected) {
+            _assertPixel(canvas, x,y, r,g,b,a, `${x},${y}`, `${r},${g},${b},${a}`);
+        }
+
+    });
+});
+</script>