Chromium Code Reviews| 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 // Flaky: http://crbug.com/500851. |
|
Nico
2015/07/09 01:27:02
Remove this comment? Also below.
| |
| 72 TEST_F(FormAutocompleteTest, DISABLED_NormalFormSubmit) { | 72 TEST_F(FormAutocompleteTest, NormalFormSubmit) { |
| 73 // Load a form. | 73 // Load a form. |
| 74 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" | 74 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" |
| 75 "<input name='lname' value='Deckard'/></form></html>"); | 75 "<input name='lname' value='Deckard'/></form></html>"); |
| 76 | 76 |
| 77 // Submit the form. | 77 // Submit the form. |
| 78 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 78 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 79 ProcessPendingMessages(); | 79 ProcessPendingMessages(); |
| 80 | 80 |
| 81 VerifyReceivedRendererMessages(render_thread_.get(), | 81 VerifyReceivedRendererMessages(render_thread_.get(), |
| 82 true /* expect_submitted_message */); | 82 true /* expect_submitted_message */); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 98 "document.querySelector('input[type=submit]').click();"); | 98 "document.querySelector('input[type=submit]').click();"); |
| 99 ProcessPendingMessages(); | 99 ProcessPendingMessages(); |
| 100 | 100 |
| 101 VerifyReceivedRendererMessages(render_thread_.get(), | 101 VerifyReceivedRendererMessages(render_thread_.get(), |
| 102 false /* expect_submitted_message */); | 102 false /* expect_submitted_message */); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Tests that submitting a form that has autocomplete="off" generates | 105 // Tests that submitting a form that has autocomplete="off" generates |
| 106 // WillSubmitForm and FormSubmitted messages. | 106 // WillSubmitForm and FormSubmitted messages. |
| 107 // Flaky: http://crbug.com/500851. | 107 // Flaky: http://crbug.com/500851. |
| 108 TEST_F(FormAutocompleteTest, DISABLED_AutoCompleteOffFormSubmit) { | 108 TEST_F(FormAutocompleteTest, AutoCompleteOffFormSubmit) { |
| 109 // Load a form. | 109 // Load a form. |
| 110 LoadHTML("<html><form id='myForm' autocomplete='off'>" | 110 LoadHTML("<html><form id='myForm' autocomplete='off'>" |
| 111 "<input name='fname' value='Rick'/>" | 111 "<input name='fname' value='Rick'/>" |
| 112 "<input name='lname' value='Deckard'/>" | 112 "<input name='lname' value='Deckard'/>" |
| 113 "</form></html>"); | 113 "</form></html>"); |
| 114 | 114 |
| 115 // Submit the form. | 115 // Submit the form. |
| 116 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 116 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 117 ProcessPendingMessages(); | 117 ProcessPendingMessages(); |
| 118 | 118 |
| 119 VerifyReceivedRendererMessages(render_thread_.get(), | 119 VerifyReceivedRendererMessages(render_thread_.get(), |
| 120 true /* expect_submitted_message */); | 120 true /* expect_submitted_message */); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Tests that fields with autocomplete off are submitted. | 123 // Tests that fields with autocomplete off are submitted. |
| 124 // Flaky: http://crbug.com/500851. | 124 // Flaky: http://crbug.com/500851. |
| 125 TEST_F(FormAutocompleteTest, DISABLED_AutoCompleteOffInputSubmit) { | 125 TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) { |
| 126 // Load a form. | 126 // Load a form. |
| 127 LoadHTML("<html><form id='myForm'>" | 127 LoadHTML("<html><form id='myForm'>" |
| 128 "<input name='fname' value='Rick'/>" | 128 "<input name='fname' value='Rick'/>" |
| 129 "<input name='lname' value='Deckard' autocomplete='off'/>" | 129 "<input name='lname' value='Deckard' autocomplete='off'/>" |
| 130 "</form></html>"); | 130 "</form></html>"); |
| 131 | 131 |
| 132 // Submit the form. | 132 // Submit the form. |
| 133 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 133 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 134 ProcessPendingMessages(); | 134 ProcessPendingMessages(); |
| 135 | 135 |
| 136 VerifyReceivedRendererMessages(render_thread_.get(), | 136 VerifyReceivedRendererMessages(render_thread_.get(), |
| 137 true /* expect_submitted_message */); | 137 true /* expect_submitted_message */); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Tests that submitting a form that has been dynamically set as autocomplete | 140 // Tests that submitting a form that has been dynamically set as autocomplete |
| 141 // off generates WillSubmitForm and FormSubmitted messages. | 141 // off generates WillSubmitForm and FormSubmitted messages. |
| 142 // Note: We previously did the opposite, for bug http://crbug.com/36520 | 142 // Note: We previously did the opposite, for bug http://crbug.com/36520 |
| 143 // Flaky: http://crbug.com/500851. | 143 // Flaky: http://crbug.com/500851. |
| 144 TEST_F(FormAutocompleteTest, DISABLED_DynamicAutoCompleteOffFormSubmit) { | 144 TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) { |
| 145 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" | 145 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" |
| 146 "<input name='lname' value='Deckard'/></form></html>"); | 146 "<input name='lname' value='Deckard'/></form></html>"); |
| 147 | 147 |
| 148 blink::WebElement element = | 148 blink::WebElement element = |
| 149 GetMainFrame()->document().getElementById(blink::WebString("myForm")); | 149 GetMainFrame()->document().getElementById(blink::WebString("myForm")); |
| 150 ASSERT_FALSE(element.isNull()); | 150 ASSERT_FALSE(element.isNull()); |
| 151 blink::WebFormElement form = element.to<blink::WebFormElement>(); | 151 blink::WebFormElement form = element.to<blink::WebFormElement>(); |
| 152 EXPECT_TRUE(form.autoComplete()); | 152 EXPECT_TRUE(form.autoComplete()); |
| 153 | 153 |
| 154 // Dynamically mark the form as autocomplete off. | 154 // Dynamically mark the form as autocomplete off. |
| 155 ExecuteJavaScript("document.getElementById('myForm')." | 155 ExecuteJavaScript("document.getElementById('myForm')." |
| 156 "setAttribute('autocomplete', 'off');"); | 156 "setAttribute('autocomplete', 'off');"); |
| 157 ProcessPendingMessages(); | 157 ProcessPendingMessages(); |
| 158 EXPECT_FALSE(form.autoComplete()); | 158 EXPECT_FALSE(form.autoComplete()); |
| 159 | 159 |
| 160 // Submit the form. | 160 // Submit the form. |
| 161 ExecuteJavaScript("document.getElementById('myForm').submit();"); | 161 ExecuteJavaScript("document.getElementById('myForm').submit();"); |
| 162 ProcessPendingMessages(); | 162 ProcessPendingMessages(); |
| 163 | 163 |
| 164 VerifyReceivedRendererMessages(render_thread_.get(), | 164 VerifyReceivedRendererMessages(render_thread_.get(), |
| 165 true /* expect_submitted_message */); | 165 true /* expect_submitted_message */); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace autofill | 168 } // namespace autofill |
| OLD | NEW |