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

Side by Side Diff: chrome/renderer/autofill/form_autofill_browsertest.cc

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 2125
2126 FormCache form_cache(*web_frame); 2126 FormCache form_cache(*web_frame);
2127 std::vector<FormData> forms = form_cache.ExtractNewForms(); 2127 std::vector<FormData> forms = form_cache.ExtractNewForms();
2128 ASSERT_EQ(1U, forms.size()); 2128 ASSERT_EQ(1U, forms.size());
2129 2129
2130 // Second call should give nothing as there are no new forms. 2130 // Second call should give nothing as there are no new forms.
2131 forms = form_cache.ExtractNewForms(); 2131 forms = form_cache.ExtractNewForms();
2132 ASSERT_TRUE(forms.empty()); 2132 ASSERT_TRUE(forms.empty());
2133 2133
2134 // Append to the current form will re-extract. 2134 // Append to the current form will re-extract.
2135 ExecuteJavaScript( 2135 ExecuteJavaScriptForTests(
2136 "var newInput = document.createElement('input');" 2136 "var newInput = document.createElement('input');"
2137 "newInput.setAttribute('type', 'text');" 2137 "newInput.setAttribute('type', 'text');"
2138 "newInput.setAttribute('id', 'telephone');" 2138 "newInput.setAttribute('id', 'telephone');"
2139 "newInput.value = '12345';" 2139 "newInput.value = '12345';"
2140 "document.getElementById('testform').appendChild(newInput);"); 2140 "document.getElementById('testform').appendChild(newInput);");
2141 msg_loop_.RunUntilIdle(); 2141 msg_loop_.RunUntilIdle();
2142 2142
2143 forms = form_cache.ExtractNewForms(); 2143 forms = form_cache.ExtractNewForms();
2144 ASSERT_EQ(1U, forms.size()); 2144 ASSERT_EQ(1U, forms.size());
2145 2145
(...skipping 16 matching lines...) Expand all
2162 expected.value = ASCIIToUTF16("john@example.com"); 2162 expected.value = ASCIIToUTF16("john@example.com");
2163 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); 2163 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
2164 2164
2165 expected.name = ASCIIToUTF16("telephone"); 2165 expected.name = ASCIIToUTF16("telephone");
2166 expected.value = ASCIIToUTF16("12345"); 2166 expected.value = ASCIIToUTF16("12345");
2167 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); 2167 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]);
2168 2168
2169 forms.clear(); 2169 forms.clear();
2170 2170
2171 // Completely new form will also be extracted. 2171 // Completely new form will also be extracted.
2172 ExecuteJavaScript( 2172 ExecuteJavaScriptForTests(
2173 "var newForm=document.createElement('form');" 2173 "var newForm=document.createElement('form');"
2174 "newForm.id='new_testform';" 2174 "newForm.id='new_testform';"
2175 "newForm.action='http://google.com';" 2175 "newForm.action='http://google.com';"
2176 "newForm.method='post';" 2176 "newForm.method='post';"
2177 "var newFirstname=document.createElement('input');" 2177 "var newFirstname=document.createElement('input');"
2178 "newFirstname.setAttribute('type', 'text');" 2178 "newFirstname.setAttribute('type', 'text');"
2179 "newFirstname.setAttribute('id', 'second_firstname');" 2179 "newFirstname.setAttribute('id', 'second_firstname');"
2180 "newFirstname.value = 'Bob';" 2180 "newFirstname.value = 'Bob';"
2181 "var newLastname=document.createElement('input');" 2181 "var newLastname=document.createElement('input');"
2182 "newLastname.setAttribute('type', 'text');" 2182 "newLastname.setAttribute('type', 'text');"
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 ASSERT_TRUE(control_elements.empty()); 4098 ASSERT_TRUE(control_elements.empty());
4099 ASSERT_TRUE(fieldsets.empty()); 4099 ASSERT_TRUE(fieldsets.empty());
4100 4100
4101 FormData form; 4101 FormData form;
4102 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( 4102 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData(
4103 fieldsets, control_elements, nullptr, frame->document(), extract_mask, 4103 fieldsets, control_elements, nullptr, frame->document(), extract_mask,
4104 &form, nullptr)); 4104 &form, nullptr));
4105 } 4105 }
4106 4106
4107 } // namespace autofill 4107 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_autocomplete_browsertest.cc ('k') | chrome/renderer/autofill/page_click_tracker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698