<html> <head> <script src="../../resources/js-test.js"></script> <style> @font-face { font-family: TestFont; src: local('Courier New'); } @font-face { font-family: TestFont; src: url(../../resources/Ahem.ttf); unicode-range: u+61-7a; /* 'a'-'z' */ } </style> <script> description('Test load events for a font family consists of multiple @font-faces.'); window.jsTestIsAsync = true; function runTests() { document.fonts.addEventListener('loading', onLoading); document.fonts.addEventListener('loadingdone', onLoadingDone); document.fonts.ready.then(finish); document.fonts.load('10px TestFont', 'abc'); } var event; var firedEvents = []; function onLoading(e) { firedEvents.push(e.type); } function onLoadingDone(e) { firedEvents.push(e.type); event = e; shouldBe("event.fontfaces.length", "2"); shouldBeEqualToString("event.fontfaces[0].status", "loaded"); shouldBeEqualToString("event.fontfaces[1].status", "loaded"); shouldBeTrue("document.fonts.check('10px TestFont')"); } function onLoadingError(e) { firedEvents.push(e.type); } function finish() { shouldBe("firedEvents", "['loading', 'loadingdone']"); finishJSTest(); } if (document.fonts) runTests(); else { testFailed('document.fonts does not exist'); finishJSTest(); } </script> </head> <body> </body> </html>