| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "chrome/test/base/chrome_render_view_test.h" | 6 #include "chrome/test/base/chrome_render_view_test.h" |
| 7 #include "components/autofill/content/common/autofill_messages.h" | 7 #include "components/autofill/content/common/autofill_messages.h" |
| 8 #include "components/autofill/core/common/form_data.h" | 8 #include "components/autofill/core/common/form_data.h" |
| 9 #include "content/public/test/mock_render_thread.h" | 9 #include "content/public/test/mock_render_thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 submitted_field = base::get<0>(submitted_forms).fields[1]; | 61 submitted_field = base::get<0>(submitted_forms).fields[1]; |
| 62 EXPECT_EQ(WebString("lname"), submitted_field.name); | 62 EXPECT_EQ(WebString("lname"), submitted_field.name); |
| 63 EXPECT_EQ(WebString("Deckard"), submitted_field.value); | 63 EXPECT_EQ(WebString("Deckard"), submitted_field.value); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // end namespace | 67 } // end namespace |
| 68 | 68 |
| 69 // Tests that submitting a form generates WillSubmitForm and FormSubmitted | 69 // Tests that submitting a form generates WillSubmitForm and FormSubmitted |
| 70 // messages with the form fields. | 70 // messages with the form fields. |
| 71 // Flaky: http://crbug.com/500851. | 71 TEST_F(FormAutocompleteTest, NormalFormSubmit) { |
| 72 TEST_F(FormAutocompleteTest, DISABLED_NormalFormSubmit) { | |
| 73 // Load a form. | 72 // Load a form. |
| 74 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" | 73 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" |
| 75 "<input name='lname' value='Deckard'/></form></html>"); | 74 "<input name='lname' value='Deckard'/></form></html>"); |
| 76 | 75 |
| 77 // Submit the form. | 76 // Submit the form. |
| 78 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 77 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 79 ProcessPendingMessages(); | 78 ProcessPendingMessages(); |
| 80 | 79 |
| 81 VerifyReceivedRendererMessages(render_thread_.get(), | 80 VerifyReceivedRendererMessages(render_thread_.get(), |
| 82 true /* expect_submitted_message */); | 81 true /* expect_submitted_message */); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 97 "form.onsubmit = function(event) { event.preventDefault(); };" | 96 "form.onsubmit = function(event) { event.preventDefault(); };" |
| 98 "document.querySelector('input[type=submit]').click();"); | 97 "document.querySelector('input[type=submit]').click();"); |
| 99 ProcessPendingMessages(); | 98 ProcessPendingMessages(); |
| 100 | 99 |
| 101 VerifyReceivedRendererMessages(render_thread_.get(), | 100 VerifyReceivedRendererMessages(render_thread_.get(), |
| 102 false /* expect_submitted_message */); | 101 false /* expect_submitted_message */); |
| 103 } | 102 } |
| 104 | 103 |
| 105 // Tests that submitting a form that has autocomplete="off" generates | 104 // Tests that submitting a form that has autocomplete="off" generates |
| 106 // WillSubmitForm and FormSubmitted messages. | 105 // WillSubmitForm and FormSubmitted messages. |
| 107 // Flaky: http://crbug.com/500851. | 106 TEST_F(FormAutocompleteTest, AutoCompleteOffFormSubmit) { |
| 108 TEST_F(FormAutocompleteTest, DISABLED_AutoCompleteOffFormSubmit) { | |
| 109 // Load a form. | 107 // Load a form. |
| 110 LoadHTML("<html><form id='myForm' autocomplete='off'>" | 108 LoadHTML("<html><form id='myForm' autocomplete='off'>" |
| 111 "<input name='fname' value='Rick'/>" | 109 "<input name='fname' value='Rick'/>" |
| 112 "<input name='lname' value='Deckard'/>" | 110 "<input name='lname' value='Deckard'/>" |
| 113 "</form></html>"); | 111 "</form></html>"); |
| 114 | 112 |
| 115 // Submit the form. | 113 // Submit the form. |
| 116 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 114 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 117 ProcessPendingMessages(); | 115 ProcessPendingMessages(); |
| 118 | 116 |
| 119 VerifyReceivedRendererMessages(render_thread_.get(), | 117 VerifyReceivedRendererMessages(render_thread_.get(), |
| 120 true /* expect_submitted_message */); | 118 true /* expect_submitted_message */); |
| 121 } | 119 } |
| 122 | 120 |
| 123 // Tests that fields with autocomplete off are submitted. | 121 // Tests that fields with autocomplete off are submitted. |
| 124 // Flaky: http://crbug.com/500851. | 122 TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) { |
| 125 TEST_F(FormAutocompleteTest, DISABLED_AutoCompleteOffInputSubmit) { | |
| 126 // Load a form. | 123 // Load a form. |
| 127 LoadHTML("<html><form id='myForm'>" | 124 LoadHTML("<html><form id='myForm'>" |
| 128 "<input name='fname' value='Rick'/>" | 125 "<input name='fname' value='Rick'/>" |
| 129 "<input name='lname' value='Deckard' autocomplete='off'/>" | 126 "<input name='lname' value='Deckard' autocomplete='off'/>" |
| 130 "</form></html>"); | 127 "</form></html>"); |
| 131 | 128 |
| 132 // Submit the form. | 129 // Submit the form. |
| 133 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 130 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 134 ProcessPendingMessages(); | 131 ProcessPendingMessages(); |
| 135 | 132 |
| 136 VerifyReceivedRendererMessages(render_thread_.get(), | 133 VerifyReceivedRendererMessages(render_thread_.get(), |
| 137 true /* expect_submitted_message */); | 134 true /* expect_submitted_message */); |
| 138 } | 135 } |
| 139 | 136 |
| 140 // Tests that submitting a form that has been dynamically set as autocomplete | 137 // Tests that submitting a form that has been dynamically set as autocomplete |
| 141 // off generates WillSubmitForm and FormSubmitted messages. | 138 // off generates WillSubmitForm and FormSubmitted messages. |
| 142 // Note: We previously did the opposite, for bug http://crbug.com/36520 | 139 // Note: We previously did the opposite, for bug http://crbug.com/36520 |
| 143 // Flaky: http://crbug.com/500851. | 140 TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) { |
| 144 TEST_F(FormAutocompleteTest, DISABLED_DynamicAutoCompleteOffFormSubmit) { | |
| 145 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" | 141 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" |
| 146 "<input name='lname' value='Deckard'/></form></html>"); | 142 "<input name='lname' value='Deckard'/></form></html>"); |
| 147 | 143 |
| 148 blink::WebElement element = | 144 blink::WebElement element = |
| 149 GetMainFrame()->document().getElementById(blink::WebString("myForm")); | 145 GetMainFrame()->document().getElementById(blink::WebString("myForm")); |
| 150 ASSERT_FALSE(element.isNull()); | 146 ASSERT_FALSE(element.isNull()); |
| 151 blink::WebFormElement form = element.to<blink::WebFormElement>(); | 147 blink::WebFormElement form = element.to<blink::WebFormElement>(); |
| 152 EXPECT_TRUE(form.autoComplete()); | 148 EXPECT_TRUE(form.autoComplete()); |
| 153 | 149 |
| 154 // Dynamically mark the form as autocomplete off. | 150 // Dynamically mark the form as autocomplete off. |
| 155 ExecuteJavaScript("document.getElementById('myForm')." | 151 ExecuteJavaScript("document.getElementById('myForm')." |
| 156 "setAttribute('autocomplete', 'off');"); | 152 "setAttribute('autocomplete', 'off');"); |
| 157 ProcessPendingMessages(); | 153 ProcessPendingMessages(); |
| 158 EXPECT_FALSE(form.autoComplete()); | 154 EXPECT_FALSE(form.autoComplete()); |
| 159 | 155 |
| 160 // Submit the form. | 156 // Submit the form. |
| 161 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 157 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 162 ProcessPendingMessages(); | 158 ProcessPendingMessages(); |
| 163 | 159 |
| 164 VerifyReceivedRendererMessages(render_thread_.get(), | 160 VerifyReceivedRendererMessages(render_thread_.get(), |
| 165 true /* expect_submitted_message */); | 161 true /* expect_submitted_message */); |
| 166 } | 162 } |
| 167 | 163 |
| 168 } // namespace autofill | 164 } // namespace autofill |
| OLD | NEW |