Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / painting-on-bad-canvas.html
blob31c38057cecbf33ba5f53abdce77d4b52afeb350
1 <!DOCTYPE html>
2 <canvas id="mycanvas"><button id="button"></button></canvas>
3 <script src="../../resources/js-test.js"></script>
4 <script>
5 description("This tests verifies that canvas API calls on a canvas with no backing or no visibility do not crash or throw exceptions.");
7 if (window.testRunner) {
8 testRunner.dumpAsText();
11 var canvas = document.getElementById('mycanvas');
12 var ctx = canvas.getContext('2d');
13 var button = document.getElementById('button');
14 button.focus();
16 function testAPICalls() {
17 try {
18 ctx.beginPath();
19 ctx.rect(0, 0, 10, 10);
20 ctx.fill();
21 ctx.stroke();
22 ctx.drawFocusIfNeeded(button);
23 ctx.isPointInPath(0,0);
24 ctx.isPointInStroke(0,0);
25 ctx.clearRect(0, 0, 5, 5);
26 ctx.fillRect(0, 0, 5, 5);
27 ctx.strokeRect(0, 0, 5, 5);
28 ctx.scrollPathIntoView();
29 data = ctx.createImageData(5, 5);
30 ctx.putImageData(data, 0, 0);
31 ctx.font = "20px arial";
32 ctx.fillText("Test", 20, 20);
33 ctx.strokeText("Test", 20, 20);
34 ctx.measureText("Test");
35 ctx.clip();
36 ctx.drawImage(canvas, 0, 0);
37 ctx.getImageData(0, 0, 5, 5);
38 canvas.toDataURL();
39 } catch(err) {
40 testFailed("Unexpected exception.");
44 // First pass: normal conditions
45 testAPICalls();
47 // Test a zero size canvas
48 canvas.width = 0;
49 testAPICalls();
51 // Test a canvas so large that it has no chance of successfull allocating a backing
52 canvas.width = 10000000;
53 canvas.height = 10000000;
54 testAPICalls();
56 // Test a canvas that is valid, but detached from the DOM
57 canvas.width = 100;
58 canvas.height = 100;
59 canvas.remove();
60 testAPICalls();
62 </script>