Commit 05a30b0c authored by Charlie Hu's avatar Charlie Hu Committed by Commit Bot

Migrate font-display to document policy

This CL migrates font-display from feature policy to document policy.

Note: font-display-feature-polcy-01.tentative.html was migrated to document policy in a previous CL(https://chromium-review.googlesource.com/c/chromium/src/+/2017927)

Bug: 993790
Change-Id: Id4c822e0a42594ab75919819e4f1b78ca6a263f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036518
Commit-Queue: Charlie Hu <chenleihu@google.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarIan Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747448}
parent 5dac99c1
...@@ -507,9 +507,6 @@ const FeaturePolicy::FeatureList& FeaturePolicy::GetDefaultFeatureList() { ...@@ -507,9 +507,6 @@ const FeaturePolicy::FeatureList& FeaturePolicy::GetDefaultFeatureList() {
{mojom::FeaturePolicyFeature::kFocusWithoutUserActivation, {mojom::FeaturePolicyFeature::kFocusWithoutUserActivation,
FeatureDefaultValue(FeaturePolicy::FeatureDefault::EnableForAll, FeatureDefaultValue(FeaturePolicy::FeatureDefault::EnableForAll,
mojom::PolicyValueType::kBool)}, mojom::PolicyValueType::kBool)},
{mojom::FeaturePolicyFeature::kFontDisplay,
FeatureDefaultValue(FeaturePolicy::FeatureDefault::EnableForAll,
mojom::PolicyValueType::kBool)},
{mojom::FeaturePolicyFeature::kFormSubmission, {mojom::FeaturePolicyFeature::kFormSubmission,
FeatureDefaultValue(FeaturePolicy::FeatureDefault::EnableForAll, FeatureDefaultValue(FeaturePolicy::FeatureDefault::EnableForAll,
mojom::PolicyValueType::kBool)}, mojom::PolicyValueType::kBool)},
......
...@@ -72,8 +72,6 @@ enum FeaturePolicyFeature { ...@@ -72,8 +72,6 @@ enum FeaturePolicyFeature {
kLayoutAnimations = 30, kLayoutAnimations = 30,
// Controls access to WakeLock // Controls access to WakeLock
kWakeLock = 31, kWakeLock = 31,
// Controls access to font-display attribute in @font-face CSS rule
kFontDisplay = 32,
// These are the defined sandbox features implemented as policy-controlled // These are the defined sandbox features implemented as policy-controlled
// features. // features.
......
...@@ -205,12 +205,12 @@ void RemoteFontFaceSource::UpdatePeriod() { ...@@ -205,12 +205,12 @@ void RemoteFontFaceSource::UpdatePeriod() {
FontDisplay RemoteFontFaceSource::GetFontDisplayWithFeaturePolicyCheck( FontDisplay RemoteFontFaceSource::GetFontDisplayWithFeaturePolicyCheck(
FontDisplay display, FontDisplay display,
const FontSelector* font_selector, const FontSelector* font_selector,
ReportOptions report) const { ReportOptions report_option) const {
ExecutionContext* context = font_selector->GetExecutionContext(); ExecutionContext* context = font_selector->GetExecutionContext();
if (display != kFontDisplayFallback && display != kFontDisplayOptional && if (display != kFontDisplayFallback && display != kFontDisplayOptional &&
context && context->IsDocument() && context && context->IsDocument() &&
!Document::From(context)->IsFeatureEnabled( !context->IsFeatureEnabled(
mojom::blink::FeaturePolicyFeature::kFontDisplay, report)) { mojom::blink::DocumentPolicyFeature::kFontDisplay, report_option)) {
return kFontDisplayOptional; return kFontDisplayOptional;
} }
return display; return display;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
"document-domain" "document-domain"
"document-write" "document-write"
"encrypted-media" "encrypted-media"
"font-display-late-swap"
"forms" "forms"
"fullscreen" "fullscreen"
"geolocation" "geolocation"
......
...@@ -141,11 +141,6 @@ ...@@ -141,11 +141,6 @@
feature_policy_name: "focus-without-user-activation", feature_policy_name: "focus-without-user-activation",
depends_on: ["BlockingFocusWithoutUserActivation"], depends_on: ["BlockingFocusWithoutUserActivation"],
}, },
{
name: "FontDisplay",
feature_policy_name: "font-display-late-swap",
depends_on: ["ExperimentalProductivityFeatures"],
},
{ {
name: "FormSubmission", name: "FormSubmission",
feature_policy_name: "forms", feature_policy_name: "forms",
......
...@@ -6257,7 +6257,6 @@ crbug.com/1006759 http/tests/devtools/modules-load-source.js [ Pass Failure ] ...@@ -6257,7 +6257,6 @@ crbug.com/1006759 http/tests/devtools/modules-load-source.js [ Pass Failure ]
# Failing document policy tests # Failing document policy tests
crbug.com/993790 external/wpt/document-policy/required-policy/separate-document-policies.html [ Failure ] crbug.com/993790 external/wpt/document-policy/required-policy/separate-document-policies.html [ Failure ]
crbug.com/993790 external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html [ Failure ]
crbug.com/993790 http/tests/images/document-policy-unoptimized-lossless-images.php [ Failure ] crbug.com/993790 http/tests/images/document-policy-unoptimized-lossless-images.php [ Failure ]
# Temporary suppression to allow devtools-frontend changes # Temporary suppression to allow devtools-frontend changes
......
<!DOCTYPE html>
<title>Test for font-display-late-swap feature policy behavior when set to reporting</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 font-display-late-swap feature policy behavior when set to reporting</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-feature-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>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title>Test for font-display-late-swap feature policy set to report-only</title> <title>Test for font-display-late-swap feature policy set to report-only</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#reporting"> <link rel="help" href="https://github.com/w3c/webappsec-feature-policy/blob/master/policies/font-display-late-swap.md">
<script src='/resources/testharness.js'></script> <script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script> <script src='/resources/testharnessreport.js'></script>
<style> <style>
...@@ -52,7 +52,7 @@ let t = async_test('font-display-late-swap Report Format'); ...@@ -52,7 +52,7 @@ let t = async_test('font-display-late-swap Report Format');
let check_report_format = (reports, observer) => { let check_report_format = (reports, observer) => {
reportCounter -= reports.length; reportCounter -= reports.length;
for (let report of reports) { for (let report of reports) {
assert_equals(report.type, 'feature-policy-violation'); assert_equals(report.type, 'document-policy-violation');
assert_equals(report.url, document.location.href, 'Report URL'); assert_equals(report.url, document.location.href, 'Report URL');
assert_equals(report.body.featureId, 'font-display-late-swap'); assert_equals(report.body.featureId, 'font-display-late-swap');
assert_equals(report.body.disposition, 'report'); assert_equals(report.body.disposition, 'report');
...@@ -66,7 +66,7 @@ let check_report_format = (reports, observer) => { ...@@ -66,7 +66,7 @@ let check_report_format = (reports, observer) => {
}; };
new ReportingObserver(t.step_func(check_report_format), new ReportingObserver(t.step_func(check_report_format),
{types: ['feature-policy-violation'], buffered: true}).observe(); {types: ['document-policy-violation'], buffered: true}).observe();
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title>Test for font-display-late-swap feature policy set to reporting</title> <title>Test for font-display-late-swap feature policy set to reporting</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#reporting"> <link rel="help" href="https://github.com/w3c/webappsec-feature-policy/blob/master/policies/font-display-late-swap.md">
<script src='/resources/testharness.js'></script> <script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script> <script src='/resources/testharnessreport.js'></script>
<style> <style>
...@@ -52,7 +52,7 @@ let t = async_test('font-display-late-swap Report Format'); ...@@ -52,7 +52,7 @@ let t = async_test('font-display-late-swap Report Format');
let check_report_format = (reports, observer) => { let check_report_format = (reports, observer) => {
reportCounter -= reports.length; reportCounter -= reports.length;
for (let report of reports) { for (let report of reports) {
assert_equals(report.type, 'feature-policy-violation'); assert_equals(report.type, 'document-policy-violation');
assert_equals(report.url, document.location.href, 'Report URL'); assert_equals(report.url, document.location.href, 'Report URL');
assert_equals(report.body.featureId, 'font-display-late-swap'); assert_equals(report.body.featureId, 'font-display-late-swap');
assert_equals(report.body.disposition, 'enforce'); assert_equals(report.body.disposition, 'enforce');
...@@ -66,7 +66,7 @@ let check_report_format = (reports, observer) => { ...@@ -66,7 +66,7 @@ let check_report_format = (reports, observer) => {
}; };
new ReportingObserver(t.step_func(check_report_format), new ReportingObserver(t.step_func(check_report_format),
{types: ['feature-policy-violation'], buffered: true}).observe(); {types: ['document-policy-violation'], buffered: true}).observe();
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -25,7 +25,6 @@ encrypted-media ...@@ -25,7 +25,6 @@ encrypted-media
execution-while-not-rendered execution-while-not-rendered
execution-while-out-of-viewport execution-while-out-of-viewport
focus-without-user-activation focus-without-user-activation
font-display-late-swap
forms forms
fullscreen fullscreen
geolocation geolocation
......
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