[Document Policy] Isolate font-display wpt tests
This CL splits font-display tests into smaller individual tests. The
split has following benefits:
- Clear obstable for implementation of violation report deduplication
- Make the tests stricter. Before the test can verify there are
4 violation reports generated, but cannot tell which 4 cases generate
violation reports.
Previously there was an attempt on isolating tests into subframes
(https://chromium-review.googlesource.com/c/chromium/src/+/2227863),
but failed due to flaky crash in network cache (crbug.com/1087277).
Bug: 1087277
Change-Id: Ifad35b40d112956fb00fd680b329e539a8762ed9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405916
Commit-Queue: Charlie Hu <chenleihu@google.com>
Reviewed-by: Jason Chase <chasej@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807589}
diff --git a/third_party/blink/web_tests/android/ChromiumWPTExpectations b/third_party/blink/web_tests/android/ChromiumWPTExpectations
index d136ed1..ca1d71c 100644
--- a/third_party/blink/web_tests/android/ChromiumWPTExpectations
+++ b/third_party/blink/web_tests/android/ChromiumWPTExpectations
@@ -1566,8 +1566,14 @@
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/unsized-media.tentative.https.sub.html [ Failure ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html [ Timeout ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html [ Timeout ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-swap.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-swap.tentative.html [ Failure ]
crbug.com/1050754 external/wpt/document-policy/reporting/oversized-images-reporting-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html [ Timeout ]
diff --git a/third_party/blink/web_tests/android/WeblayerWPTExpectations b/third_party/blink/web_tests/android/WeblayerWPTExpectations
index c2c9d278..d7f5be4 100644
--- a/third_party/blink/web_tests/android/WeblayerWPTExpectations
+++ b/third_party/blink/web_tests/android/WeblayerWPTExpectations
@@ -1475,8 +1475,14 @@
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/unsized-media.tentative.https.sub.html [ Failure ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html [ Timeout ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html [ Timeout ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-swap.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-swap.tentative.html [ Failure ]
crbug.com/1050754 external/wpt/document-policy/reporting/oversized-images-reporting-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html [ Timeout ]
diff --git a/third_party/blink/web_tests/android/WebviewWPTExpectations b/third_party/blink/web_tests/android/WebviewWPTExpectations
index c8ab373b..e67a92f 100644
--- a/third_party/blink/web_tests/android/WebviewWPTExpectations
+++ b/third_party/blink/web_tests/android/WebviewWPTExpectations
@@ -1599,8 +1599,14 @@
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/experimental-features/unsized-media.tentative.https.sub.html [ Failure ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html [ Timeout ]
-crbug.com/1050754 external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html [ Timeout ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/reporting-swap.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-blank.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-auto.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-block.tentative.html [ Failure ]
+crbug.com/1050754 external/wpt/document-policy/font-display/report-only-swap.tentative.html [ Failure ]
crbug.com/1050754 external/wpt/document-policy/reporting/oversized-images-reporting-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html [ Timeout ]
crbug.com/1050754 external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html [ Timeout ]
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html
deleted file mode 100644
index 03fa5b68..0000000
--- a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Test for font-display-late-swap feature policy set to report-only</title>
- <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/testharnessreport.js'></script>
- <style>
- </style>
- </head>
- <body>
- <p>
- Tests if the correct number of violation reports are generated and each report corresponds to this feature.
- 4 reports should be created out of the 6 options below (reports for all except for 'fallback' and 'optional').
- </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. => {
- 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);
-}
-
-let reportCounter = 4;
-let t = async_test('font-display-late-swap Report Format');
-
-let check_report_format = (reports, observer) => {
- reportCounter -= reports.length;
- for (let report of reports) {
- assert_equals(report.type, 'document-policy-violation');
- assert_equals(report.url, document.location.href, 'Report URL');
- assert_equals(report.body.featureId, 'font-display-late-swap');
- assert_equals(report.body.disposition, 'report');
- assert_true('sourceFile' in report.body);
- assert_true('lineNumber' in report.body);
- assert_true('columnNumber' in report.body);
- }
- // Test is done when we have exactly 4 reports for the following
- // font-display values: not set, 'auto', 'block', 'swap'
- if (reportCounter == 0) t.done();
-};
-
-new ReportingObserver(t.step_func(check_report_format),
- {types: ['document-policy-violation'], buffered: true}).observe();
- </script>
- </body>
-</html>
\ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html
deleted file mode 100644
index db871d1..0000000
--- a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Test for font-display-late-swap feature policy set to reporting</title>
- <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/testharnessreport.js'></script>
- <style>
- </style>
- </head>
- <body>
- <p>
- Tests if the correct number of violation reports are generated and each report corresponds to this feature.
- 4 reports should be created out of the 6 options below (reports for all except for 'fallback' and 'optional').
- </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. => {
- 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);
-}
-
-let reportCounter = 4;
-let t = async_test('font-display-late-swap Report Format');
-
-let check_report_format = (reports, observer) => {
- reportCounter -= reports.length;
- for (let report of reports) {
- assert_equals(report.type, 'document-policy-violation');
- assert_equals(report.url, document.location.href, 'Report URL');
- assert_equals(report.body.featureId, 'font-display-late-swap');
- assert_equals(report.body.disposition, 'enforce');
- assert_true('sourceFile' in report.body);
- assert_true('lineNumber' in report.body);
- assert_true('columnNumber' in report.body);
- }
- // Test is done when we have exactly 4 reports for the following
- // font-display values: not set, 'auto', 'block', 'swap'
- if (reportCounter == 0) t.done();
-};
-
-new ReportingObserver(t.step_func(check_report_format),
- {types: ['document-policy-violation'], buffered: true}).observe();
- </script>
- </body>
-</html>
\ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative-ref.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative-ref.html
similarity index 100%
rename from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative-ref.html
rename to third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative-ref.html
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative.html
similarity index 94%
rename from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html
rename to third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative.html
index cad4c18..26927bb 100644
--- a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative.html
@@ -2,7 +2,7 @@
<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">
+<link rel="match" href="override-to-optional.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>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative.html.headers
similarity index 100%
rename from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-01.tentative.html.headers
rename to third_party/blink/web_tests/external/wpt/document-policy/font-display/override-to-optional.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-auto.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-auto.tentative.html
new file mode 100644
index 0000000..9eea350
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-auto.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'auto'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyReportOnlyGenerated('auto');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-auto.tentative.html.headers
similarity index 100%
rename from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
rename to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-auto.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-blank.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-blank.tentative.html
new file mode 100644
index 0000000..628dbcc
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-blank.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value empty</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyReportOnlyGenerated('');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-blank.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-blank.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-block.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-block.tentative.html
new file mode 100644
index 0000000..a383695
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-block.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'block'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyReportOnlyGenerated('block');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-block.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-block.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-fallback.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-fallback.tentative.html
new file mode 100644
index 0000000..a03015e
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-fallback.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'fallback'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testCompliantWithFontDisplayPolicy('fallback');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-fallback.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-fallback.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-optional.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-optional.tentative.html
new file mode 100644
index 0000000..2a4673f
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-optional.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'optional'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testCompliantWithFontDisplayPolicy('optional');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-optional.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-optional.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-swap.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-swap.tentative.html
new file mode 100644
index 0000000..ad1f437
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-swap.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'swap'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyReportOnlyGenerated('swap');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-swap.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-report-only.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/report-only-swap.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-auto.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-auto.tentative.html
new file mode 100644
index 0000000..01857dd
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-auto.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'auto'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyViolationGenerated('auto');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-auto.tentative.html.headers
similarity index 100%
rename from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
rename to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-auto.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-blank.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-blank.tentative.html
new file mode 100644
index 0000000..6521ae1
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-blank.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value empty</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyViolationGenerated('');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-blank.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-blank.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-block.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-block.tentative.html
new file mode 100644
index 0000000..60403c6
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-block.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'block'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyViolationGenerated('block');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-block.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-block.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-fallback.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-fallback.tentative.html
new file mode 100644
index 0000000..a03015e
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-fallback.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'fallback'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testCompliantWithFontDisplayPolicy('fallback');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-fallback.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-fallback.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-optional.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-optional.tentative.html
new file mode 100644
index 0000000..2a4673f
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-optional.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'optional'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testCompliantWithFontDisplayPolicy('optional');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-optional.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-optional.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-swap.tentative.html b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-swap.tentative.html
new file mode 100644
index 0000000..53d823f
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-swap.tentative.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap document policy with font display value 'swap'</title>
+<link rel="help" href="https://github.com/w3c/webappsec-permissions-policy/blob/master/policies/font-display-late-swap.md">
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='resources/font-display-reporting-helper.js'></script>
+<script>
+ testFontDisplayPolicyViolationGenerated('swap');
+</script>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-swap.tentative.html.headers
similarity index 100%
copy from third_party/blink/web_tests/external/wpt/document-policy/font-display/font-display-document-policy-reporting.tentative.html.headers
copy to third_party/blink/web_tests/external/wpt/document-policy/font-display/reporting-swap.tentative.html.headers
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/font-display/resources/font-display-reporting-helper.js b/third_party/blink/web_tests/external/wpt/document-policy/font-display/resources/font-display-reporting-helper.js
new file mode 100644
index 0000000..f3c8a22
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/document-policy/font-display/resources/font-display-reporting-helper.js
@@ -0,0 +1,81 @@
+function check_report_format(report, expected_url, expected_disposition) {
+ assert_equals(report.type, 'document-policy-violation');
+ assert_equals(report.url, expected_url);
+ assert_equals(report.body.featureId, 'font-display-late-swap');
+ assert_equals(report.body.disposition, expected_disposition);
+ assert_true('sourceFile' in report.body);
+ assert_true('lineNumber' in report.body);
+ assert_true('columnNumber' in report.body);
+}
+
+function check_violation_report_format(report, expected_url) {
+ check_report_format(report, expected_url, 'enforce');
+}
+
+function check_report_only_report_format(report, expected_url) {
+ check_report_format(report, expected_url, 'report');
+}
+
+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}; }`;
+}
+
+/**
+ * Run font-display test with given parameters.
+ *
+ * A violation report is expected with fontDisplayValue set to
+ * ['', 'auto', 'block', 'swap']
+ *
+ * No violation report is expected with fontDisplayValue set to
+ * ['fallback', 'optional']
+
+ * @param {String} fontDisplayValue
+ * @param {(Report, String) => () | undefined} format_check pass a callback to
+ * check report format if a violation report is expected. If no report is
+ * expected to be generated, leave this argument undefined.
+ */
+function runTest(fontDisplayValue, format_check) {
+ window. => {
+ const family = fontDisplayValue + '-face';
+ const rule = makeFontFaceDeclaration(family, fontDisplayValue);
+
+ const style = document.createElement('style');
+ style.innerHTML = rule;
+ document.body.appendChild(style);
+
+ const div = document.createElement('div');
+ div.textContent = 'a';
+ div.style.fontFamily = family + ', Arial';
+ document.body.appendChild(div);
+ };
+
+ const t = async_test('font-display-late-swap Report Format');
+
+ new ReportingObserver(
+ t.step_func_done((reports, _) => {
+ assert_equals(reports.length, 1);
+ assert_true(!!format_check);
+ format_check(reports[0], document.location.href);
+ }), {
+ types: ['document-policy-violation'],
+ buffered: true
+ }
+ ).observe();
+
+ t.step_timeout(t.step_func_done(() => {
+ assert_false(!!format_check, 'Expected violation report but did not get one.');
+ }), 400); // 400ms should be sufficient to observe the violation report.
+}
+
+function testFontDisplayPolicyViolationGenerated(fontDisplayValue) {
+ runTest(fontDisplayValue, check_violation_report_format);
+}
+
+function testFontDisplayPolicyReportOnlyGenerated(fontDisplayValue) {
+ runTest(fontDisplayValue, check_report_only_report_format);
+}
+
+function testCompliantWithFontDisplayPolicy(fontDisplayValue) {
+ runTest(fontDisplayValue);
+}
\ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/lint.ignore b/third_party/blink/web_tests/external/wpt/lint.ignore
index a3b91f1..457f36f8 100644
--- a/third_party/blink/web_tests/external/wpt/lint.ignore
+++ b/third_party/blink/web_tests/external/wpt/lint.ignore
@@ -302,7 +302,7 @@
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: document-policy/font-display/override-to-optional.tentative.html
SET TIMEOUT: feature-policy/experimental-features/resources/focus-without-user-activation-iframe-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