| 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" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 EXPECT_EQ(expectedAlgorithm, metadata.algorithm()); | 134 EXPECT_EQ(expectedAlgorithm, metadata.algorithm()); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 void expectParseMultipleHashes( | 138 void expectParseMultipleHashes( |
| 139 const char* integrityAttribute, | 139 const char* integrityAttribute, |
| 140 const IntegrityMetadata expectedMetadataArray[], | 140 const IntegrityMetadata expectedMetadataArray[], |
| 141 size_t expectedMetadataArraySize) { | 141 size_t expectedMetadataArraySize) { |
| 142 IntegrityMetadataSet expectedMetadataSet; | 142 IntegrityMetadataSet expectedMetadataSet; |
| 143 for (size_t i = 0; i < expectedMetadataArraySize; i++) { | 143 for (size_t i = 0; i < expectedMetadataArraySize; i++) { |
| 144 expectedMetadataSet.add(expectedMetadataArray[i].toPair()); | 144 expectedMetadataSet.insert(expectedMetadataArray[i].toPair()); |
| 145 } | 145 } |
| 146 IntegrityMetadataSet metadataSet; | 146 IntegrityMetadataSet metadataSet; |
| 147 EXPECT_EQ(SubresourceIntegrity::IntegrityParseValidResult, | 147 EXPECT_EQ(SubresourceIntegrity::IntegrityParseValidResult, |
| 148 SubresourceIntegrity::parseIntegrityAttribute(integrityAttribute, | 148 SubresourceIntegrity::parseIntegrityAttribute(integrityAttribute, |
| 149 metadataSet)); | 149 metadataSet)); |
| 150 EXPECT_TRUE(IntegrityMetadata::setsEqual(expectedMetadataSet, metadataSet)); | 150 EXPECT_TRUE(IntegrityMetadata::setsEqual(expectedMetadataSet, metadataSet)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void expectParseFailure(const char* integrityAttribute) { | 153 void expectParseFailure(const char* integrityAttribute) { |
| 154 IntegrityMetadataSet metadataSet; | 154 IntegrityMetadataSet metadataSet; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, | 526 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, |
| 527 strlen(kBasicScript), secureURL, insecureURL); | 527 strlen(kBasicScript), secureURL, insecureURL); |
| 528 | 528 |
| 529 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript), | 529 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript), |
| 530 secureURL, insecureURL, NoCors); | 530 secureURL, insecureURL, NoCors); |
| 531 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, | 531 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, |
| 532 strlen(kBasicScript), secureURL, insecureURL); | 532 strlen(kBasicScript), secureURL, insecureURL); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace blink | 535 } // namespace blink |
| OLD | NEW |