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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditorTest.cpp

Issue 2740823003: [PasswordGeneration] Makes generated passwords copyable (Closed)
Patch Set: Changes in the test addressed to reviewer comments 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/editing/Editor.h" 5 #include "core/editing/Editor.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/html/HTMLBodyElement.h" 9 #include "core/html/HTMLBodyElement.h"
10 #include "core/html/HTMLDivElement.h" 10 #include "core/html/HTMLDivElement.h"
11 #include "core/html/HTMLHeadElement.h" 11 #include "core/html/HTMLHeadElement.h"
12 #include "core/html/HTMLHtmlElement.h" 12 #include "core/html/HTMLHtmlElement.h"
13 #include "core/html/HTMLInputElement.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class EditorTest : public EditingTestBase { 17 class EditorTest : public EditingTestBase {
17 protected: 18 protected:
18 void makeDocumentEmpty(); 19 void makeDocumentEmpty();
19 }; 20 };
20 21
21 void EditorTest::makeDocumentEmpty() { 22 void EditorTest::makeDocumentEmpty() {
22 while (document().firstChild()) 23 while (document().firstChild())
(...skipping 29 matching lines...) Expand all
52 makeDocumentEmpty(); 53 makeDocumentEmpty();
53 document().setDesignMode("on"); 54 document().setDesignMode("on");
54 document().appendChild(head); 55 document().appendChild(head);
55 Editor::tidyUpHTMLStructure(document()); 56 Editor::tidyUpHTMLStructure(document());
56 57
57 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement())); 58 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
58 EXPECT_TRUE(isHTMLBodyElement(document().body())); 59 EXPECT_TRUE(isHTMLBodyElement(document().body()));
59 EXPECT_EQ(document().documentElement(), head->parentNode()); 60 EXPECT_EQ(document().documentElement(), head->parentNode());
60 } 61 }
61 62
63 TEST_F(EditorTest, copyGeneratedPassword) {
64 // Checks that if the password field has the value generated by Chrome
65 // (HTMLInputElement::shouldRevealPassword will be true), copying the field
66 // should be available.
67 const char* bodyContent = "<input type='password' id='password'></input>";
68 setBodyContent(bodyContent);
69
70 HTMLInputElement& element =
71 toHTMLInputElement(*document().getElementById("password"));
72
73 const String kPasswordValue = "secret";
74 element.focus();
75 element.setValue(kPasswordValue);
76 element.setSelectionRange(0, kPasswordValue.length());
77
78 Editor& editor = document().frame()->editor();
79 EXPECT_FALSE(editor.canCopy());
80
81 element.setShouldRevealPassword(true);
82 EXPECT_TRUE(editor.canCopy());
83 }
84
62 } // namespace blink 85 } // namespace blink
OLDNEW
« 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