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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-text-ideographic-space.html

Issue 2695963004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Fixing canvas-text-ideographic-space.html to pass on Mac trybots 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 <meta charcode="utf-16">
2 <html> 2 <script src="../../resources/testharness.js"></script>
3 <head> 3 <script src="../../resources/testharnessreport.js"></script>
4 <meta charcode="utf-16"> 4 <style>
5 <script src="../../resources/js-test.js"></script>
6 <style>
7
8 span { 5 span {
9 padding : 0px; 6 padding : 0px;
10 font-size : 12px; 7 font-size : 12px;
11 font-family : Arial; 8 font-family : Arial;
12 display : inline; 9 display : inline;
13 } 10 }
11 </style>
12 <body>
13 <div><span>a&#x3000;b&#x3000;c</span></div>
14 <div><canvas></canvas></div>
15
16 <script>
17 var PIXEL_RATIO = (function () {
18 var ctx = document.createElement("canvas").getContext("2d"),
19 dpr = window.devicePixelRatio || 1,
20 bsr = ctx.webkitBackingStorePixelRatio ||
21 ctx.mozBackingStorePixelRatio ||
22 ctx.msBackingStorePixelRatio ||
23 ctx.oBackingStorePixelRatio ||
24 ctx.backingStorePixelRatio || 1;
14 25
15 </style> 26 return dpr / bsr;
16 </head> 27 })();
17 <body>
18 <div><span>a&#x3000;b&#x3000;c</span></div>
19 <div><canvas></canvas></div>
20 <script>
21 28
29
30 test(function(t) {
22 var canvas = document.querySelector("canvas"); 31 var canvas = document.querySelector("canvas");
32 canvas.width = 300 * PIXEL_RATIO;
33 canvas.height = 150 * PIXEL_RATIO;
34 canvas.style.width = 300 + "px";
35 canvas.style.height = 150 + "px";
36 canvas.getContext("2d").setTransform(PIXEL_RATIO, 0, 0, PIXEL_RATIO, 0, 0);
37
23 var context = canvas.getContext("2d"); 38 var context = canvas.getContext("2d");
24 var span = document.querySelector("span"); 39 var span = document.querySelector("span");
25 40
26 var abc = 'a' + '\u3000' + 'b' + '\u3000' + 'c'; 41 var abc = 'a' + '\u3000' + 'b' + '\u3000' + 'c';
27 context.font = "12px Arial"; 42 context.font = "12px Arial";
28 context.fillText(abc, 0, 20); 43 context.fillText(abc, 0, 20);
29 44
30 spanWidth = span.offsetWidth; 45 spanWidth = span.offsetWidth;
31 canvasWidth = context.measureText(abc).width; 46 canvasWidth = context.measureText(abc).width;
32 shouldBeTrue("spanWidth == canvasWidth"); 47 assert_approx_equals(spanWidth, canvasWidth, 0.999);
48 }, 'Test canvas text ideographic space.');
49 </script>
50 </body>
33 51
34 </script>
35 </body>
36 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698