Skip to content

Commit f88c0e9

Browse files
committed
Merge pull request mozilla#2972 from brendandahl/blend-mode-feature-test
Add feature test for blend mode.
2 parents 931ce96 + ed1fa5a commit f88c0e9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/features/tests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,34 @@ var tests = [
595595
},
596596
impact: 'Important',
597597
area: 'Core'
598+
},
599+
{
600+
id: 'Canvas Blend Mode',
601+
name: 'Canvas supports extended blend modes',
602+
run: function () {
603+
var fail = { output: 'Failed', emulated: 'No' };
604+
var ctx = document.createElement('canvas').getContext('2d');
605+
ctx.canvas.width = 1;
606+
ctx.canvas.height = 1;
607+
var mode = 'difference';
608+
ctx.globalCompositeOperation = mode;
609+
if (ctx.globalCompositeOperation !== mode) {
610+
return fail;
611+
}
612+
// Chrome supports setting the value, but it may not actually be
613+
// implemented, so we have to actually test the blend mode.
614+
ctx.fillStyle = 'red';
615+
ctx.fillRect(0, 0, 1, 1);
616+
ctx.fillStyle = 'blue';
617+
ctx.fillRect(0, 0, 1, 1);
618+
var pix = ctx.getImageData(0, 0, 1, 1).data;
619+
if (pix[0] !== 255 || pix[1] !== 0 || pix[2] !== 255) {
620+
return fail;
621+
}
622+
return { output: 'Success', emulated: '' };
623+
},
624+
impact: 'Important',
625+
area: 'Core'
598626
}
599627
];
600628

0 commit comments

Comments
 (0)