commit-queue@webkit.org | 9a94dd7 | 2014-11-14 23:45:41 +0000 | [diff] [blame] | 1 | <!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.org | 4d8349c | 2015-01-21 19:35:08 +0000 | [diff] [blame] | 19 | <p class="output expectedtext">Expected output:<p><img src="../resources/green-100x50.png" class="output expected" id="expected" alt=""> |
commit-queue@webkit.org | 9a94dd7 | 2014-11-14 23:45:41 +0000 | [diff] [blame] | 20 | <ul id="d"></ul> |
| 21 | <script> |
| 22 | _addTest(function(canvas, ctx) { |
| 23 | |
| 24 | ctx.fillStyle = '#0f0'; |
| 25 | ctx.fillRect(0, 0, 100, 50); |
| 26 | |
| 27 | var canvas2 = document.createElement('canvas'); |
| 28 | canvas2.width = 0; |
| 29 | canvas2.height = 10; |
| 30 | try { 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 | |
| 34 | canvas2.width = 10; |
| 35 | canvas2.height = 0; |
| 36 | try { 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 | |
| 40 | canvas2.width = 0; |
| 41 | canvas2.height = 0; |
| 42 | try { 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 | |