From a2c185eecb07fb4ceb07339f928d12dccdb909a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Fri, 24 Jan 2025 18:22:05 +0100 Subject: [PATCH] Add more tests for trusted-types-sink violation reports. This covers all Window-only sinks listed in https://github.com/w3c/trusted-types/issues/494#issuecomment-2572763334 This also adds small improvements to csp-violations.js: - Rely on connect-src / EventSource / self.add/removeEventListner, so that the file could be usable in Workers in the future. - Also force a connect-src violation before executing fn, so that we can flush previously reported violations. Although this is not necessary for existing tests, I noticed this can sometimes happen when I was trying to write tests. --- ...icyFactory-createPolicy-cspTests-none.html | 2 +- ...pePolicyFactory-createPolicy-cspTests.html | 2 +- ...trusted-types-for-report-only.html.headers | 2 +- trusted-types/require-trusted-types-for.html | 2 +- trusted-types/support/csp-violations.js | 39 ++++--- ...d-types-eval-reporting-no-unsafe-eval.html | 4 +- ...eval-reporting-no-unsafe-eval.html.headers | 2 +- ...sted-types-eval-reporting-report-only.html | 2 +- ...es-eval-reporting-report-only.html.headers | 2 +- .../trusted-types-eval-reporting.html | 2 +- .../trusted-types-eval-reporting.html.headers | 2 +- .../trusted-types-report-only.html.headers | 2 +- ...porting-for-DOMParser-parseFromString.html | 26 +++++ ...es-reporting-for-Document-execCommand.html | 34 ++++++ ...eporting-for-Document-parseHTMLUnsafe.html | 26 +++++ ...ed-types-reporting-for-Document-write.html | 38 +++++++ ...types-reporting-for-Element-innerHTML.html | 26 +++++ ...orting-for-Element-insertAdjacentHTML.html | 27 +++++ ...types-reporting-for-Element-outerHTML.html | 26 +++++ ...es-reporting-for-Element-setAttribute.html | 107 ++++++++++++++++++ ...s-reporting-for-Element-setHTMLUnsafe.html | 26 +++++ ...eporting-for-HTMLIFrameElement-srcdoc.html | 26 +++++ ...types-reporting-for-HTMLScriptElement.html | 44 +++++++ ...ng-for-Range-createContextualFragment.html | 32 ++++++ ...es-reporting-for-ShadowRoot-innerHTML.html | 29 +++++ ...eporting-for-ShadowRoot-setHTMLUnsafe.html | 29 +++++ trusted-types/trusted-types-reporting.html | 92 +-------------- .../trusted-types-reporting.html.headers | 2 +- .../trusted-types-source-file-path.html | 2 +- .../trusted-types-svg-script-set-href.html | 2 +- trusted-types/trusted-types-svg-script.html | 2 +- 31 files changed, 536 insertions(+), 123 deletions(-) create mode 100644 trusted-types/trusted-types-reporting-for-DOMParser-parseFromString.html create mode 100644 trusted-types/trusted-types-reporting-for-Document-execCommand.html create mode 100644 trusted-types/trusted-types-reporting-for-Document-parseHTMLUnsafe.html create mode 100644 trusted-types/trusted-types-reporting-for-Document-write.html create mode 100644 trusted-types/trusted-types-reporting-for-Element-innerHTML.html create mode 100644 trusted-types/trusted-types-reporting-for-Element-insertAdjacentHTML.html create mode 100644 trusted-types/trusted-types-reporting-for-Element-outerHTML.html create mode 100644 trusted-types/trusted-types-reporting-for-Element-setAttribute.html create mode 100644 trusted-types/trusted-types-reporting-for-Element-setHTMLUnsafe.html create mode 100644 trusted-types/trusted-types-reporting-for-HTMLIFrameElement-srcdoc.html create mode 100644 trusted-types/trusted-types-reporting-for-HTMLScriptElement.html create mode 100644 trusted-types/trusted-types-reporting-for-Range-createContextualFragment.html create mode 100644 trusted-types/trusted-types-reporting-for-ShadowRoot-innerHTML.html create mode 100644 trusted-types/trusted-types-reporting-for-ShadowRoot-setHTMLUnsafe.html diff --git a/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none.html b/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none.html index a75b50f8f002e2..5179206e7e1270 100644 --- a/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none.html +++ b/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none.html @@ -4,7 +4,7 @@ - + - + - + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Document-execCommand.html b/trusted-types/trusted-types-reporting-for-Document-execCommand.html new file mode 100644 index 00000000000000..617c3c18c53231 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Document-execCommand.html @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Document-parseHTMLUnsafe.html b/trusted-types/trusted-types-reporting-for-Document-parseHTMLUnsafe.html new file mode 100644 index 00000000000000..b0b286f733eba5 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Document-parseHTMLUnsafe.html @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Document-write.html b/trusted-types/trusted-types-reporting-for-Document-write.html new file mode 100644 index 00000000000000..b20c458b4a1c6f --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Document-write.html @@ -0,0 +1,38 @@ + + + + + + +
+ + diff --git a/trusted-types/trusted-types-reporting-for-Element-innerHTML.html b/trusted-types/trusted-types-reporting-for-Element-innerHTML.html new file mode 100644 index 00000000000000..5782c689071128 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Element-innerHTML.html @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Element-insertAdjacentHTML.html b/trusted-types/trusted-types-reporting-for-Element-insertAdjacentHTML.html new file mode 100644 index 00000000000000..6448b3f4097af7 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Element-insertAdjacentHTML.html @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Element-outerHTML.html b/trusted-types/trusted-types-reporting-for-Element-outerHTML.html new file mode 100644 index 00000000000000..a5fcb2d24f0482 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Element-outerHTML.html @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Element-setAttribute.html b/trusted-types/trusted-types-reporting-for-Element-setAttribute.html new file mode 100644 index 00000000000000..f0ad7a966f6dbd --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Element-setAttribute.html @@ -0,0 +1,107 @@ + + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Element-setHTMLUnsafe.html b/trusted-types/trusted-types-reporting-for-Element-setHTMLUnsafe.html new file mode 100644 index 00000000000000..41bc4d57b7a936 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Element-setHTMLUnsafe.html @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-HTMLIFrameElement-srcdoc.html b/trusted-types/trusted-types-reporting-for-HTMLIFrameElement-srcdoc.html new file mode 100644 index 00000000000000..b86eb6e6910d18 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-HTMLIFrameElement-srcdoc.html @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-HTMLScriptElement.html b/trusted-types/trusted-types-reporting-for-HTMLScriptElement.html new file mode 100644 index 00000000000000..3c540e8d287d5f --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-HTMLScriptElement.html @@ -0,0 +1,44 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-Range-createContextualFragment.html b/trusted-types/trusted-types-reporting-for-Range-createContextualFragment.html new file mode 100644 index 00000000000000..8f34ba0ed1dfa6 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-Range-createContextualFragment.html @@ -0,0 +1,32 @@ + + + + + + +
+ + diff --git a/trusted-types/trusted-types-reporting-for-ShadowRoot-innerHTML.html b/trusted-types/trusted-types-reporting-for-ShadowRoot-innerHTML.html new file mode 100644 index 00000000000000..9aaf2d8aa4f50d --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-ShadowRoot-innerHTML.html @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting-for-ShadowRoot-setHTMLUnsafe.html b/trusted-types/trusted-types-reporting-for-ShadowRoot-setHTMLUnsafe.html new file mode 100644 index 00000000000000..b65261d0e38180 --- /dev/null +++ b/trusted-types/trusted-types-reporting-for-ShadowRoot-setHTMLUnsafe.html @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/trusted-types/trusted-types-reporting.html b/trusted-types/trusted-types-reporting.html index 2ea5855e054637..1649e46d0d5aa4 100644 --- a/trusted-types/trusted-types-reporting.html +++ b/trusted-types/trusted-types-reporting.html @@ -7,8 +7,6 @@ -
- - + diff --git a/trusted-types/trusted-types-svg-script-set-href.html b/trusted-types/trusted-types-svg-script-set-href.html index f339ba119a1b6b..3092fb41d81f73 100644 --- a/trusted-types/trusted-types-svg-script-set-href.html +++ b/trusted-types/trusted-types-svg-script-set-href.html @@ -6,7 +6,7 @@ - +
diff --git a/trusted-types/trusted-types-svg-script.html b/trusted-types/trusted-types-svg-script.html index 4fc3b710eb620c..c08bdc0db87026 100644 --- a/trusted-types/trusted-types-svg-script.html +++ b/trusted-types/trusted-types-svg-script.html @@ -5,7 +5,7 @@ - +