Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / draw-focus-if-needed.html
blob8bfb2ea3bfefca1cead0a7fbe0dd3cb2a3933937
1 <!DOCTYPE HTML>
2 <head>
3 <title>Canvas test: drawFocusIfNeeded</title>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body style="padding: 0; margin: 0">
7 <canvas id="canvas" class="output" width="300" height="350">
8 <button id="button1"></button>
9 <button id="button2"></button>
10 </canvas>
11 <script>
12 if (window.testRunner)
13 testRunner.dumpAsText();
15 document.getElementById("button1").focus();
17 var canvas = document.getElementById("canvas").getContext("2d");
19 shouldThrow('canvas.drawFocusIfNeeded(null);');
20 shouldThrow('canvas.drawFocusIfNeeded();');
22 canvas.beginPath();
23 canvas.rect(50, 50, 200, 100);
24 canvas.fillStyle = "#ccf";
25 canvas.fill();
26 // re-test null case after having defined a path (regression test for crbug.com/353248)
27 shouldThrow('canvas.drawFocusIfNeeded(null);');
28 canvas.drawFocusIfNeeded(document.getElementById("button1"));
30 canvas.beginPath();
31 canvas.rect(50, 200, 200, 100);
32 canvas.fillStyle = "#cfc";
33 canvas.fill();
34 canvas.drawFocusIfNeeded(document.getElementById("button2"));
36 // The top rect"s focus ring is tied to button1, which is focused.
37 // It should have an outline in some color other than the background color.
38 var imageData = canvas.getImageData(49, 50, 1, 1);
39 var data = imageData.data;
40 shouldBe("data[0] != 0 || data[1] != 0 || data[2] != 0", "true");
42 // The bottom rect"s focus ring is tied to button2, which is not focused.
43 imageData = canvas.getImageData(49, 200, 1, 1);
44 data = imageData.data;
45 shouldBe("data[0] == 0 && data[1] == 0 && data[2] == 0", "true");
46 </script>
47 </body>