Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/draw-focus-if-needed.html

Issue 2700823002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <head> 2 <head>
3 <title>Canvas test: drawFocusIfNeeded</title> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 </head> 5 </head>
6 <body style="padding: 0; margin: 0">
7 <canvas id="canvas" class="output" width="300" height="350"> 6 <canvas id="canvas" class="output" width="300" height="350">
8 <button id="button1"></button> 7 <button id="button1"></button>
9 <button id="button2"></button> 8 <button id="button2"></button>
10 </canvas> 9 </canvas>
11 <script> 10 <script>
12 if (window.testRunner) 11 test(function(t) {
13 testRunner.dumpAsText();
14 12
15 document.getElementById("button1").focus(); 13 document.getElementById("button1").focus();
16 14
17 var canvas = document.getElementById("canvas").getContext("2d"); 15 var canvas = document.getElementById("canvas").getContext("2d");
18 16
19 shouldThrow('canvas.drawFocusIfNeeded(null);'); 17 assert_throws(null, function(){canvas.drawFocusIfNeeded(null);});
20 shouldThrow('canvas.drawFocusIfNeeded();'); 18 assert_throws(null, function(){canvas.drawFocusIfNeeded();});
21 19
22 canvas.beginPath(); 20 canvas.beginPath();
23 canvas.rect(50, 50, 200, 100); 21 canvas.rect(50, 50, 200, 100);
24 canvas.fillStyle = "#ccf"; 22 canvas.fillStyle = "#ccf";
25 canvas.fill(); 23 canvas.fill();
26 // re-test null case after having defined a path (regression test for crbug.com/ 353248) 24 // re-test null case after having defined a path (regression test for crbug. com/353248)
27 shouldThrow('canvas.drawFocusIfNeeded(null);'); 25 assert_throws(null, function(){canvas.drawFocusIfNeeded(null);});
28 canvas.drawFocusIfNeeded(document.getElementById("button1")); 26 canvas.drawFocusIfNeeded(document.getElementById("button1"));
29 27
30 canvas.beginPath(); 28 canvas.beginPath();
31 canvas.rect(50, 200, 200, 100); 29 canvas.rect(50, 200, 200, 100);
32 canvas.fillStyle = "#cfc"; 30 canvas.fillStyle = "#cfc";
33 canvas.fill(); 31 canvas.fill();
34 canvas.drawFocusIfNeeded(document.getElementById("button2")); 32 canvas.drawFocusIfNeeded(document.getElementById("button2"));
35 33
36 // The top rect"s focus ring is tied to button1, which is focused. 34 // 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. 35 // It should have an outline in some color other than the background color.
38 var imageData = canvas.getImageData(49, 50, 1, 1); 36 var imageData = canvas.getImageData(49, 50, 1, 1);
39 var data = imageData.data; 37 var data = imageData.data;
40 shouldBe("data[0] != 0 || data[1] != 0 || data[2] != 0", "true"); 38 assert_true(data[0] != 0 || data[1] != 0 || data[2] != 0);
41 39
42 // The bottom rect"s focus ring is tied to button2, which is not focused. 40 // The bottom rect"s focus ring is tied to button2, which is not focused.
43 imageData = canvas.getImageData(49, 200, 1, 1); 41 imageData = canvas.getImageData(49, 200, 1, 1);
44 data = imageData.data; 42 data = imageData.data;
45 shouldBe("data[0] == 0 && data[1] == 0 && data[2] == 0", "true"); 43 assert_true(data[0] == 0 && data[1] == 0 && data[2] == 0);
44
45 }, 'Canvas test: drawFocusIfNeeded');
46 </script> 46 </script>
47 </body> 47 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698