Chromium Code Reviews| 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 "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 Loading... | |
| 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 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.
| |
| 71 ASSERT_TRUE(isHTMLInputElement(node)); | |
| 72 HTMLInputElement& element = toHTMLInputElement(*node); | |
| 73 | |
| 74 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.
| |
| 75 element.focus(); | |
| 76 element.setValue(passwordValue); | |
| 77 element.setSelectionRange(0, passwordValue.length()); | |
| 78 | |
| 79 Editor& editor = document().frame()->editor(); | |
| 80 EXPECT_FALSE(editor.canCopy()); | |
| 81 | |
| 82 element.setShouldRevealPassword(true); | |
| 83 EXPECT_TRUE(editor.canCopy()); | |
| 84 } | |
| 85 | |
| 62 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |