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

Side by Side Diff: LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-style-blocked.html

Issue 718633002: Deflake http/tests/security/subresourceIntegrity/subresource-integrity-style-blocked.html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix our use of w3 test harness to call done() Created 6 years 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Subresource integrity blocked style resources</title> 4 <title>Subresource integrity blocked style resources</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 6
7 <link rel="stylesheet" href="style-1-of-3.css" integrity="ni:///sha256;B pfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE="></link> 7 <script>
8 <link rel="stylesheet" href="style-2-of-3.css" integrity="ni:///sha384;X VVXBGoYw6AJOh9J/Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr"></link> 8 var steps = 0;
9 <link rel="stylesheet" href="style-3-of-3.css" integrity="ni:///sha512;t bUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAjcHqba5csor DWtKg=="></link> 9 var loaded = 0;
10 var failed = 0;
11
12 function markLoaded() {
13 ++loaded;
14 runNextStep();
15 }
16
17 function markFailed() {
18 ++failed;
19 runNextStep();
20 }
21
22 function insertStylesheetAsLink(cssHref, hash)
23 {
24 var link = document.createElement("link");
25 link.rel = "stylesheet";
26 link.href = cssHref;
27 link.integrity = hash;
28 link.addEventListener('load', markLoaded);
29 link.addEventListener('error', markFailed);
30 document.head.appendChild(link);
31 }
32
33 function runTest()
34 {
35 if (window.testRunner) {
36 testRunner.dumpAsText();
37 testRunner.waitUntilDone();
38 }
39
40 runNextStep();
41 }
42
43 function runNextStep()
44 {
45 switch (++steps) {
46 case 1:
47 insertStylesheetAsLink("style-1-of-3.css", "ni:///sha256;Bpf Bw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=");
48 break;
49 case 2:
50 insertStylesheetAsLink("style-2-of-3.css", "ni:///sha384;XVV XBGoYw6AJOh9J/Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr");
51 break;
52 case 3:
53 insertStylesheetAsLink("style-3-of-3.css", "ni:///sha512;tbU PioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAjcHqba5csorDW tKg==");
54 break;
55 case 4:
56 finishTest();
57 break;
58 }
59 }
60
61 function finishTest()
62 {
63 var color = window.getComputedStyle(document.querySelector('#p1' )).color;
64 assert_not_equals(color, "rgb(0, 128, 0)", "The p#1 element's te xt should not be green.");
65 color = window.getComputedStyle(document.querySelector('#p2')).c olor;
66 assert_not_equals(color, "rgb(0, 128, 0)", "The p#2 element's te xt should not be green.");
67 color = window.getComputedStyle(document.querySelector('#p3')).c olor;
68 assert_not_equals(color, "rgb(0, 128, 0)", "The p#3 element's te xt should not be green.");
69 assert_equals(failed, 3, "All stylesheet loads should have faile d.");
70 assert_equals(loaded, 0, "All stylesheet loads should have faile d.");
71 done();
72 if (window.testRunner)
73 testRunner.notifyDone();
74 }
75 </script>
10 </head> 76 </head>
11 <body> 77 <body onload="runTest()">
12 <script>
13 if (window.testRunner)
14 testRunner.dumpAsText();
15 </script>
16 <p id="p1">Test 1</p> 78 <p id="p1">Test 1</p>
17 <p id="p2">Test 2</p> 79 <p id="p2">Test 2</p>
18 <p id="p3">Test 3</p> 80 <p id="p3">Test 3</p>
19
20 <script>
21 var color = window.getComputedStyle(document.querySelector('#p1')).color ;
22 assert_not_equals(color, "rgb(0, 128, 0)", "The p#1 element's text shoul d not be green.");
23 color = window.getComputedStyle(document.querySelector('#p2')).color;
24 assert_not_equals(color, "rgb(0, 128, 0)", "The p#2 element's text shoul d not be green.");
25 color = window.getComputedStyle(document.querySelector('#p3')).color;
26 assert_not_equals(color, "rgb(0, 128, 0)", "The p#3 element's text shoul d not be green.");
27 </script>
28 </body> 81 </body>
29 </html> 82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698