chromium/third_party/blink/web_tests/fast/canvas-api/canvas-overloads-drawImage.html

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
test(function(t) {
    var ctx = document.createElement('canvas').getContext('2d');
    var imageElement = document.createElement("img");
    assert_throws_js(TypeError, function() {
      ctx.drawImage();
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement, 0);
    });
    assert_equals(ctx.drawImage(imageElement, 0, 0), undefined);
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement, 0, 0, 0);
    });
    assert_equals(ctx.drawImage(imageElement, 0, 0, 0, 0), undefined);
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement, 0, 0, 0, 0, 0);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0);
    });
    assert_equals(ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0), undefined);
    assert_equals(ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0), undefined);
    assert_equals(ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), undefined);

    var canvasElement = document.createElement("canvas");
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement, 0);
    });
    assert_equals(ctx.drawImage(canvasElement, 0, 0), undefined);
    assert_equals(ctx.drawImage(canvasElement, 0, 0, 0, 0), undefined);
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement, 0, 0, 0);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement, 0, 0, 0, 0, 0);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0);
    });
    assert_throws_js(TypeError, function() {
      ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0);
    });
    assert_equals(ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0), undefined);
    assert_equals(ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0), undefined);
    assert_equals(ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), undefined);

}, "Test the behavior of CanvasRenderingContext2D.drawImage() when called with different numbers of arguments.");
</script>
</body>