OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Test for font-display @font-face descriptor</title> |
| 3 <style> |
| 4 td > div { |
| 5 height: 1em; |
| 6 line-height: 1em; |
| 7 } |
| 8 </style> |
| 9 <table id="container"> |
| 10 <tr> |
| 11 <th>Callback order</th> |
| 12 <th>auto</th> |
| 13 <th>block</th> |
| 14 <th>swap</th> |
| 15 <th>fallback</th> |
| 16 <th>optional</th> |
| 17 </tr> |
| 18 </table> |
| 19 <script> |
| 20 if (window.testRunner) |
| 21 testRunner.waitUntilDone(); |
| 22 |
| 23 const fontDisplayValues = ['auto', 'block', 'swap', 'fallback', 'optional']; |
| 24 const configs = [[], |
| 25 ['short'], |
| 26 ['cacheMiss'], |
| 27 ['short', 'long'], |
| 28 ['short', 'cacheMiss'], |
| 29 ['cacheMiss', 'short'], |
| 30 ['short', 'long', 'cacheMiss'], |
| 31 ['short', 'cacheMiss', 'long'], |
| 32 ['cacheMiss', 'short', 'long']]; |
| 33 const delayMs = 200; |
| 34 const table = document.getElementById('container'); |
| 35 |
| 36 window.onload = () => { |
| 37 for (let finish of [true, false]) { |
| 38 for (let callbackList1 of configs) { |
| 39 const callbackList = callbackList1.slice(); |
| 40 if (finish) |
| 41 callbackList.push('finish'); |
| 42 |
| 43 const tr = document.createElement('tr'); |
| 44 const td1 = document.createElement('td'); |
| 45 td1.textContent = callbackList.join(' > '); |
| 46 tr.appendChild(td1); |
| 47 |
| 48 const url = 'cachable-slow-ahem-loading.cgi' + |
| 49 '?delay=' + (finish ? delayMs : delayMs * 100) + |
| 50 '&x=' + callbackList.join('-'); |
| 51 const testObject = window.internals |
| 52 ? window.internals.cacheAwareFontDisplayTest(url) |
| 53 : undefined; |
| 54 |
| 55 for (let display of fontDisplayValues) { |
| 56 const family = 'A' + callbackList.join('-') + '-' + display; |
| 57 console.log(family); |
| 58 const rule = '@font-face { font-family: ' + family + '; src: url(' + url
+ '); font-display: ' + display + '; }'; |
| 59 document.styleSheets[0].insertRule(rule, 0); |
| 60 const td = document.createElement('td'); |
| 61 td.innerHTML = '<div>a</div>'; |
| 62 td.style.fontFamily = family + ', Arial'; |
| 63 tr.appendChild(td); |
| 64 } |
| 65 table.appendChild(tr); |
| 66 |
| 67 if (testObject) { |
| 68 setTimeout(() => { |
| 69 for (let callback of callbackList) { |
| 70 if (callback == 'short') |
| 71 testObject.fontLoadShortLimitCallback(); |
| 72 else if (callback == 'long') |
| 73 testObject.fontLoadLongLimitCallback(); |
| 74 else if (callback == 'cacheMiss') |
| 75 testObject.willReloadAfterDiskCacheMiss(); |
| 76 } |
| 77 }, delayMs / 2); |
| 78 } |
| 79 } |
| 80 } |
| 81 |
| 82 if (window.testRunner) |
| 83 setTimeout(() => { testRunner.notifyDone(); }, delayMs * 5); |
| 84 }; |
| 85 |
| 86 </script> |
OLD | NEW |