OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/SubresourceIntegrity.h" | 5 #include "core/frame/SubresourceIntegrity.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/html/HTMLScriptElement.h" | 9 #include "core/html/HTMLScriptElement.h" |
10 #include "platform/Crypto.h" | 10 #include "platform/Crypto.h" |
11 #include "platform/loader/fetch/IntegrityMetadata.h" | 11 #include "platform/loader/fetch/IntegrityMetadata.h" |
12 #include "platform/loader/fetch/RawResource.h" | 12 #include "platform/loader/fetch/RawResource.h" |
13 #include "platform/loader/fetch/Resource.h" | 13 #include "platform/loader/fetch/Resource.h" |
14 #include "platform/weborigin/KURL.h" | 14 #include "platform/weborigin/KURL.h" |
15 #include "platform/weborigin/SecurityOrigin.h" | 15 #include "platform/weborigin/SecurityOrigin.h" |
| 16 #include "platform/wtf/RefPtr.h" |
| 17 #include "platform/wtf/Vector.h" |
| 18 #include "platform/wtf/dtoa/utils.h" |
| 19 #include "platform/wtf/text/WTFString.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "wtf/RefPtr.h" | |
18 #include "wtf/Vector.h" | |
19 #include "wtf/dtoa/utils.h" | |
20 #include "wtf/text/WTFString.h" | |
21 | 21 |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
24 static const char kBasicScript[] = "alert('test');"; | 24 static const char kBasicScript[] = "alert('test');"; |
25 static const char kSha256Integrity[] = | 25 static const char kSha256Integrity[] = |
26 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4="; | 26 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4="; |
27 static const char kSha256IntegrityLenientSyntax[] = | 27 static const char kSha256IntegrityLenientSyntax[] = |
28 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4="; | 28 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4="; |
29 static const char kSha256IntegrityWithEmptyOption[] = | 29 static const char kSha256IntegrityWithEmptyOption[] = |
30 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4=?"; | 30 "sha256-GAF48QOoxRvu0gZAmQivUdJPyBacqznBAXwnkfpmQX4=?"; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 ExpectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, | 527 ExpectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, |
528 strlen(kBasicScript), secure_url, insecure_url); | 528 strlen(kBasicScript), secure_url, insecure_url); |
529 | 529 |
530 ExpectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript), | 530 ExpectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript), |
531 secure_url, insecure_url, kNoCors); | 531 secure_url, insecure_url, kNoCors); |
532 ExpectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, | 532 ExpectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, |
533 strlen(kBasicScript), secure_url, insecure_url); | 533 strlen(kBasicScript), secure_url, insecure_url); |
534 } | 534 } |
535 | 535 |
536 } // namespace blink | 536 } // namespace blink |
OLD | NEW |