Darken Composite Operation Test

JavaScript

function hasDarker() {
    var canvas = document.createElement( 'canvas' );
    var ctx = canvas.getContext( '2d' );
    ctx.globalCompositeOperation = 'darker';
    ctx.fillStyle = 'rgb(1,0,0)';
    ctx.fillRect(0,0,1,1);
    ctx.fillStyle = 'rgb(2,0,0)';
    ctx.fillRect(0,0,1,1);
    var data = ctx.getImageData(0,0,1,1).data;
    return data[0] === 1;
}

var ok = hasDarker();
console.log( ok );