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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-accessibility-test.html

Issue 2679193002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 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>
2 <head> 1 <head>
3 <title>Canvas Hit Regions: accessibility test</title> 2 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
5 </head>
6 <body> 4 <body>
7 <canvas id="canvas"> 5 <canvas id="canvas">
8 <button id="button1"></button> 6 <button id="button1"></button>
9 <div id="container1"> 7 <div id="container1">
10 <button id="button2"></button> 8 <button id="button2"></button>
11 <button id="button3"></button> 9 <button id="button3"></button>
12 </div> 10 </div>
13 <div id="container2"> 11 <div id="container2">
14 <div id="container3"> 12 <div id="container3">
15 <button id="button4"></button> 13 <button id="button4"></button>
16 <button id="button5"></button> 14 <button id="button5"></button>
17 </div> 15 </div>
18 <button id="button6"></button> 16 <button id="button6"></button>
19 </div> 17 </div>
20 </canvas> 18 </canvas>
21 <div id="console"></div>
22 <script> 19 <script>
23 20
24 var canvas = document.getElementById("canvas"); 21 var canvas = document.getElementById("canvas");
25 var context = canvas.getContext("2d"); 22 var context = canvas.getContext("2d");
26 23
27 function drawRectAndAddHitRegion(control, x, y, width, height) { 24 function drawRectAndAddHitRegion(testItem) {
28 if (window.accessibilityController) 25 var control = testItem['control'];
29 window["ax" + control] = accessibilityController.accessibleElementById(con trol); 26 var x = testItem['x'];
27 var y = testItem['y'];
28 var width = testItem['width'];
29 var height = testItem['height'];
30 if (window.accessibilityController)
31 window["ax" + control] = accessibilityController.accessibleElementById(contr ol);
30 32
31 context.beginPath(); 33 context.beginPath();
32 context.rect(x, y, width, height); 34 context.rect(x, y, width, height);
33 context.fill(); 35 context.fill();
34 context.addHitRegion({ 36 context.addHitRegion({
35 id : control, 37 id : control,
36 control : document.getElementById(control) 38 control : document.getElementById(control)
37 }); 39 });
38 } 40 }
39 41
40 function testAccessibilityRect(control, x, y, width, height) { 42 function testAccessibilityRect(testItem) {
43 var control = testItem['control'];
44 var x = testItem['x'];
45 var y = testItem['y'];
46 var width = testItem['width'];
47 var height = testItem['height'];
41 48
42 if (window.accessibilityController && !window["ax" + control]) 49 if (window.accessibilityController && !window["ax" + control])
43 window["ax" + control] = accessibilityController.accessibleElementById(con trol); 50 window["ax" + control] = accessibilityController.accessibleElementById(contr ol);
44 51
45 shouldBe("ax" + control + ".x", x.toString()); 52 assert_equals(eval("ax" + control + ".x"), x);
46 shouldBe("ax" + control + ".y", y.toString()); 53 assert_equals(eval("ax" + control + ".y"), y);
47 shouldBe("ax" + control + ".width", width.toString()); 54 assert_equals(eval("ax" + control + ".width"), width);
48 shouldBe("ax" + control + ".height", height.toString()); 55 assert_equals(eval("ax" + control + ".height"), height);
49 } 56 }
50 57
51 drawRectAndAddHitRegion("button1", 0, 0, 200, 200); 58 var drawRectAndAddHitRegionTests = [
52 drawRectAndAddHitRegion("button2", 0, 0, 100, 50); 59 ['drawRectAndAddHitRegion 1', {control: "button1", x: 0, y: 0, width: 200, hei ght: 200}],
53 drawRectAndAddHitRegion("button3", 40, 20, 50, 70); 60 ['drawRectAndAddHitRegion 2', {control: "button2", x: 0, y: 0, width: 100, hei ght: 50}],
54 drawRectAndAddHitRegion("button4", 0, 0, 100, 50); 61 ['drawRectAndAddHitRegion 3', {control: "button3", x: 40, y: 20, width: 50, he ight: 70}],
55 drawRectAndAddHitRegion("button5", 40, 20, 50, 70); 62 ['drawRectAndAddHitRegion 4', {control: "button4", x: 0, y: 0, width: 100, hei ght: 50}],
56 drawRectAndAddHitRegion("button6", 20, 10, 140, 30); 63 ['drawRectAndAddHitRegion 5', {control: "button5", x: 40, y: 20, width: 50, he ight: 70}],
57 drawRectAndAddHitRegion("button7", 0, 0, 200, 200); 64 ['drawRectAndAddHitRegion 6', {control: "button6", x: 20, y: 10, width: 140, h eight: 30}],
65 ['drawRectAndAddHitRegion 7', {control: "button7", x: 0, y: 0, width: 200, hei ght: 200}],
66 ];
58 67
59 debug("Just one button tests."); 68 var accessibilityRectTests = [
60 testAccessibilityRect("button1", 8, 8, 200, 200); 69 // Just one button tests.
61 debug(""); 70 ['testAccessibilityRect 1', {control: "button1", x: 8, y: 8, width: 200, heigh t: 200}],
71 // The container1 has two buttons.
72 ['testAccessibilityRect 2', {control: "button2", x: 8, y: 8, width: 100, heigh t: 50}],
73 ['testAccessibilityRect 3', {control: "button3", x: 48, y: 28, width: 50, heig ht: 70}],
74 ['testAccessibilityRect 4', {control: "container1", x: 8, y: 8, width: 100, he ight: 90}],
75 // After removing button2 from the container1.
76 ['testAccessibilityRect 5', {control: "container1", x: 48, y: 28, width: 50, h eight: 70}],
77 // Depth-two container tests.
78 ['testAccessibilityRect 6', {control: "button4", x: 8, y: 8, width: 100, heigh t: 50}],
79 ['testAccessibilityRect 7', {control: "button5", x: 48, y: 28, width: 50, heig ht: 70}],
80 ['testAccessibilityRect 8', {control: "button6", x: 28, y: 18, width: 140, hei ght: 30}],
81 ['testAccessibilityRect 9', {control: "container2", x: 8, y: 8, width: 160, he ight: 90}],
82 ['testAccessibilityRect 10', {control: "container3", x: 8, y: 8, width: 100, h eight: 90}],
83 ];
62 84
63 debug("The container1 has two buttons."); 85 generate_tests(drawRectAndAddHitRegion, drawRectAndAddHitRegionTests);
64 testAccessibilityRect("button2", 8, 8, 100, 50);
65 testAccessibilityRect("button3", 48, 28, 50, 70);
66 testAccessibilityRect("container1", 8, 8, 100, 90);
67 debug("");
68 86
69 debug("Remove the button2 from the container1."); 87 generate_tests(testAccessibilityRect, accessibilityRectTests.slice(0,4));
70 document.getElementById("container1").removeChild(document.getElementById("but ton2"));
71 testAccessibilityRect("container1", 48, 28, 50, 70);
72 debug("");
73 88
74 debug("Depth-two container tests."); 89 document.getElementById("container1").removeChild(document.getElementById("butto n2"));
75 testAccessibilityRect("button4", 8, 8, 100, 50); 90 generate_tests(testAccessibilityRect, accessibilityRectTests.slice(4));;
76 testAccessibilityRect("button5", 48, 28, 50, 70);
77 testAccessibilityRect("button6", 28, 18, 140, 30);
78 testAccessibilityRect("container2", 8, 8, 160, 90);
79 testAccessibilityRect("container3", 8, 8, 100, 90);
80 debug("");
81
82 </script> 91 </script>
83 </body> 92 </body>
84 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698