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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-path2d-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> 1 <title>Canvas Hit Regions: path2d test</title>
2 <html> 2 <script src='../../resources/testharness.js'></script>
3 <head> 3 <script src='../../resources/testharnessreport.js'></script>
4 <title>Canvas Hit Regions: path2d test</title>
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body> 4 <body>
8 <canvas id="canvas" width="400" height="400"> 5 <canvas id='canvas' width='400' height='400'>
9 <button id="face"></button> 6 <button id='face'></button>
10 <button id="eyes"></button> 7 <button id='eyes'></button>
11 </canvas> 8 </canvas>
12 9
13 <script src="./resources/canvas-hit-region-event.js"></script> 10 <script src='./resources/canvas-hit-region-event.js'></script>
14 <script> 11 <script>
15 12
16 var canvas = document.getElementById("canvas"); 13 test(function(t) {
17 var context = canvas.getContext("2d"); 14 var canvas = document.getElementById('canvas');
15 var context = canvas.getContext('2d');
18 16
19 var face = new Path2D(); 17 var face = new Path2D();
20 context.fillStyle = "pink"; 18 context.fillStyle = 'pink';
21 face.arc(200, 175, 150, 0, Math.PI * 2, true); 19 face.arc(200, 175, 150, 0, Math.PI * 2, true);
22 context.fill(face); 20 context.fill(face);
23 context.addHitRegion({ id : "face", control : document.getElementById("face"), path : face }); 21 context.addHitRegion({ id : 'face', control : document.getElementById('face'), path : face });
24 22
25 var nose = new Path2D(); 23 var nose = new Path2D();
26 context.fillStyle = "black"; 24 context.fillStyle = 'black';
27 context.globalAlpha = .5; 25 context.globalAlpha = .5;
28 nose.moveTo(200, 165); 26 nose.moveTo(200, 165);
29 nose.lineTo(240, 205); 27 nose.lineTo(240, 205);
30 nose.lineTo(160, 205); 28 nose.lineTo(160, 205);
31 nose.closePath(); 29 nose.closePath();
32 context.fill(nose); 30 context.fill(nose);
33 context.addHitRegion({ id : "nose", path : nose }); 31 context.addHitRegion({ id : 'nose', path : nose });
34 32
35 var mouth = new Path2D(); 33 var mouth = new Path2D();
36 context.fillStyle = "red"; 34 context.fillStyle = 'red';
37 mouth.rect(125, 240, 150, 20); 35 mouth.rect(125, 240, 150, 20);
38 context.fill(mouth); 36 context.fill(mouth);
39 context.addHitRegion({ id : "mouth", path : mouth }); 37 context.addHitRegion({ id : 'mouth', path : mouth });
40 38
41 var eyes = new Path2D(); 39 var eyes = new Path2D();
42 context.globalAlpha = 1; 40 context.globalAlpha = 1;
43 context.fillStyle = "blue"; 41 context.fillStyle = 'blue';
44 eyes.arc(150, 125, 25, 0, Math.PI * 2, true); 42 eyes.arc(150, 125, 25, 0, Math.PI * 2, true);
45 eyes.arc(250, 125, 25, 0, Math.PI * 2, true); 43 eyes.arc(250, 125, 25, 0, Math.PI * 2, true);
46 context.fill(eyes); 44 context.fill(eyes);
47 context.addHitRegion({ id: "eye", control : document.getElementById("eyes"), p ath : eyes }); 45 context.addHitRegion({ id: 'eye', control : document.getElementById('eyes'), p ath : eyes });
48 46
49 debug("Hit detection and mouse event tests"); 47 // Hit detection and mouse event tests');
50 shouldBe("clickCanvas(100, 100)", "'face'"); 48 assert_equals(clickCanvas(100, 100), 'face');
51 shouldBe("clickCanvas(200, 200)", "'nose'"); 49 assert_equals(clickCanvas(200, 200), 'nose');
52 shouldBe("clickCanvas(127, 242)", "'mouth'"); 50 assert_equals(clickCanvas(127, 242), 'mouth');
53 shouldBe("clickCanvas(150, 125)", "'eye'"); 51 assert_equals(clickCanvas(150, 125), 'eye');
54 shouldBe("clickCanvas(250, 125)", "'eye'"); 52 assert_equals(clickCanvas(250, 125), 'eye');
55 shouldBe("clickCanvas(200, 125)", "'face'"); 53 assert_equals(clickCanvas(200, 125), 'face');
56 shouldBe("clickCanvas(20, 10)", "null"); 54 assert_equals(clickCanvas(20, 10), null);
57 debug("");
58 55
56 }, 'Test that createImageBitmap from a bitmaprenderer canvas produces correct re sult');
59 </script> 57 </script>
60 </body> 58 </body>
61 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698