2 <canvas id=
"mycanvas"><button id=
"button"></button></canvas>
3 <script src=
"../../resources/js-test.js"></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');
16 function testAPICalls() {
19 ctx
.rect(0, 0, 10, 10);
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");
36 ctx
.drawImage(canvas
, 0, 0);
37 ctx
.getImageData(0, 0, 5, 5);
40 testFailed("Unexpected exception.");
44 // First pass: normal conditions
47 // Test a zero size canvas
51 // Test a canvas so large that it has no chance of successfull allocating a backing
52 canvas
.width
= 10000000;
53 canvas
.height
= 10000000;
56 // Test a canvas that is valid, but detached from the DOM