| OLD | NEW |
| 1 <html> | 1 <!DOCTYPE html> |
| 2 <head> | |
| 3 <script src="../../js-test-resources/js-test.js"></script> | |
| 4 <style> | 2 <style> |
| 5 @font-face { | 3 @font-face { |
| 6 font-family: 'TestFont'; | 4 font-family: 'TestFont'; |
| 7 src: url(slow-ahem-loading.cgi); | 5 src: url(slow-ahem-loading.cgi); |
| 8 } | 6 } |
| 9 </style> | 7 </style> |
| 8 <style id="RemoveMe"> |
| 9 @font-face { |
| 10 font-family: 'TestFont2'; |
| 11 src: url(slow-ahem-loading.cgi?2); |
| 12 } |
| 13 </style> |
| 14 <script src="../../resources/testharness.js"></script> |
| 15 <script src="../../resources/testharnessreport.js"></script> |
| 10 <script> | 16 <script> |
| 11 description('Test for FontFaceSet.status attribute'); | |
| 12 | 17 |
| 13 window.jsTestIsAsync = true; | 18 promise_test(function(t) { |
| 19 assert_false(document.fonts.check('10px TestFont')); |
| 20 assert_equals(document.fonts.status, "loaded"); |
| 21 var loadPromise = document.fonts.load('10px TestFont'); |
| 22 assert_equals(document.fonts.status, "loading"); |
| 14 | 23 |
| 15 function runTests() { | 24 return loadPromise |
| 16 shouldBeFalse("document.fonts.check('10px TestFont')"); | 25 .then(function() { |
| 17 shouldBeEqualToString("document.fonts.status", "loaded"); | 26 assert_true(document.fonts.check('10px TestFont')); |
| 18 document.fonts.load('10px TestFont').then(onsuccess); | 27 return document.fonts.ready; |
| 19 shouldBeEqualToString("document.fonts.status", "loading"); | 28 }).then(function() { |
| 20 } | 29 assert_equals(document.fonts.status, "loaded"); |
| 30 }); |
| 31 }, 'FontFaceSet.status attribute'); |
| 21 | 32 |
| 22 function onsuccess() { | 33 promise_test(function(t) { |
| 23 shouldBeTrue("document.fonts.check('10px TestFont')"); | 34 document.fonts.load('10px TestFont2'); |
| 24 document.fonts.ready.then(onFontsReady); | 35 assert_equals(document.fonts.status, "loading"); |
| 25 } | 36 var style = document.getElementById('RemoveMe'); |
| 37 style.parentNode.removeChild(style); |
| 26 | 38 |
| 27 function onFontsReady() { | 39 return document.fonts.ready |
| 28 shouldBeEqualToString("document.fonts.status", "loaded"); | 40 .then(function() { |
| 29 finishJSTest(); | 41 assert_equals(document.fonts.status, "loaded"); |
| 30 } | 42 }); |
| 43 }, 'Removing @font-face while loading'); |
| 31 | 44 |
| 32 if (document.fonts) | |
| 33 runTests(); | |
| 34 else { | |
| 35 testFailed('document.fonts does not exist'); | |
| 36 finishJSTest(); | |
| 37 } | |
| 38 </script> | 45 </script> |
| 39 </head> | |
| 40 <body> | |
| 41 </body> | |
| 42 </html> | |
| OLD | NEW |