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

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 2478803003: Remove DOMAutomationController::automation_id_ (Closed)
Patch Set: Rebasing... Created 3 years, 5 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
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 using base::ASCIIToUTF16; 62 using base::ASCIIToUTF16;
63 63
64 namespace autofill { 64 namespace autofill {
65 65
66 namespace { 66 namespace {
67 67
68 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; 68 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,";
69 static const char kTestFormString[] = 69 static const char kTestFormString[] =
70 "<form action=\"http://www.example.com/\" method=\"POST\">" 70 "<form action=\"http://www.example.com/\" method=\"POST\">"
71 "<label for=\"firstname\">First name:</label>" 71 "<label for=\"firstname\">First name:</label>"
72 " <input type=\"text\" id=\"firstname\"" 72 " <input type=\"text\" id=\"firstname\"><br>"
73 " onfocus=\"domAutomationController.send(true)\"><br>"
74 "<label for=\"lastname\">Last name:</label>" 73 "<label for=\"lastname\">Last name:</label>"
75 " <input type=\"text\" id=\"lastname\"><br>" 74 " <input type=\"text\" id=\"lastname\"><br>"
76 "<label for=\"address1\">Address line 1:</label>" 75 "<label for=\"address1\">Address line 1:</label>"
77 " <input type=\"text\" id=\"address1\"><br>" 76 " <input type=\"text\" id=\"address1\"><br>"
78 "<label for=\"address2\">Address line 2:</label>" 77 "<label for=\"address2\">Address line 2:</label>"
79 " <input type=\"text\" id=\"address2\"><br>" 78 " <input type=\"text\" id=\"address2\"><br>"
80 "<label for=\"city\">City:</label>" 79 "<label for=\"city\">City:</label>"
81 " <input type=\"text\" id=\"city\"><br>" 80 " <input type=\"text\" id=\"city\"><br>"
82 "<label for=\"state\">State:</label>" 81 "<label for=\"state\">State:</label>"
83 " <select id=\"state\">" 82 " <select id=\"state\">"
(...skipping 29 matching lines...) Expand all
113 "var textchange = false;" 112 "var textchange = false;"
114 "var textkeyup = false;" 113 "var textkeyup = false;"
115 "var textblur = false;" 114 "var textblur = false;"
116 "var selectfocus = false;" 115 "var selectfocus = false;"
117 "var selectinput = false;" 116 "var selectinput = false;"
118 "var selectchange = false;" 117 "var selectchange = false;"
119 "var selectblur = false;" 118 "var selectblur = false;"
120 "</script>" 119 "</script>"
121 "<form action=\"http://www.example.com/\" method=\"POST\">" 120 "<form action=\"http://www.example.com/\" method=\"POST\">"
122 "<label for=\"firstname\">First name:</label>" 121 "<label for=\"firstname\">First name:</label>"
123 " <input type=\"text\" id=\"firstname\"" 122 " <input type=\"text\" id=\"firstname\"><br>"
124 " onfocus=\"domAutomationController.send(true)\"><br>"
125 "<label for=\"lastname\">Last name:</label>" 123 "<label for=\"lastname\">Last name:</label>"
126 " <input type=\"text\" id=\"lastname\"" 124 " <input type=\"text\" id=\"lastname\""
127 " onfocus=\"inputfocus = true\" onkeydown=\"inputkeydown = true\"" 125 " onfocus=\"inputfocus = true\" onkeydown=\"inputkeydown = true\""
128 " oninput=\"inputinput = true\" onchange=\"inputchange = true\"" 126 " oninput=\"inputinput = true\" onchange=\"inputchange = true\""
129 " onkeyup=\"inputkeyup = true\" onblur=\"inputblur = true\" ><br>" 127 " onkeyup=\"inputkeyup = true\" onblur=\"inputblur = true\" ><br>"
130 "<label for=\"address1\">Address line 1:</label>" 128 "<label for=\"address1\">Address line 1:</label>"
131 " <input type=\"text\" id=\"address1\"><br>" 129 " <input type=\"text\" id=\"address1\"><br>"
132 "<label for=\"address2\">Address line 2:</label>" 130 "<label for=\"address2\">Address line 2:</label>"
133 " <input type=\"text\" id=\"address2\"><br>" 131 " <input type=\"text\" id=\"address2\"><br>"
134 "<label for=\"city\">City:</label>" 132 "<label for=\"city\">City:</label>"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 fetcher->set_status(net::URLRequestStatus::FromError(error)); 352 fetcher->set_status(net::URLRequestStatus::FromError(error));
355 fetcher->set_response_code(success ? 200 : 500); 353 fetcher->set_response_code(success ? 200 : 500);
356 fetcher->SetResponseString(script); 354 fetcher->SetResponseString(script);
357 fetcher->delegate()->OnURLFetchComplete(fetcher); 355 fetcher->delegate()->OnURLFetchComplete(fetcher);
358 } 356 }
359 357
360 void FocusFieldByName(const std::string& name) { 358 void FocusFieldByName(const std::string& name) {
361 bool result = false; 359 bool result = false;
362 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 360 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
363 GetRenderViewHost(), 361 GetRenderViewHost(),
364 "if (document.readyState === 'complete')" 362 "function onFocusHandler(e) {"
365 " document.getElementById('" + name + "').focus();" 363 " e.target.removeEventListener(e.type, arguments.callee);"
366 "else" 364 " domAutomationController.send(true);"
367 " domAutomationController.send(false);", 365 "}"
366 "if (document.readyState === 'complete') {"
367 " var target = document.getElementById('" +
368 name +
369 "');"
370 " target.addEventListener('focus', onFocusHandler);"
371 " target.focus();"
372 "} else {"
373 " domAutomationController.send(false);"
374 "}",
368 &result)); 375 &result));
369 ASSERT_TRUE(result); 376 ASSERT_TRUE(result);
370 } 377 }
371 378
372 void FocusFirstNameField() { 379 void FocusFirstNameField() { FocusFieldByName("firstname"); }
373 bool result = false;
374 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
375 GetRenderViewHost(),
376 "if (document.readyState === 'complete')"
377 " document.getElementById('firstname').focus();"
378 "else"
379 " domAutomationController.send(false);",
380 &result));
381 ASSERT_TRUE(result);
382 }
383 380
384 // Simulates a click on the middle of the DOM element with the given |id|. 381 // Simulates a click on the middle of the DOM element with the given |id|.
385 void ClickElementWithId(const std::string& id) { 382 void ClickElementWithId(const std::string& id) {
386 int x; 383 int x;
387 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 384 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
388 GetRenderViewHost(), 385 GetRenderViewHost(),
389 "var bounds = document.getElementById('" + 386 "var bounds = document.getElementById('" +
390 id + 387 id +
391 "').getBoundingClientRect();" 388 "').getBoundingClientRect();"
392 "domAutomationController.send(" 389 "domAutomationController.send("
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 #else 785 #else
789 #define MAYBE_OnSelectOptionFromDatalist OnSelectOptionFromDatalist 786 #define MAYBE_OnSelectOptionFromDatalist OnSelectOptionFromDatalist
790 #endif 787 #endif
791 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, 788 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
792 MAYBE_OnSelectOptionFromDatalist) { 789 MAYBE_OnSelectOptionFromDatalist) {
793 // Load the test page. 790 // Load the test page.
794 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( 791 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
795 browser(), 792 browser(),
796 GURL(std::string(kDataURIPrefix) + 793 GURL(std::string(kDataURIPrefix) +
797 "<form action=\"http://www.example.com/\" method=\"POST\">" 794 "<form action=\"http://www.example.com/\" method=\"POST\">"
798 " <input list=\"dl\" type=\"search\" id=\"firstname\"" 795 " <input list=\"dl\" type=\"search\" id=\"firstname\"><br>"
799 " onfocus=\"domAutomationController.send(true)\"><br>"
800 " <datalist id=\"dl\">" 796 " <datalist id=\"dl\">"
801 " <option value=\"Adam\"></option>" 797 " <option value=\"Adam\"></option>"
802 " <option value=\"Bob\"></option>" 798 " <option value=\"Bob\"></option>"
803 " <option value=\"Carl\"></option>" 799 " <option value=\"Carl\"></option>"
804 " </datalist>" 800 " </datalist>"
805 "</form>"))); 801 "</form>")));
806 std::string orginalcolor; 802 std::string orginalcolor;
807 GetFieldBackgroundColor("firstname", &orginalcolor); 803 GetFieldBackgroundColor("firstname", &orginalcolor);
808 804
809 FocusFirstNameField(); 805 FocusFirstNameField();
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 std::string script_focus( 1887 std::string script_focus(
1892 "window.focus();" 1888 "window.focus();"
1893 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); 1889 "document.getElementById('CREDIT_CARD_NUMBER').focus();");
1894 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); 1890 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus));
1895 1891
1896 // Send an arrow dow keypress in order to trigger the autofill popup. 1892 // Send an arrow dow keypress in order to trigger the autofill popup.
1897 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); 1893 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN);
1898 } 1894 }
1899 1895
1900 } // namespace autofill 1896 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/captive_portal/captive_portal_browsertest.cc » ('j') | content/public/test/browser_test_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698