Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: third_party/WebKit/Source/core/editing/EditorTest.cpp

Issue 2740823003: [PasswordGeneration] Makes generated passwords copyable (Closed)
Patch Set: Added a test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/EditorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditorTest.cpp b/third_party/WebKit/Source/core/editing/EditorTest.cpp
index b2bd10e3626068ade95aaa7fa945eff5978df0d0..30d7da449c7ee2b415eaec366230fc2ce01ab1d0 100644
--- a/third_party/WebKit/Source/core/editing/EditorTest.cpp
+++ b/third_party/WebKit/Source/core/editing/EditorTest.cpp
@@ -10,6 +10,7 @@
#include "core/html/HTMLDivElement.h"
#include "core/html/HTMLHeadElement.h"
#include "core/html/HTMLHtmlElement.h"
+#include "core/html/HTMLInputElement.h"
namespace blink {
@@ -59,4 +60,27 @@ TEST_F(EditorTest, tidyUpHTMLStructureFromHead) {
EXPECT_EQ(document().documentElement(), head->parentNode());
}
+TEST_F(EditorTest, copyGeneratedPassword) {
+ // Checks that if the password field has the value generated by Chrome
+ // (HTMLInputElement::shouldRevealPassword will be true), copying the field
+ // should be available.
+ const char* bodyContent = "<input type='password' id='password'></input>";
+ setBodyContent(bodyContent);
+
+ Node* node = document().body()->firstChild();
yosin_UTC9 2017/03/13 07:35:41 L70 to L71 should be HTMLInputElement& element =
kolos1 2017/03/13 08:15:54 Done.
+ ASSERT_TRUE(isHTMLInputElement(node));
+ HTMLInputElement& element = toHTMLInputElement(*node);
+
+ String passwordValue = "secret";
yosin_UTC9 2017/03/13 07:35:41 nit: s/String passwordValue/const String kPassword
kolos1 2017/03/13 08:15:54 Done.
+ element.focus();
+ element.setValue(passwordValue);
+ element.setSelectionRange(0, passwordValue.length());
+
+ Editor& editor = document().frame()->editor();
+ EXPECT_FALSE(editor.canCopy());
+
+ element.setShouldRevealPassword(true);
+ EXPECT_TRUE(editor.canCopy());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698