| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 " <input type=\"text\" id=\"zip\"><br>" | 85 " <input type=\"text\" id=\"zip\"><br>" |
| 86 "<label for=\"country\">Country:</label>" | 86 "<label for=\"country\">Country:</label>" |
| 87 " <select id=\"country\">" | 87 " <select id=\"country\">" |
| 88 " <option value=\"\" selected=\"yes\">--</option>" | 88 " <option value=\"\" selected=\"yes\">--</option>" |
| 89 " <option value=\"CA\">Canada</option>" | 89 " <option value=\"CA\">Canada</option>" |
| 90 " <option value=\"US\">United States</option>" | 90 " <option value=\"US\">United States</option>" |
| 91 " </select><br>" | 91 " </select><br>" |
| 92 "<label for=\"phone\">Phone number:</label>" | 92 "<label for=\"phone\">Phone number:</label>" |
| 93 " <input type=\"text\" id=\"phone\"><br>" | 93 " <input type=\"text\" id=\"phone\"><br>" |
| 94 "</form>"; | 94 "</form>"; |
| 95 static const char kTestPasswordFormString[] = | |
| 96 "<form>" | |
| 97 "<label for=\"user\">User:</label>" | |
| 98 " <input id=\"user\" type=\"text\" name=\"name\"" | |
| 99 "onfocus=\"domAutomationController.send(true)\">" | |
| 100 "<br>" | |
| 101 "<label for=\"password\">Password:</label>" | |
| 102 " <input id=\"password\" type=\"password\" name=\"password\"" | |
| 103 "onfocus=\"domAutomationController.send(true)\">" | |
| 104 "<br>" | |
| 105 "<input type=\"submit\" value=\"Submit\">" | |
| 106 "</form>"; | |
| 107 | 95 |
| 108 // TODO(crbug.com/609861): Remove the autocomplete attribute from the textarea | 96 // TODO(crbug.com/609861): Remove the autocomplete attribute from the textarea |
| 109 // field when the bug is fixed. | 97 // field when the bug is fixed. |
| 110 static const char kTestEventFormString[] = | 98 static const char kTestEventFormString[] = |
| 111 "<script type=\"text/javascript\">" | 99 "<script type=\"text/javascript\">" |
| 112 "var inputfocus = false;" | 100 "var inputfocus = false;" |
| 113 "var inputkeydown = false;" | 101 "var inputkeydown = false;" |
| 114 "var inputinput = false;" | 102 "var inputinput = false;" |
| 115 "var inputchange = false;" | 103 "var inputchange = false;" |
| 116 "var inputkeyup = false;" | 104 "var inputkeyup = false;" |
| (...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 GetRenderViewHost(), | 1708 GetRenderViewHost(), |
| 1721 "document.querySelector('input').autocomplete = 'off';")); | 1709 "document.querySelector('input').autocomplete = 'off';")); |
| 1722 | 1710 |
| 1723 // Press the down arrow to select the suggestion and attempt to preview the | 1711 // Press the down arrow to select the suggestion and attempt to preview the |
| 1724 // autofilled form. | 1712 // autofilled form. |
| 1725 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); | 1713 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); |
| 1726 } | 1714 } |
| 1727 | 1715 |
| 1728 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1716 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1729 PastedPasswordIsSaved) { | 1717 PastedPasswordIsSaved) { |
| 1730 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1718 // Serve test page from a HTTPS server so that Form Not Secure warnings do not |
| 1731 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); | 1719 // interfere with the test. |
| 1720 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 1721 net::SSLServerConfig ssl_config; |
| 1722 ssl_config.client_cert_type = |
| 1723 net::SSLServerConfig::ClientCertType::NO_CLIENT_CERT; |
| 1724 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config); |
| 1725 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 1726 ASSERT_TRUE(https_server.Start()); |
| 1727 |
| 1728 GURL url = https_server.GetURL("/autofill/autofill_password_form.html"); |
| 1729 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); |
| 1730 |
| 1732 ASSERT_TRUE(content::ExecuteScript( | 1731 ASSERT_TRUE(content::ExecuteScript( |
| 1733 GetRenderViewHost(), | 1732 GetRenderViewHost(), |
| 1734 "document.getElementById('user').value = 'user';")); | 1733 "document.getElementById('user').value = 'user';")); |
| 1735 FocusFieldByName("password"); | 1734 FocusFieldByName("password"); |
| 1736 PasteStringAndWait("foobar"); | 1735 PasteStringAndWait("foobar"); |
| 1737 } | 1736 } |
| 1738 | 1737 |
| 1739 } // namespace autofill | 1738 } // namespace autofill |
| OLD | NEW |