Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html

Issue 1429713004: Implement CSS font-display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html b/third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html
new file mode 100644
index 0000000000000000000000000000000000000000..562e2eaeeef0b714c5cf66a8bdfd2a95fc08fff5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
Yoav Weiss 2015/10/30 17:22:30 It would have been great if this test could have b
Kunihiko Sakamoto 2015/11/02 05:30:16 Ah sorry, I didn't write a high level description
+<style>
+.hidden { display: none; }
+</style>
+<table id="container">
+ <tr>
+ <th>T[sec]</th>
+ <th>delay[sec]</th>
+ <th>auto</th>
+ <th>block</th>
+ <th>swap</th>
+ <th>fallback</th>
+ <th>optional</th>
+ </tr>
+</table>
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+var fontDisplayValues = ['auto', 'block', 'swap', 'fallback', 'optional'];
+var configs = [{time: 0, delay: 1000},
+ {time: 1000, delay: 0},
+ {time: 1000, delay: 500},
+ {time: 1000, delay: 3000},
+ {time: 5000, delay: 2000},
+ {time: 5000, delay: 4000},
+ {time: 5000, delay: 8000}];
+
+function makeFontFaceDeclaration(family, config, display) {
+ var url = '/resources/Ahem.ttf';
+ if (config.delay > 0)
+ url = 'slow-ahem-loading.cgi?delay=' + config.delay + '&t=' + config.time;
+ return '@font-face { font-family: ' + family + '; src: url(' + url + '); font-display: ' + display + '; }';
+}
+
+
+var maxTime = Math.max.apply(null, configs.map((config) => config.time));
+var table = document.getElementById('container');
+
+for (var config of configs) {
eae 2015/11/02 00:56:22 Don't use for in loops for arrays (as per js style
Kunihiko Sakamoto 2015/11/02 05:30:16 Done.
+ var tr = document.createElement('tr');
+ tr.classList.add('hidden');
+ var td1 = document.createElement('td');
+ td1.textContent = config.time / 1000;
+ tr.appendChild(td1);
+ var td2 = document.createElement('td');
+ td2.textContent = config.delay / 1000;
+ tr.appendChild(td2);
+
+ for (var display of fontDisplayValues) {
+ var family = [display, config.time, config.delay].join('-');
+ var rule = makeFontFaceDeclaration(family, config, display);
+ document.styleSheets[0].insertRule(rule, 0);
+ var td = document.createElement('td');
+ td.textContent = 'a';
+ td.style.fontFamily = family + ', Arial';
+ tr.appendChild(td);
+ }
+ table.appendChild(tr);
+ setTimeout((function(tr){tr.classList.remove('hidden')}).bind(null, tr), maxTime - config.time);
+}
+
+if (window.testRunner)
+ setTimeout(function() { testRunner.notifyDone(); }, maxTime);
+</script>

Powered by Google App Engine
This is Rietveld 408576698