-
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
Test hidden nonce
content attribute behavior.
#5423
Conversation
As specified in whatwg/html#2373.
First pass at tests for whatwg/html#2373. What else would y'all like to see, @annevk, @arturjanc, and @zcorpan? |
Notifying @hillbrad. (Learn how reviewing works.) |
This all looks resaonable to me. Wouldn't getComputedStyle be an easier way to test CSS? Or did you specifically want to test that event? It seems with that event you don't know if it failed if the browser decided not to fetch the image for some other reason. |
Firefox (nightly channel)Testing web-platform-tests at revision 91f34f2 All results1 test ran/content-security-policy/script-src/script-nonces-hidden.html
|
Chrome (unstable channel)Testing web-platform-tests at revision 91f34f2 |
Ah, I didn't think about |
These tests are now available on w3c-test.org |
Updated the last test to use |
getComputedStyle forces style resolution, but the loading of background images is not deterministic, so that event might never fire I suppose. |
(Does it fire on time in browsers today?) |
It doesn't. :( I'll drop the event. It's just going to be flaky even if it works, and the |
</style> | ||
<script nonce="abc" id="cssTest"> | ||
async_test(t => { | ||
requestAnimationFrame(t.step_func_done(_ => { |
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.
No need for rAF. Can just make this a sync test()
.
|
||
window.addEventListener('load', t.step_func_done(_ => { | ||
assert_equals(s.nonce, 'abc', "Post-insertion IDL"); | ||
assert_equals(s.getAttribute('nonce'), '', "Post-insertion content"); |
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.
I think the above two should be asserted directly after document.head.appendChild(s);
|
||
window.addEventListener('load', t.step_func_done(_ => { | ||
assert_equals(s.nonce, 'abc'); | ||
assert_equals(s.getAttribute('nonce'), null); |
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.
I think the above two should be asserted directly after document.head.appendChild(s);
async_test(t => { | ||
var s = document.createElement('script'); | ||
s.innerText = script.innerText; | ||
s.nonce = 'abc'; |
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.
Assert pre-insertion IDL and content attribute here?
nonce
content attribute behavior.
For whatwg/html#5300. Supersedes #5423.
Remaining nits now addressed in the other PR. Some were already addressed. |
For whatwg/html#5300. Supersedes #5423
As specified in whatwg/html#2373.