Commit 5f3a2e58 authored by Rodney Ding's avatar Rodney Ding Committed by Commit Bot

wpt tests for Document-Policy font-display

Bug: 998694
Change-Id: I9e7d10b68f4f28311ecb6bfce325c7389b31d148
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2017927Reviewed-by: default avatarIan Clelland <iclelland@chromium.org>
Commit-Queue: Rodney Ding <rodneyding@google.com>
Cr-Commit-Position: refs/heads/master@{#735986}
parent 0f4e4e7e
<!DOCTYPE html>
<title>Test for no-font-display-late-swap document policy behavior</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
.ahem {
font-family: 'Ahem';
}
.arial {
font-family: 'Arial';
}
</style>
<p>Tests if font-display is set to optional for each option except for when it is set to fallback</p>
<table id="container">
<tr>
<th>not-set</th>
<th>auto</th>
<th>block</th>
<th>swap</th>
<th>fallback</th>
<th>optional</th>
</tr>
<tr>
<td class="arial">a</td>
<td class="arial">a</td>
<td class="arial">a</td>
<td class="arial">a</td>
<td class="ahem">a</td>
<td class="arial">a</td>
</tr>
</table>
<!DOCTYPE html>
<html class="reftest-wait">
<title>Test for no-font-display-late-swap document policy behavior</title>
<link rel="help" href="https://github.com/w3c/webappsec-feature-policy/blob/master/policies/font-display-late-swap.md">
<link rel="match" href="font-display-document-policy-01.tentative-ref.html">
<style>
</style>
<p>Tests if font-display is set to optional for each option except for when it is set to fallback</p>
<table id="container">
<tr>
<th>not-set</th>
<th>auto</th>
<th>block</th>
<th>swap</th>
<th>fallback</th>
<th>optional</th>
</tr>
</table>
<script>
const fontDisplayValues = ['', 'auto', 'block', 'swap', 'fallback', 'optional'];
const table = document.getElementById('container');
function makeFontFaceDeclaration(family, display) {
url = '/fonts/Ahem.ttf?pipe=trickle(d1)'; // Before the swap period is over
return '@font-face { font-family: ' + family + '; src: url("' + url + '"); font-display: ' + display + '; }';
}
window.onload = () => {
let tr = document.createElement('tr');
for (let display of fontDisplayValues) {
const family = display + '-face';
const rule = makeFontFaceDeclaration(family, display);
document.styleSheets[0].insertRule(rule, 0);
let td = document.createElement('td');
td.textContent = 'a';
td.style.fontFamily = family + ', Arial';
tr.appendChild(td);
}
table.appendChild(tr);
const timeoutMilliSec = 1500; // After the font is loaded
setTimeout(() => {
document.documentElement.classList.remove("reftest-wait");
}, timeoutMilliSec);
}
</script>
</html>
......@@ -293,6 +293,7 @@ SET TIMEOUT: css/css-fonts/font-display/font-display-change-ref.html
SET TIMEOUT: css/css-fonts/font-display/font-display-feature-policy-01.tentative.html
SET TIMEOUT: css/css-fonts/font-display/font-display-feature-policy-02.tentative.html
SET TIMEOUT: css/css-fonts/font-display/font-display-preload.html
SET TIMEOUT: document-policy/font-display/font-display-document-policy-01.tentative.html
SET TIMEOUT: html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
SET TIMEOUT: html/cross-origin-embedder-policy/resources/navigate-none.sub.html
SET TIMEOUT: html/cross-origin-embedder-policy/resources/navigate-require-corp.sub.html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment