-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mistakes in trusted-types*reporting tests. #50098
Conversation
* 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
@@ -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 */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current behavior is broken, see commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah apologies yeah that makes sense.
@@ -6,6 +6,11 @@ | |||
<script src="/content-security-policy/support/testharness-helper.js"></script> | |||
</head> | |||
<body> | |||
<!-- Some elements for the tests to act on. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this cause a problem when running them? LGTM either way, just trying to understand the why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I noticed some flakiness in firefox after implementing svg href due to that. actually it seems there used to be a flakiness in chromium too (will remove that comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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]
wpt/resources/testharness.js
Line 2391 in 070a67f
[2]
wpt/resources/testharness.js
Line 4544 in 070a67f