OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "modules/credentialmanager/CredentialsContainer.h" | 5 #include "modules/credentialmanager/CredentialsContainer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "bindings/core/v8/V8BindingForTesting.h" | 9 #include "bindings/core/v8/V8BindingForTesting.h" |
10 #include "bindings/core/v8/V8GCController.h" | 10 #include "bindings/core/v8/V8GCController.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Make sure that the renderer doesn't crash if got a credential. | 43 // Make sure that the renderer doesn't crash if got a credential. |
44 TEST(CredentialsContainerTest, TestGetWithDocumentDestroyed) { | 44 TEST(CredentialsContainerTest, TestGetWithDocumentDestroyed) { |
45 CredentialsContainer* credential_container = CredentialsContainer::Create(); | 45 CredentialsContainer* credential_container = CredentialsContainer::Create(); |
46 std::unique_ptr<WebCredentialManagerClient::RequestCallbacks> get_callback; | 46 std::unique_ptr<WebCredentialManagerClient::RequestCallbacks> get_callback; |
47 | 47 |
48 V8TestingScope scope; | 48 V8TestingScope scope; |
49 { | 49 { |
50 // Set up. | 50 // Set up. |
51 scope.GetDocument().SetSecurityOrigin( | 51 scope.GetDocument().SetSecurityOrigin( |
52 SecurityOrigin::CreateFromString("https://example.test")); | 52 SecurityOrigin::CreateFromString("https://example.test")); |
53 testing::StrictMock<MockCredentialManagerClient> mock_client; | 53 ::testing::StrictMock<MockCredentialManagerClient> mock_client; |
54 ProvideCredentialManagerClientTo(scope.GetPage(), | 54 ProvideCredentialManagerClientTo(scope.GetPage(), |
55 new CredentialManagerClient(&mock_client)); | 55 new CredentialManagerClient(&mock_client)); |
56 | 56 |
57 // Request a credential. | 57 // Request a credential. |
58 WebCredentialManagerClient::RequestCallbacks* callback = nullptr; | 58 WebCredentialManagerClient::RequestCallbacks* callback = nullptr; |
59 EXPECT_CALL(mock_client, DispatchGet(_, _, _, _)) | 59 EXPECT_CALL(mock_client, DispatchGet(_, _, _, _)) |
60 .WillOnce(SaveArg<3>(&callback)); | 60 .WillOnce(SaveArg<3>(&callback)); |
61 credential_container->get(scope.GetScriptState(), | 61 credential_container->get(scope.GetScriptState(), |
62 CredentialRequestOptions()); | 62 CredentialRequestOptions()); |
63 | 63 |
64 ASSERT_TRUE(callback); | 64 ASSERT_TRUE(callback); |
65 get_callback.reset(callback); | 65 get_callback.reset(callback); |
66 } | 66 } |
67 | 67 |
68 // Garbage collect v8::Context. | 68 // Garbage collect v8::Context. |
69 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); | 69 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); |
70 | 70 |
71 // Invoking the callback shouldn't crash. | 71 // Invoking the callback shouldn't crash. |
72 get_callback->OnSuccess(std::unique_ptr<WebCredential>()); | 72 get_callback->OnSuccess(std::unique_ptr<WebCredential>()); |
73 } | 73 } |
74 | 74 |
75 } // namespace blink | 75 } // namespace blink |
OLD | NEW |