| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script> |
| self.jsTestIsAsync = true; |
| description("This test makes sure that document.fonts.ready always triggers its promise when there are no loads.") |
| if (window.internals) |
| internals.clearMemoryCache(); |
| |
| var counter = 0; |
| function bumpCounter() { |
| counter = counter + 1; |
| if (counter == 4) |
| finishJSTest(); |
| } |
| function failure() { |
| testFailed("Promise should not fail."); |
| } |
| |
| document.fonts.ready.then(bumpCounter); |
| window.addEventListener("DOMContentLoaded", function() { |
| document.fonts.ready.then(bumpCounter, failure); |
| }); |
| window.addEventListener("load", function() { |
| document.fonts.ready.then(bumpCounter, failure); |
| }); |
| shouldBeEqualToString("document.fonts.status", "loaded"); |
| document.fonts.add(new FontFace("WebFont", "url('../../resources/Ahem.ttf') format('truetype')", {})); |
| document.fonts.load("14px WebFont").then(bumpCounter, failure); |
| shouldBeEqualToString("document.fonts.status", "loading"); |
| </script> |
| </head> |
| <body> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |