Bug 1526592 [wpt PR 15241] - Add violation reporting to font-display feature policy, a=testonly
authorYashar Dabiran <yashard@google.com>
Mon, 18 Feb 2019 19:24:44 +0000
changeset 519168 3baef312efe25c5a6ac8f090555ff0012544afeb
parent 519167 e6028ae2bf9e8f3b48f066a8ad274871e4c0a7c4
child 519169 4b6b8922a59aeed995bb1af9fa180cd7baf74432
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526592, 15241, 1440475, 629344
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526592 [wpt PR 15241] - Add violation reporting to font-display feature policy, a=testonly Automatic update from web-platform-tests Add violation reporting to font-display feature policy Change-Id: Ia9f5cb1ee78a6c9071db70c992b8c2d1d3fa8e2a Reviewed-on: https://chromium-review.googlesource.com/c/1440475 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Ian Clelland <iclelland@chromium.org> Commit-Queue: Yashar Dabiran <yashard@google.com> Cr-Commit-Position: refs/heads/master@{#629344} -- wpt-commits: 6374b9ac6b3c35667925e83287f650a74015f780 wpt-pr: 15241
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative-ref.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative.html.headers
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative-ref.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative.html.headers
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-report-only.tentative.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-report-only.tentative.html.headers
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-reporting.tentative.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-reporting.tentative.html.headers
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative-ref.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative.html
testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative.html.headers
testing/web-platform/tests/lint.whitelist
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap feature policy behavior when set to reporting</title>
+<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>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative.html
@@ -0,0 +1,46 @@
+<!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>
rename from testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative.html.headers
rename to testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-01.tentative.html.headers
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<title>Test for font-display-late-swap feature policy behavior when set to report-only</title>
+<style>
+.ahem {
+  font-family: 'Ahem';
+}
+.arial {
+  font-family: 'Arial';
+}
+</style>
+<p>None of the font-display values should be changed</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="ahem">a</td>
+  <td class="ahem">a</td>
+  <td class="ahem">a</td>
+  <td class="ahem">a</td>
+  <td class="ahem">a</td>
+  <td class="arial">a</td>
+ </tr>
+</table>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<title>Test for font-display-late-swap feature policy behavior when set to report-only</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-02.tentative-ref.html">
+<style>
+</style>
+<p>None of the font-display values should be changed</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>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-02.tentative.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy-Report-Only: font-display-late-swap 'none';
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-report-only.tentative.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <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">
+    <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.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);
+}
+
+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, 'feature-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: ['feature-policy-violation'], buffered: true}).observe();
+    </script>
+  </body>
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-report-only.tentative.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy-Report-Only: font-display-late-swap 'none';
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-reporting.tentative.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <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">
+    <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.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);
+}
+
+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, 'feature-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: ['feature-policy-violation'], buffered: true}).observe();
+    </script>
+  </body>
+</html>
\ No newline at end of file
copy from testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative.html.headers
copy to testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy-reporting.tentative.html.headers
deleted file mode 100644
--- a/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative-ref.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<title>Test for font-display-late-swap feature policy</title>
-<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>
deleted file mode 100644
--- a/testing/web-platform/tests/css/css-fonts/font-display/font-display-feature-policy.tentative.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<title>Test for font-display-late-swap feature policy</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.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>
--- a/testing/web-platform/tests/lint.whitelist
+++ b/testing/web-platform/tests/lint.whitelist
@@ -289,17 +289,18 @@ GENERATE_TESTS: shadow-dom/untriaged/sha
 GENERATE_TESTS: shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/ownerdocument-002.html
 GENERATE_TESTS: shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/window-named-properties-002.html
 GENERATE_TESTS: shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/window-named-properties-003.html
 
 # Intentional use of setTimeout
 SET TIMEOUT: css/css-fonts/font-display/font-display.html
 SET TIMEOUT: css/css-fonts/font-display/font-display-change.html
 SET TIMEOUT: css/css-fonts/font-display/font-display-change-ref.html
-SET TIMEOUT: css/css-fonts/font-display/font-display-feature-policy.tentative.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: html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
 SET TIMEOUT: html/dom/documents/dom-tree-accessors/Document.currentScript.html
 SET TIMEOUT: html/webappapis/timers/*
 SET TIMEOUT: resources/chromium/*
 SET TIMEOUT: resources/test/tests/functional/add_cleanup.html
 SET TIMEOUT: resources/test/tests/functional/add_cleanup_async.html
 SET TIMEOUT: resources/test/tests/functional/add_cleanup_async_rejection.html