blob: 8f143195b5c7988974194c106059a59696f15b2d [file] [log] [blame]
<!DOCTYPE html>
<title>Canvas test: 2d.imageData.put.wrongtype</title>
<meta name="author" content="Philip Taylor">
<script src="../common/canvas-tests.js"></script>
<link rel="stylesheet" href="../common/canvas-tests.css">
<body class="show_output">
<h1><a href="index.2d.html">2d</a>.<a href="index.2d.imageData.html">imageData</a>.<a href="index.2d.imageData.put.html">put</a>.wrongtype</h1>
<p class="desc">putImageData() does not accept non-ImageData objects</p>
<div class="refs">Spec references:
<ul>
<li><a href="../annotated-spec/canvas.html#testrefs.2d.imageData.put.wrongtype">2d.imageData.put.wrongtype</a>
</ul>
</div>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="../resources/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
_addTest(function(canvas, ctx) {
var imgdata = { width: 1, height: 1, data: [255, 0, 0, 255] };
try { var _thrown = false;
ctx.putImageData(imgdata, 0, 0);
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.putImageData(imgdata, 0, 0)"); }
try { var _thrown = false;
ctx.putImageData("cheese", 0, 0);
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.putImageData(\"cheese\", 0, 0)"); }
try { var _thrown = false;
ctx.putImageData(42, 0, 0);
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.putImageData(42, 0, 0)"); }
});
</script>