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

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

Issue 2438033003: [NOT FOR COMMIT] Layout test for WebFonts cache-aware timeout adaption (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display-expected.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display.html b/third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display.html
new file mode 100644
index 0000000000000000000000000000000000000000..5808a678ef2e4609d6130dd7992e2c30b3a7cfde
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<title>Test for font-display @font-face descriptor</title>
+<style>
+td > div {
+ height: 1em;
+ line-height: 1em;
+}
+</style>
+<table id="container">
+ <tr>
+ <th>Callback order</th>
+ <th>auto</th>
+ <th>block</th>
+ <th>swap</th>
+ <th>fallback</th>
+ <th>optional</th>
+ </tr>
+</table>
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+const fontDisplayValues = ['auto', 'block', 'swap', 'fallback', 'optional'];
+const configs = [[],
+ ['short'],
+ ['cacheMiss'],
+ ['short', 'long'],
+ ['short', 'cacheMiss'],
+ ['cacheMiss', 'short'],
+ ['short', 'long', 'cacheMiss'],
+ ['short', 'cacheMiss', 'long'],
+ ['cacheMiss', 'short', 'long']];
+const delayMs = 200;
+const table = document.getElementById('container');
+
+window.onload = () => {
+ for (let finish of [true, false]) {
+ for (let callbackList1 of configs) {
+ const callbackList = callbackList1.slice();
+ if (finish)
+ callbackList.push('finish');
+
+ const tr = document.createElement('tr');
+ const td1 = document.createElement('td');
+ td1.textContent = callbackList.join(' > ');
+ tr.appendChild(td1);
+
+ const url = 'cachable-slow-ahem-loading.cgi' +
+ '?delay=' + (finish ? delayMs : delayMs * 100) +
+ '&x=' + callbackList.join('-');
+ const testObject = window.internals
+ ? window.internals.cacheAwareFontDisplayTest(url)
+ : undefined;
+
+ for (let display of fontDisplayValues) {
+ const family = 'A' + callbackList.join('-') + '-' + display;
+ console.log(family);
+ const rule = '@font-face { font-family: ' + family + '; src: url(' + url + '); font-display: ' + display + '; }';
+ document.styleSheets[0].insertRule(rule, 0);
+ const td = document.createElement('td');
+ td.innerHTML = '<div>a</div>';
+ td.style.fontFamily = family + ', Arial';
+ tr.appendChild(td);
+ }
+ table.appendChild(tr);
+
+ if (testObject) {
+ setTimeout(() => {
+ for (let callback of callbackList) {
+ if (callback == 'short')
+ testObject.fontLoadShortLimitCallback();
+ else if (callback == 'long')
+ testObject.fontLoadLongLimitCallback();
+ else if (callback == 'cacheMiss')
+ testObject.willReloadAfterDiskCacheMiss();
+ }
+ }, delayMs / 2);
+ }
+ }
+ }
+
+ if (window.testRunner)
+ setTimeout(() => { testRunner.notifyDone(); }, delayMs * 5);
+};
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/webfont/cache-aware-font-display-expected.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698