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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-load-css-after-failed-integrity.html

Issue 2290983003: CSSStyleSheetResource should cache decoded text instead of raw bytes (Closed)
Patch Set: rebased Created 4 years, 2 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
(Empty)
1 <!DOCTYPE html>
2 <link rel="stylesheet" type="text/css" href="resources/mark-result-red.css" inte grity="sha256-deadbeef">
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <body>
6 <script>
7 function waitForLinkElementToLoad(linkElement) {
8 return new Promise(resolve => {
9 (function waitAgain() {
10 if (linkElement.sheet !== null) {
11 resolve();
12 } else {
13 setTimeout(waitAgain, 100);
14 }
15 })();
16 });
17 }
18
19 promise_test(() => {
20 let link = document.querySelector("link");
21
22 let divResult = document.createElement("div");
23 divResult.id = "result";
24 document.body.appendChild(divResult);
25
26 let divResult2 = document.createElement("div");
27 divResult2.id = "result2";
28 document.body.appendChild(divResult2);
29
30 return new Promise(resolve => {
31 window.addEventListener("load", resolve, {once: true});
32 })
33 .then(() => {
34 assert_equals(getComputedStyle(divResult).color.toString(), "rgb(0, 0, 0)", "bad integrity CSS should not be applied");
35
36 let linkElement = document.querySelector("link");
37 linkElement.removeAttribute("integrity");
38 linkElement.href = "resources/mark-result2-blue.css";
39 return waitForLinkElementToLoad(linkElement);
40 })
41 .then(() => {
42 assert_equals(getComputedStyle(divResult).color.toString(), "rgb(0, 0, 0)", "bad integrity CSS should not be applied");
43 assert_equals(getComputedStyle(divResult2).color.toString(), "rgb(0, 0, 255) ", "CSS w/o integrity check disabled should load on the link element");
44 })
45 .then(() => {
46 document.body.removeChild(divResult);
47 document.body.removeChild(divResult2);
48 });
49 }, 'Link element should still load another CSS after SRI check failed.');
50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698