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.
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.
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.
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.
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.