Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-basic-blocked-error-event.html

Issue 1049513003: Add error dispatch events to SVGStyleElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Nits Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Style element has error on bad style nonce</title> 4 <title>Style element has error on bad style nonce</title>
5 <meta http-equiv="Content-Security-Policy" content="style-src 'nonce-nonceyn once'"> 5 <meta http-equiv="Content-Security-Policy" content="style-src 'nonce-nonceyn once'">
6 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testharnessreport.js"></script>
8 <script> 8 <script>
9 function verifyStep1() {
10 var color = window.getComputedStyle(document.querySelector('p')).col or;
11 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i s still green after initial style.");
12 }
13
14 function setupStep2() {
15 var sty = document.createElement("style");
16 sty.nonce = "notavalidnonce";
17 sty.innerHTML = "p { color: red; }";
18 sty.onerror = styleError;
19 document.body.appendChild(sty);
20 }
21 function verifyStep2() {
22 var color = window.getComputedStyle(document.querySelector('p')).col or;
23 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i s still green after inserted style.");
24 }
25
26 function setupStep3() {
27 var e = document.getElementById('style1');
28 e.innerHTML = "p { color: blue; }";
29 }
30 function verifyStep3() {
31 var color = window.getComputedStyle(document.querySelector('p')).col or;
32 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i s still green after changing style.");
33 test.done();
34 }
35
36 var verifySteps = [ verifyStep1, verifyStep2, verifyStep3 ];
37 var setupSteps = [ setupStep2, setupStep3 ];
38
39 var test = async_test("Test that paragraph remains green and error event s received.");
40
9 function styleError() { 41 function styleError() {
10 var color = window.getComputedStyle(document.querySelector('p')).col or; 42 test.step(function() {
11 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i s still green."); 43 verifySteps.shift()();
12 done(); 44 var nextSetup = setupSteps.shift();
45 if (nextSetup)
46 nextSetup();
47 });
13 } 48 }
14 </script> 49 </script>
50 </head>
51 <body>
15 <style nonce="nonceynonce">p { color: green; }</style> 52 <style nonce="nonceynonce">p { color: green; }</style>
16 <style nonce="notavalidnonce" onerror="styleError();">p { color: red; }</sty le> 53 <style id="style1" nonce="notavalidnonce" onerror="styleError();">p { color: red; }</style>
17 </head>
18 <p>A test paragraph</p> 54 <p>A test paragraph</p>
55 </body>
19 </html> 56 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698