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 "modules/credentialmanager/PasswordCredential.h" | 5 #include "modules/credentialmanager/PasswordCredential.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 "<input type='text' name='theExtraField' value='extra'>" | 60 "<input type='text' name='theExtraField' value='extra'>" |
61 "<input type='text' name='theName' value='friendly name' " | 61 "<input type='text' name='theName' value='friendly name' " |
62 "autocomplete='name'>"); | 62 "autocomplete='name'>"); |
63 PasswordCredential* credential = | 63 PasswordCredential* credential = |
64 PasswordCredential::Create(form, ASSERT_NO_EXCEPTION); | 64 PasswordCredential::Create(form, ASSERT_NO_EXCEPTION); |
65 ASSERT_NE(nullptr, credential); | 65 ASSERT_NE(nullptr, credential); |
66 EXPECT_EQ("theId", credential->idName()); | 66 EXPECT_EQ("theId", credential->idName()); |
67 EXPECT_EQ("thePassword", credential->passwordName()); | 67 EXPECT_EQ("thePassword", credential->passwordName()); |
68 | 68 |
69 EXPECT_EQ("musterman", credential->id()); | 69 EXPECT_EQ("musterman", credential->id()); |
70 EXPECT_EQ("sekrit", credential->Password()); | 70 EXPECT_EQ("sekrit", credential->password()); |
71 EXPECT_EQ(KURL(kParsedURLString, "https://example.com/photo"), | 71 EXPECT_EQ(KURL(kParsedURLString, "https://example.com/photo"), |
72 credential->iconURL()); | 72 credential->iconURL()); |
73 EXPECT_EQ("friendly name", credential->name()); | 73 EXPECT_EQ("friendly name", credential->name()); |
74 EXPECT_EQ("password", credential->type()); | 74 EXPECT_EQ("password", credential->type()); |
75 | 75 |
76 FormDataOrURLSearchParams additional_data; | 76 FormDataOrURLSearchParams additional_data; |
77 credential->additionalData(additional_data); | 77 credential->additionalData(additional_data); |
78 ASSERT_TRUE(additional_data.isFormData()); | 78 ASSERT_TRUE(additional_data.isFormData()); |
79 EXPECT_TRUE(additional_data.getAsFormData()->has("theId")); | 79 EXPECT_TRUE(additional_data.getAsFormData()->has("theId")); |
80 EXPECT_TRUE(additional_data.getAsFormData()->has("thePassword")); | 80 EXPECT_TRUE(additional_data.getAsFormData()->has("thePassword")); |
(...skipping 14 matching lines...) Expand all Loading... |
95 "<input type='text' name='theExtraField' value='extra'>" | 95 "<input type='text' name='theExtraField' value='extra'>" |
96 "<input type='text' name='theName' value='friendly name' " | 96 "<input type='text' name='theName' value='friendly name' " |
97 "autocomplete='name'>"); | 97 "autocomplete='name'>"); |
98 PasswordCredential* credential = | 98 PasswordCredential* credential = |
99 PasswordCredential::Create(form, ASSERT_NO_EXCEPTION); | 99 PasswordCredential::Create(form, ASSERT_NO_EXCEPTION); |
100 ASSERT_NE(nullptr, credential); | 100 ASSERT_NE(nullptr, credential); |
101 EXPECT_EQ("theId", credential->idName()); | 101 EXPECT_EQ("theId", credential->idName()); |
102 EXPECT_EQ("thePassword", credential->passwordName()); | 102 EXPECT_EQ("thePassword", credential->passwordName()); |
103 | 103 |
104 EXPECT_EQ("musterman", credential->id()); | 104 EXPECT_EQ("musterman", credential->id()); |
105 EXPECT_EQ("sekrit", credential->Password()); | 105 EXPECT_EQ("sekrit", credential->password()); |
106 EXPECT_EQ(KURL(kParsedURLString, "https://example.com/photo"), | 106 EXPECT_EQ(KURL(kParsedURLString, "https://example.com/photo"), |
107 credential->iconURL()); | 107 credential->iconURL()); |
108 EXPECT_EQ("friendly name", credential->name()); | 108 EXPECT_EQ("friendly name", credential->name()); |
109 EXPECT_EQ("password", credential->type()); | 109 EXPECT_EQ("password", credential->type()); |
110 | 110 |
111 FormDataOrURLSearchParams additional_data; | 111 FormDataOrURLSearchParams additional_data; |
112 credential->additionalData(additional_data); | 112 credential->additionalData(additional_data); |
113 ASSERT_TRUE(additional_data.isURLSearchParams()); | 113 ASSERT_TRUE(additional_data.isURLSearchParams()); |
114 EXPECT_TRUE(additional_data.getAsURLSearchParams()->has("theId")); | 114 EXPECT_TRUE(additional_data.getAsURLSearchParams()->has("theId")); |
115 EXPECT_TRUE(additional_data.getAsURLSearchParams()->has("thePassword")); | 115 EXPECT_TRUE(additional_data.getAsURLSearchParams()->has("thePassword")); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 DummyExceptionStateForTesting exception_state; | 150 DummyExceptionStateForTesting exception_state; |
151 PasswordCredential* credential = | 151 PasswordCredential* credential = |
152 PasswordCredential::Create(form, exception_state); | 152 PasswordCredential::Create(form, exception_state); |
153 EXPECT_EQ(nullptr, credential); | 153 EXPECT_EQ(nullptr, credential); |
154 EXPECT_TRUE(exception_state.HadException()); | 154 EXPECT_TRUE(exception_state.HadException()); |
155 EXPECT_EQ(kV8TypeError, exception_state.Code()); | 155 EXPECT_EQ(kV8TypeError, exception_state.Code()); |
156 EXPECT_EQ("'id' must not be empty.", exception_state.Message()); | 156 EXPECT_EQ("'id' must not be empty.", exception_state.Message()); |
157 } | 157 } |
158 | 158 |
159 } // namespace blink | 159 } // namespace blink |
OLD | NEW |