chromium/third_party/blink/web_tests/fast/canvas/canvas-path-with-inf-nan-dimensions.html

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<canvas width="200" height="200" id="canvas"></canvas>
<script>
test(function(t) {
    var ctx = document.getElementById("canvas").getContext("2d");
    
    // 1. Infinite dimensions to fillRect
    ctx.fillStyle = "green";
    ctx.fillRect(0, 0, 100, 100);
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, Infinity, Infinity);
    
    // 2. Infinite dimensions to rect
    ctx.fillStyle = "green";
    ctx.fillRect(100, 0, 100, 100);
    ctx.fillStyle = "red";
    ctx.rect(100, 0, Infinity, Infinity);
    ctx.fill();
    
    // 3. Infinite argument to moveTo
    ctx.translate(0, 100);
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, 100, 100);
    ctx.fillStyle = "green";
    ctx.beginPath();
    ctx.moveTo(Infinity, Infinity);
    ctx.rect(0, 0, 100, 100);
    ctx.fill();
    
    // 4. Infinite argument to lineTo
    ctx.translate(100, 0);
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, 100, 100);
    ctx.fillStyle = "green";
    ctx.beginPath();
    ctx.moveTo(0,0);
    ctx.lineTo(100, 0);
    ctx.lineTo(100, 100);
    ctx.lineTo(0, 100);
    ctx.lineTo(Infinity, 100);
    ctx.fill();
    
    var points = [25, 50, 75, 125, 150, 175];
    for (var x = 0; x < points.length; x++)
        for (var y = 0; y < points.length; y++)
            assert_array_equals(ctx.getImageData(points[x], points[y], 1, 1).data, [0, 128, 0, 255]);
}, 'Test canvas with infinity passed to fillRect, rect, moveTo and lineTo.');
</script>