chromium/third_party/blink/web_tests/fast/canvas-api/canvas-with-incorrect-args.html

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<script>
test(function () {
    var canvas = document.createElement('canvas');
    var context = canvas.getContext('2d');
    context.fillStyle = '#f00';

    context.fillRect(0, 0, canvas.width, canvas.height);
    context.fillRect(0, 0, 0, 0);
    context.fillRect(0, 0, 0.0/1.0, 0.0/1.0);
    context.fillRect(0, 0, NaN, NaN);

    context.clearRect(0, 0, 0, 0);
    context.clearRect(0, 0, 0.0/1.0, 0.0/1.0);
    context.clearRect(0, 0, NaN, NaN);

    context.rect(0, 0, 0, 0);
    context.rect(0, 0, 0.0/1.0, 0.0/1.0);
    context.rect(0, 0, NaN, NaN);

    context.fill();
    context.arc(2, 2, 0, 0, 90, true);
    assert_throws_dom("INDEX_SIZE_ERR", function() {
      context.arc(2, 2, -10, 0, 90, true);
    });
    context.arc(2, 2, Infinity, 0, 90, true);
    context.arc(2, 2, NaN, 0, 90, true);

    context.beginPath();
    context.moveTo(10, 10);
    context.arcTo(2, 2, 4, 4, 0);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.arc(2, 2, 4, 4, -10);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.arcTo(2, 2, 4, 4, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.arcTo(2, 2, 4, 4, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(Infinity, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(Infinity, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(20, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(NaN, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(20, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.lineTo(NaN, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, Infinity, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(Infinity, Infinity, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(Infinity, 20, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, Infinity, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, Infinity, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, 20, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, NaN, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(NaN, NaN, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(NaN, 20, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, NaN, 20, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, NaN, 20);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.quadraticCurveTo(20, 20, 20, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, Infinity, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, 30, Infinity);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, Infinity, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, Infinity, Infinity, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, Infinity, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, Infinity, 30, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(Infinity, Infinity, 20, 20, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(30, Infinity, 20, 20, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(Infinity, 30, 20, 20, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, NaN, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, 0, NaN);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, 30, NaN, 0);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, NaN, NaN, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, 30, NaN, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, 20, NaN, 30, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(NaN, NaN, 20, 20, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(20, NaN, 20, 20, 30, 30);
    context.closePath();

    context.beginPath();
    context.moveTo(10, 10);
    context.bezierCurveTo(NaN, 20, 20, 20, 30, 30);
    context.closePath();

    var canvas2 = document.createElement('canvas');
    canvas2.width = canvas2.height = 0;
    assert_throws_dom("INVALID_STATE_ERR", function() {
      var pattern = context.createPattern(canvas2, 'repeat');
    });
    context.fillStyle = '#0f0';
    context.fillRect(0, 0, canvas.width, canvas.height);
}, "Verify the behavior of a number of the DOM Canvas drawing methods when given 0, Infinity, or NaN as parameters. Test should not crash.");
</script>