summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/imagebitmap_bug1239752.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/canvas/test/imagebitmap_bug1239752.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/canvas/test/imagebitmap_bug1239752.js')
-rw-r--r--dom/canvas/test/imagebitmap_bug1239752.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/dom/canvas/test/imagebitmap_bug1239752.js b/dom/canvas/test/imagebitmap_bug1239752.js
new file mode 100644
index 000000000..86e9d6f52
--- /dev/null
+++ b/dom/canvas/test/imagebitmap_bug1239752.js
@@ -0,0 +1,85 @@
+var RGBAValues = [[42,142,23,148],
+ [234,165,177,91],
+ [74,228,75,195],
+ [140,108,73,65],
+ [25,177,3,201],
+ [127,104,12,199],
+ [196,93,240,131],
+ [250,121,231,189],
+ [175,131,215,190],
+ [145,122,166,70],
+ [18,196,210,162],
+ [225,1,90,188],
+ [223,216,182,233],
+ [115,48,168,56],
+ [50,206,198,199],
+ [152,28,70,130],
+ [176,134,133,51],
+ [148,46,43,144],
+ [78,171,141,95],
+ [24,177,102,110],
+ [0,27,127,91],
+ [31,221,41,170],
+ [85,7,218,146],
+ [65,30,198,238],
+ [121,56,123,88],
+ [246,39,140,146],
+ [174,195,254,149],
+ [29,153,92,116],
+ [17,240,5,111],
+ [38,162,84,143],
+ [237,159,201,244],
+ [93,68,14,246],
+ [143,142,82,221],
+ [187,215,243,154],
+ [24,121,220,53],
+ [80,153,151,219],
+ [202,241,250,191]];
+
+function createOneTest(rgbaValue) {
+ return new Promise(function(resolve, reject) {
+ var tolerance = 5;
+ var r = rgbaValue[0];
+ var g = rgbaValue[1];
+ var b = rgbaValue[2];
+ var a = rgbaValue[3];
+ var imageData = new ImageData(new Uint8ClampedArray([r, g, b, a]), 1, 1);
+
+ var newImageData;
+ createImageBitmap(imageData).then(
+ function(imageBitmap) {
+ var context = document.createElement("canvas").getContext("2d");
+ context.drawImage(imageBitmap, 0, 0);
+ newImageData = context.getImageData(0, 0, 1, 1);
+ var newR = newImageData.data[0];
+ var newG = newImageData.data[1];
+ var newB = newImageData.data[2];
+ var newA = newImageData.data[3];
+ var isTheSame = Math.abs(r - newR) <= tolerance &&
+ Math.abs(g - newG) <= tolerance &&
+ Math.abs(b - newB) <= tolerance &&
+ Math.abs(a - newA) <= tolerance;
+ ok(isTheSame, "newImageData(" + newR + "," + newG + "," + newB + "," + newA +
+ ") should equal to imageData(" + r + "," + g + "," + b + "," + a + ")." +
+ "Premultiplied Alpha is handled while creating ImageBitmap from ImageData.");
+ if (isTheSame) {
+ resolve();
+ } else {
+ reject();
+ }
+ },
+ function() {
+ reject();
+ }
+ );
+ });
+}
+
+function testBug1239752() {
+ var tests = [];
+ for (var i = 0; i < RGBAValues.length; ++i) {
+ tests.push(createOneTest(RGBAValues[i]));
+ }
+
+ return Promise.all(tests);
+} \ No newline at end of file