OLD | NEW |
1 <script src="../../resources/js-test.js"></script> | 1 <script src="../../resources/testharness.js"></script> |
| 2 <script src="../../resources/testharnessreport.js"></script> |
2 <canvas id='c'></canvas> | 3 <canvas id='c'></canvas> |
3 <script> | 4 <script> |
4 // The reason this is implemented as a layout test instead of a unit test (see C
anvasFontCacheTest.cpp) | 5 test(function(t) { |
5 // is to exercise interactions with animation frames. | |
6 | 6 |
7 var cacheLimit = 0; | 7 // The reason this is implemented as a layout test instead of a unit test (s
ee CanvasFontCacheTest.cpp) |
8 if (!window.internals || !window.testRunner) { | 8 // is to exercise interactions with animation frames. |
9 » testFailed('This test requires the window.internals and window.testRunne
r interfaces'); | 9 var cacheLimit = 0; |
10 } else { | 10 cacheLimit = window.internals.canvasFontCacheMaxFonts(); |
11 » cacheLimit = internals.canvasFontCacheMaxFonts(); | 11 requestAnimationFrame(step1); |
12 » testRunner.waitUntilDone(); | 12 |
13 » testRunner.dumpAsText(); | 13 var ctx = document.getElementById('c').getContext('2d'); |
14 » requestAnimationFrame(step1); | 14 |
15 } | 15 function step1() |
16 | 16 { |
17 var ctx = document.getElementById('c').getContext('2d'); | 17 for (var i = 0; i < cacheLimit + 1; i ++) { |
18 | 18 ctx.font = (1 + i) + 'px sans-serif'; |
19 function step1() | 19 ctx.fillText('a', 0, 50); |
20 { | 20 } |
21 » for (var i = 0; i < cacheLimit + 1; i ++) { | 21 assert_true(internals.isInCanvasFontCache(document, "1px sans-serif")); |
22 » » ctx.font = (1 + i) + 'px sans-serif'; | 22 requestAnimationFrame(step2); |
23 » » ctx.fillText('a', 0, 50); | 23 } |
24 » } | 24 |
25 » shouldBeTrue('internals.isInCanvasFontCache(document, "1px sans-serif")'
); | 25 function step2() |
26 » requestAnimationFrame(step2); | 26 { |
27 } | 27 // Pruning of the cache is expected to happen between tasks |
28 | 28 assert_false(internals.isInCanvasFontCache(document, "1px sans-serif")); |
29 function step2() | 29 assert_true(internals.isInCanvasFontCache(document, "2px sans-serif")); |
30 { | 30 } |
31 » // Pruning of the cache is expected to happen between tasks | 31 |
32 » shouldBeFalse('internals.isInCanvasFontCache(document, "1px sans-serif")
'); | 32 }, 'Test that createImageBitmap from a bitmaprenderer canvas produces correct re
sult'); |
33 » shouldBeTrue('internals.isInCanvasFontCache(document, "2px sans-serif")'
); | |
34 » testRunner.notifyDone(); | |
35 } | |
36 | |
37 </script> | 33 </script> |
OLD | NEW |