| <!DOCTYPE html> |
| <title>Canvas test: 2d.imageData.put.wrongtype</title> |
| <script src="../tests.js"></script> |
| <link rel="stylesheet" href="../tests.css"> |
| <body> |
| <p id="passtext">Pass</p> |
| <p id="failtext">Fail</p> |
| <p class="output">These images should be identical:</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="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> |
| |