summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/document-policy/reporting
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/document-policy/reporting')
-rw-r--r--testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html26
-rw-r--r--testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html32
-rw-r--r--testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/image.jpgbin0 -> 2033 bytes
-rw-r--r--testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html26
-rw-r--r--testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html27
-rw-r--r--testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html32
-rw-r--r--testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/oversized.jpgbin0 -> 1655 bytes
-rw-r--r--testing/web-platform/tests/document-policy/reporting/resources/sync-script.js20
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html14
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html28
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html36
-rw-r--r--testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpgbin0 -> 43999 bytes
-rw-r--r--testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html24
-rw-r--r--testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html.headers1
22 files changed, 274 insertions, 0 deletions
diff --git a/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html b/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html
new file mode 100644
index 0000000000..bf17807f4a
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <script>
+var check_report_format = ([reports, observer]) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.body.featureId, "document-write");
+ assert_equals(report.body.disposition, "report");
+};
+
+promise_test(async t => {
+ const report = new Promise(resolve => {
+ new ReportingObserver((reports, observer) => resolve([reports, observer]),
+ {types: ['document-policy-violation']}).observe();
+ });
+ document.write("This should be written into the document");
+ check_report_format(await report);
+}, "Document-write report only mode");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html.headers
new file mode 100644
index 0000000000..924dac8e87
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/document-write-report-only-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy-Report-Only: document-write=?0
diff --git a/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html b/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html
new file mode 100644
index 0000000000..65a584ce19
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <script>
+var t = async_test("Document-write Report Format");
+
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "document-write");
+ assert_equals(report.body.sourceFile, document.location.href);
+ assert_equals(typeof report.body.lineNumber, "number");
+ assert_equals(typeof report.body.columnNumber, "number");
+ assert_equals(report.body.disposition, "enforce");
+};
+
+new ReportingObserver(t.step_func_done(check_report_format),
+ {types: ['document-policy-violation']}).observe();
+
+t.step_func(() => {
+ assert_throws_dom('NotAllowedError',
+ () => document.write("This should not succeed"),
+ "document.write should throw an exception when disabled");
+})();
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html.headers
new file mode 100644
index 0000000000..6d05e969b5
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/document-write-reporting-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: document-write=?0
diff --git a/testing/web-platform/tests/document-policy/reporting/image.jpg b/testing/web-platform/tests/document-policy/reporting/image.jpg
new file mode 100644
index 0000000000..c059b96d97
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/image.jpg
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html
new file mode 100644
index 0000000000..85e1349a19
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <script>
+var image = new Image();
+image.src = "./unoptimized-image.jpg";
+
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "lossy-images-max-bpp");
+ assert_equals(report.body.disposition, "enforce");
+};
+
+async_test(t => {
+ new ReportingObserver(t.step_func_done(check_report_format),
+ {types: ['document-policy-violation'], buffered: true}).observe();
+}, "unoptimized-images Report Format");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html.headers
new file mode 100644
index 0000000000..cb28d40ec1
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-onload-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: lossy-images-max-bpp=0.5
diff --git a/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html
new file mode 100644
index 0000000000..b6876f4880
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <img src="./unoptimized-image.jpg">
+ <script>
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "lossy-images-max-bpp");
+ assert_equals(report.body.disposition, "enforce");
+ assert_equals(report.body.sourceFile, document.getElementsByTagName('img')[0].src);
+ assert_equals(report.body.lineNumber, null);
+ assert_equals(report.body.columnNumber, null);
+};
+
+async_test(t => {
+ new ReportingObserver(t.step_func_done(check_report_format),
+ {types: ['document-policy-violation'], buffered: true}).observe();
+}, "unoptimized-images Report Format");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html.headers
new file mode 100644
index 0000000000..cb28d40ec1
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: lossy-images-max-bpp=0.5
diff --git a/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html
new file mode 100644
index 0000000000..bef7db27a7
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src='../resources/document-policy-report-json.js'></script>
+ </head>
+ <body>
+ <img src="./oversized.jpg" alt="oversized image" width="50" height="50">
+ <script>
+ async_test(t => {
+ new ReportingObserver(
+ t.step_func_done((reports, _) => {
+ assert_greater_than(reports.length, 0);
+ const report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ const rbody = report.body;
+ assert_equals(rbody.featureId, "oversized-images");
+ assert_equals(rbody.sourceFile, document.getElementsByTagName('img')[0].src);
+ assert_equals(rbody.lineNumber, null);
+ assert_equals(rbody.columnNumber, null);
+ check_report_json(reports[0]);
+ }),
+ {types: ['document-policy-violation'], buffered: true}
+ ).observe();
+ },
+ "oversized-images Report Format")
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html.headers
new file mode 100644
index 0000000000..10f5be1c33
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: oversized-images=2.0
diff --git a/testing/web-platform/tests/document-policy/reporting/oversized.jpg b/testing/web-platform/tests/document-policy/reporting/oversized.jpg
new file mode 100644
index 0000000000..497ed770bf
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/oversized.jpg
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/reporting/resources/sync-script.js b/testing/web-platform/tests/document-policy/reporting/resources/sync-script.js
new file mode 100644
index 0000000000..10d582cb0e
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/resources/sync-script.js
@@ -0,0 +1,20 @@
+// This is deliberately split from sync-script-reporting.html so that it will
+// not be blocked by policy, and can actuall be executed.
+
+var t = async_test("Sync-script Report Format");
+
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "sync-script");
+ assert_equals(report.body.sourceFile, null);
+ assert_equals(report.body.lineNumber, null);
+ assert_equals(report.body.columnNumber, null);
+ assert_equals(report.body.disposition, "enforce");
+ check_report_json(report);
+};
+
+new ReportingObserver(t.step_func_done(check_report_format),
+ { types: ['document-policy-violation'],
+ buffered: true}).observe();
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html b/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html
new file mode 100644
index 0000000000..45e1b8fc3c
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script defer src='/resources/testharness.js'></script>
+ <script defer src='/resources/testharnessreport.js'></script>
+ <script defer src='../resources/document-policy-report-json.js'></script>
+ <script defer src="resources/sync-script.js"></script>
+ </head>
+ <body>
+ <!-- The presence of this script will violate the sync-script policy,
+ and will trigger a report. -->
+ <script>var newGlobal = true;</script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html.headers b/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html.headers
new file mode 100644
index 0000000000..cfe200c27b
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-script-reporting.html.headers
@@ -0,0 +1 @@
+Document-Policy: sync-script=?0
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html b/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html
new file mode 100644
index 0000000000..a68cf713ee
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <script>
+const check_report_format = ([reports, observer]) => {
+ const report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.body.featureId, "sync-xhr");
+ assert_equals(report.body.disposition, "report");
+};
+
+promise_test(async t => {
+ const report = new Promise(resolve => {
+ new ReportingObserver((reports, observer) => resolve([reports, observer]),
+ {types: ['document-policy-violation']}).observe();
+ });
+ const xhr = new XMLHttpRequest();
+ xhr.open("GET", document.location.href, false);
+ xhr.send();
+ check_report_format(await report);
+}, "Sync-xhr report only mode");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html.headers b/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html.headers
new file mode 100644
index 0000000000..8de201c750
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-xhr-report-only.html.headers
@@ -0,0 +1 @@
+Document-Policy-Report-Only: sync-xhr=?0
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html b/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html
new file mode 100644
index 0000000000..3bcb63459d
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src='../resources/document-policy-report-json.js'></script>
+ </head>
+ <body>
+ <script>
+var t = async_test("Sync-xhr Report Format");
+
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "sync-xhr");
+ assert_equals(report.body.sourceFile, document.location.href);
+ assert_equals(typeof report.body.lineNumber, "number");
+ assert_equals(typeof report.body.columnNumber, "number");
+ assert_equals(report.body.disposition, "enforce");
+ check_report_json(report);
+};
+
+new ReportingObserver(t.step_func_done(check_report_format),
+ {types: ['document-policy-violation']}).observe();
+
+t.step_func(() => {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", document.location.href, false);
+ assert_throws_dom('NetworkError',
+ () => xhr.send(),
+ "Synchronous XHR.send should throw an exception when disabled");
+})();
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html.headers b/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html.headers
new file mode 100644
index 0000000000..ab319fc4ce
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/sync-xhr-reporting.html.headers
@@ -0,0 +1 @@
+Document-Policy: sync-xhr=?0
diff --git a/testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpg b/testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpg
new file mode 100644
index 0000000000..599137a55d
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpg
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html b/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html
new file mode 100644
index 0000000000..47a3643646
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <img src="image.jpg">
+ <script>
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "document-policy-violation");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.featureId, "unsized-media");
+ assert_equals(report.body.disposition, "enforce");
+};
+
+async_test(t => {
+ new ReportingObserver(t.step_func_done(check_report_format),
+ {types: ['document-policy-violation'], buffered: true}).observe();
+}, "Unsized-media Report Format");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html.headers b/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html.headers
new file mode 100644
index 0000000000..cf59933e8d
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unsized-media-reporting-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: unsized-media=?0