OLD | NEW |
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 2082 matching lines...) Loading... |
2093 | 2093 |
2094 FormCache form_cache(*web_frame); | 2094 FormCache form_cache(*web_frame); |
2095 std::vector<FormData> forms = form_cache.ExtractNewForms(); | 2095 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
2096 ASSERT_EQ(1U, forms.size()); | 2096 ASSERT_EQ(1U, forms.size()); |
2097 | 2097 |
2098 // Second call should give nothing as there are no new forms. | 2098 // Second call should give nothing as there are no new forms. |
2099 forms = form_cache.ExtractNewForms(); | 2099 forms = form_cache.ExtractNewForms(); |
2100 ASSERT_TRUE(forms.empty()); | 2100 ASSERT_TRUE(forms.empty()); |
2101 | 2101 |
2102 // Append to the current form will re-extract. | 2102 // Append to the current form will re-extract. |
2103 ExecuteJavaScript( | 2103 ExecuteJavaScriptForTests( |
2104 "var newInput = document.createElement('input');" | 2104 "var newInput = document.createElement('input');" |
2105 "newInput.setAttribute('type', 'text');" | 2105 "newInput.setAttribute('type', 'text');" |
2106 "newInput.setAttribute('id', 'telephone');" | 2106 "newInput.setAttribute('id', 'telephone');" |
2107 "newInput.value = '12345';" | 2107 "newInput.value = '12345';" |
2108 "document.getElementById('testform').appendChild(newInput);"); | 2108 "document.getElementById('testform').appendChild(newInput);"); |
2109 msg_loop_.RunUntilIdle(); | 2109 msg_loop_.RunUntilIdle(); |
2110 | 2110 |
2111 forms = form_cache.ExtractNewForms(); | 2111 forms = form_cache.ExtractNewForms(); |
2112 ASSERT_EQ(1U, forms.size()); | 2112 ASSERT_EQ(1U, forms.size()); |
2113 | 2113 |
(...skipping 16 matching lines...) Loading... |
2130 expected.value = ASCIIToUTF16("john@example.com"); | 2130 expected.value = ASCIIToUTF16("john@example.com"); |
2131 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2131 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
2132 | 2132 |
2133 expected.name = ASCIIToUTF16("telephone"); | 2133 expected.name = ASCIIToUTF16("telephone"); |
2134 expected.value = ASCIIToUTF16("12345"); | 2134 expected.value = ASCIIToUTF16("12345"); |
2135 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); | 2135 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); |
2136 | 2136 |
2137 forms.clear(); | 2137 forms.clear(); |
2138 | 2138 |
2139 // Completely new form will also be extracted. | 2139 // Completely new form will also be extracted. |
2140 ExecuteJavaScript( | 2140 ExecuteJavaScriptForTests( |
2141 "var newForm=document.createElement('form');" | 2141 "var newForm=document.createElement('form');" |
2142 "newForm.id='new_testform';" | 2142 "newForm.id='new_testform';" |
2143 "newForm.action='http://google.com';" | 2143 "newForm.action='http://google.com';" |
2144 "newForm.method='post';" | 2144 "newForm.method='post';" |
2145 "var newFirstname=document.createElement('input');" | 2145 "var newFirstname=document.createElement('input');" |
2146 "newFirstname.setAttribute('type', 'text');" | 2146 "newFirstname.setAttribute('type', 'text');" |
2147 "newFirstname.setAttribute('id', 'second_firstname');" | 2147 "newFirstname.setAttribute('id', 'second_firstname');" |
2148 "newFirstname.value = 'Bob';" | 2148 "newFirstname.value = 'Bob';" |
2149 "var newLastname=document.createElement('input');" | 2149 "var newLastname=document.createElement('input');" |
2150 "newLastname.setAttribute('type', 'text');" | 2150 "newLastname.setAttribute('type', 'text');" |
(...skipping 1915 matching lines...) Loading... |
4066 ASSERT_TRUE(control_elements.empty()); | 4066 ASSERT_TRUE(control_elements.empty()); |
4067 ASSERT_TRUE(fieldsets.empty()); | 4067 ASSERT_TRUE(fieldsets.empty()); |
4068 | 4068 |
4069 FormData form; | 4069 FormData form; |
4070 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( | 4070 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( |
4071 fieldsets, control_elements, nullptr, frame->document(), extract_mask, | 4071 fieldsets, control_elements, nullptr, frame->document(), extract_mask, |
4072 &form, nullptr)); | 4072 &form, nullptr)); |
4073 } | 4073 } |
4074 | 4074 |
4075 } // namespace autofill | 4075 } // namespace autofill |
OLD | NEW |