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

Side by Side Diff: LayoutTests/fast/canvas/canvas-set-font-with-updated-style.html

Issue 552053003: CanvasRenderingContext2D should update the render tree to avoid stale computed style. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test added! Created 6 years, 3 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
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-set-font-with-updated-style-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <html>
3 <style>
4 canvas {
5 border: 1px solid black;
6 }
7 .pass {
8 color: green;
9 font-weight: bold;
10 }
11
12 .fail {
13 color: red;
14 font-weight: bold;
15 }
16 </style>
17 <body onload="runTest();">
18 <div>
19 <span>Tests that setting font of Canvas 2d context always uses up-to-date style: <span id="result"></span></span><br>
20 <canvas id="expected"></canvas>
21 <canvas id="actual"></canvas>
22 </div>
23 <script type="text/javascript">
24 if (window.testRunner)
25 testRunner.dumpAsText();
26
27 function drawCanvasText(id, text, forceStyleUpdate)
28 {
29 var canvasElement = document.getElementById(id);
30 var context = canvasElement.getContext('2d');
31 context.font = '20px Arial';
32 context.fillText(id, 0, 20);
33 canvasElement.offsetTop;
34 canvasElement.style.fontSize = '64px';
35
36 if (forceStyleUpdate)
37 canvasElement.offsetTop;
38 context.font = '1em Calibri';
39 context.fillText(text, 0, 100);
40 return context.font;
41 }
42
43 function runTest()
44 {
45 var expectedFontSize = drawCanvasText('expected', 'Some Text', true);
Justin Novosad 2014/09/16 20:58:58 This test does not need a reference canvas. I feel
46 var actualFontSize = drawCanvasText('actual', 'Some Text');
47 var resultElement = document.getElementById('result');
48 var result = expectedFontSize === actualFontSize ? 'PASS' : 'FAIL';
49 resultElement.textContent = result;
50 resultElement.className = (result === 'PASS') ? 'pass' : 'fail';
51 }
52 </script>
53 </body>
54 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-set-font-with-updated-style-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698