From 8f8dddb7628f2ac3e9e60073f9d1b25bcc457a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Wed, 15 Jan 2025 15:35:45 +0100 Subject: [PATCH 1/2] Fix mistakes in trusted-types*reporting tests. * expect_throws(): move out assert_unreached() out of the try scope. assert_unreached() throws [1] [2] so expect_throws() will not throw in case of failure. * trusted-types-reporting.html: Move the elements before the script to make sure they are already in the DOM when the tests are run. [1] https://github.com/web-platform-tests/wpt/blob/070a67f19da0b454068bc38ef40904403e5edca0/resources/testharness.js#L2391 [2] https://github.com/web-platform-tests/wpt/blob/070a67f19da0b454068bc38ef40904403e5edca0/resources/testharness.js#L4544 --- ...rusted-types-eval-reporting-no-unsafe-eval.html | 3 ++- .../trusted-types-eval-reporting-report-only.html | 3 ++- trusted-types/trusted-types-eval-reporting.html | 3 ++- trusted-types/trusted-types-reporting.html | 14 +++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.html b/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.html index afdd0018cd1479..92604c96718a01 100644 --- a/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.html +++ b/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.html @@ -45,7 +45,8 @@ // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { - try { fn(); assert_unreached(); } catch (err) { /* ignore */ } + try { fn(); } catch (err) { return; /* ignore */ } + assert_unreached(); } // A sample policy we use to test trustedTypes.createPolicy behaviour. diff --git a/trusted-types/trusted-types-eval-reporting-report-only.html b/trusted-types/trusted-types-eval-reporting-report-only.html index 39dba61730ea72..a81f5a45789389 100644 --- a/trusted-types/trusted-types-eval-reporting-report-only.html +++ b/trusted-types/trusted-types-eval-reporting-report-only.html @@ -45,7 +45,8 @@ // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { - try { fn(); assert_unreached(); } catch (err) { /* ignore */ } + try { fn(); } catch (err) { return; /* ignore */ } + assert_unreached(); } // A sample policy we use to test trustedTypes.createPolicy behaviour. diff --git a/trusted-types/trusted-types-eval-reporting.html b/trusted-types/trusted-types-eval-reporting.html index 0f4d406980b24b..e7c7245f9e415e 100644 --- a/trusted-types/trusted-types-eval-reporting.html +++ b/trusted-types/trusted-types-eval-reporting.html @@ -39,7 +39,8 @@ // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { - try { fn(); assert_unreached(); } catch (err) { /* ignore */ } + try { fn(); } catch (err) { return; /* ignore */ } + assert_unreached(); } // A sample policy we use to test trustedTypes.createPolicy behaviour. diff --git a/trusted-types/trusted-types-reporting.html b/trusted-types/trusted-types-reporting.html index 9dbb2141b62f96..662af5f6906a11 100644 --- a/trusted-types/trusted-types-reporting.html +++ b/trusted-types/trusted-types-reporting.html @@ -6,6 +6,11 @@ + +
+ + + - - -
- - - From 08512bc7a43580dc62daf1889003ea817a8e7478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Wed, 15 Jan 2025 15:48:58 +0100 Subject: [PATCH 2/2] also obsolete legacy flaky comment for chromium (probably due to the DOM issue) --- trusted-types/trusted-types-reporting.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/trusted-types/trusted-types-reporting.html b/trusted-types/trusted-types-reporting.html index 662af5f6906a11..96c9dd72813a7b 100644 --- a/trusted-types/trusted-types-reporting.html +++ b/trusted-types/trusted-types-reporting.html @@ -204,9 +204,6 @@ return p; }, "Trusted Type violation report: sample for script innerText assignment"); - // TODO(lyf): https://crbug.com/1066791 Following tests which related to svg - // script element cause a flaky timeout in `linux-blink-rel`, following tests - // should be added back after the bug fix. promise_test(t => { let p = Promise.resolve() .then(promise_violation("require-trusted-types-for 'script'"))