1 <script src=
"../../resources/js-test.js"></script>
2 <canvas id='c'
></canvas>
4 // The reason this is implemented as a layout test instead of a unit test (see CanvasFontCacheTest.cpp)
5 // is to exercise interactions with animation frames.
8 if (!window
.internals
|| !window
.testRunner
) {
9 testFailed('This test requires the window.internals and window.testRunner interfaces');
11 cacheLimit
= internals
.canvasFontCacheMaxFonts();
12 testRunner
.waitUntilDone();
13 testRunner
.dumpAsText();
14 requestAnimationFrame(step1
);
17 var ctx
= document
.getElementById('c').getContext('2d');
21 for (var i
= 0; i
< cacheLimit
+ 1; i
++) {
22 ctx
.font
= (1 + i
) + 'px sans-serif';
23 ctx
.fillText('a', 0, 50);
25 shouldBeTrue('internals.isInCanvasFontCache(document, "1px sans-serif")');
26 requestAnimationFrame(step2
);
31 // Pruning of the cache is expected to happen between tasks
32 shouldBeFalse('internals.isInCanvasFontCache(document, "1px sans-serif")');
33 shouldBeTrue('internals.isInCanvasFontCache(document, "2px sans-serif")');
34 testRunner
.notifyDone();