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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-textMetrics-width.html

Issue 2232243002: Rewrite canvas/philip/tests/2d.text.draw.text.metrics.html test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: needs to be a async_test Created 4 years, 4 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
(Empty)
1 <!DOCTYPE html>
2 <head>
3 <style>
4 @font-face {
5 font-family: Ahem;
6 src: url('../../resources/Ahem.ttf');
7 }
8 </style>
9 </head>
10 <body>
11 <p>On success, the red text "Hello World" should be tightly contained inside the two thin red lines.</p>
12 <canvas id="canvas" width="300" height="50"></canvas>
13 <script>
14 if (window.testRunner)
15 testRunner.dumpAsTextWithPixelResults();
16
17 var canvas = document.getElementById('canvas');
18 var ctx = canvas.getContext('2d');
19 var text = "Hello World";
20 ctx.font = "50px Ahem";
21 ctx.fillStyle = '#FF0000';
22 ctx.textBaseline = "top";
23 ctx.fillText(text, 1, 0);
24 var textMetrics = ctx.measureText(text);
25 ctx.fillRect(0, 0, 1, 50);
26 ctx.fillRect(Math.ceil(textMetrics.width), 0, 1, 50);
27 </script>
28 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698