blob: ae98d93e2a81cbc3c4d3ff8d8235ee68463449ba [file] [log] [blame]
commit-queue@webkit.org9a94dd72014-11-14 23:45:41 +00001<!DOCTYPE html>
2<title>Canvas test: 2d.drawImage.zerocanvas</title>
3<meta name="author" content="Philip Taylor">
4<script src="../common/canvas-tests.js"></script>
5<link rel="stylesheet" href="../common/canvas-tests.css">
6<body class="show_output">
7
8<h1><a href="index.2d.html">2d</a>.<a href="index.2d.drawImage.html">drawImage</a>.zerocanvas</h1>
9<p class="desc"></p>
10
11<div class="refs">Spec references:
12<ul>
13<li><a href="../annotated-spec/canvas.html#testrefs.2d.drawImage.zerocanvas">2d.drawImage.zerocanvas</a>
14</ul>
15</div>
16
17<p class="output">Actual output:</p>
18<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
commit-queue@webkit.org4d8349c2015-01-21 19:35:08 +000019<p class="output expectedtext">Expected output:<p><img src="../resources/green-100x50.png" class="output expected" id="expected" alt="">
commit-queue@webkit.org9a94dd72014-11-14 23:45:41 +000020<ul id="d"></ul>
21<script>
22_addTest(function(canvas, ctx) {
23
24ctx.fillStyle = '#0f0';
25ctx.fillRect(0, 0, 100, 50);
26
27var canvas2 = document.createElement('canvas');
28canvas2.width = 0;
29canvas2.height = 10;
30try { var _thrown = false;
31 ctx.drawImage(canvas2, 0, 0);
32} catch (e) { if (e.code != DOMException.INVALID_STATE_ERR) _fail("Failed assertion: expected exception of type INVALID_STATE_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type INVALID_STATE_ERR: ctx.drawImage(canvas2, 0, 0)"); }
33
34canvas2.width = 10;
35canvas2.height = 0;
36try { var _thrown = false;
37 ctx.drawImage(canvas2, 0, 0);
38} catch (e) { if (e.code != DOMException.INVALID_STATE_ERR) _fail("Failed assertion: expected exception of type INVALID_STATE_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type INVALID_STATE_ERR: ctx.drawImage(canvas2, 0, 0)"); }
39
40canvas2.width = 0;
41canvas2.height = 0;
42try { var _thrown = false;
43 ctx.drawImage(canvas2, 0, 0);
44} catch (e) { if (e.code != DOMException.INVALID_STATE_ERR) _fail("Failed assertion: expected exception of type INVALID_STATE_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type INVALID_STATE_ERR: ctx.drawImage(canvas2, 0, 0)"); }
45
46_assertPixelApprox(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
47
48
49});
50</script>
51