| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/webcrypto/fuzzer_support.h" | 5 #include "components/webcrypto/fuzzer_support.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "components/test_runner/test_common.h" | |
| 11 #include "components/webcrypto/algorithm_dispatch.h" | 10 #include "components/webcrypto/algorithm_dispatch.h" |
| 12 #include "components/webcrypto/crypto_data.h" | 11 #include "components/webcrypto/crypto_data.h" |
| 13 #include "components/webcrypto/status.h" | 12 #include "components/webcrypto/status.h" |
| 13 #include "third_party/WebKit/public/platform/Platform.h" |
| 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
| 15 #include "third_party/WebKit/public/web/WebKit.h" |
| 15 | 16 |
| 16 namespace webcrypto { | 17 namespace webcrypto { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // This mock is used to initialize blink. | 21 // This mock is used to initialize blink. |
| 21 class InitOnce { | 22 class InitOnce : NON_EXPORTED_BASE(public blink::Platform) { |
| 22 public: | 23 public: |
| 23 InitOnce() { | 24 InitOnce() { |
| 24 // EnsureBlinkInitialized() depends on the command line singleton being | |
| 25 // initialized. | |
| 26 base::CommandLine::Init(0, nullptr); | 25 base::CommandLine::Init(0, nullptr); |
| 27 test_runner::EnsureBlinkInitialized(); | 26 blink::Platform::initialize(this); |
| 28 } | 27 } |
| 28 ~InitOnce() override {} |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 base::LazyInstance<InitOnce>::Leaky g_once = LAZY_INSTANCE_INITIALIZER; | 31 base::LazyInstance<InitOnce>::Leaky g_once = LAZY_INSTANCE_INITIALIZER; |
| 32 | 32 |
| 33 void EnsureInitialized() { | 33 void EnsureInitialized() { |
| 34 g_once.Get(); | 34 g_once.Get(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( | 37 blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( |
| 38 blink::WebCryptoAlgorithmId id, | 38 blink::WebCryptoAlgorithmId id, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // These errors imply a bad setup of parameters, and means ImportKey() may not | 124 // These errors imply a bad setup of parameters, and means ImportKey() may not |
| 125 // be testing the actual parsing. | 125 // be testing the actual parsing. |
| 126 DCHECK_NE(status.error_details(), | 126 DCHECK_NE(status.error_details(), |
| 127 Status::ErrorUnsupportedImportKeyFormat().error_details()); | 127 Status::ErrorUnsupportedImportKeyFormat().error_details()); |
| 128 DCHECK_NE(status.error_details(), | 128 DCHECK_NE(status.error_details(), |
| 129 Status::ErrorCreateKeyBadUsages().error_details()); | 129 Status::ErrorCreateKeyBadUsages().error_details()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace webcrypto | 132 } // namespace webcrypto |
| OLD | NEW |