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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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/core/common/autofill_messages.h" 7 #include "components/autofill/core/common/autofill_messages.h"
8 #include "components/autofill/core/common/form_data.h" 8 #include "components/autofill/core/common/form_data.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/platform/WebString.h" 10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/platform/WebURLError.h" 11 #include "third_party/WebKit/public/platform/WebURLError.h"
12 #include "third_party/WebKit/public/web/WebDocument.h" 12 #include "third_party/WebKit/public/web/WebDocument.h"
13 #include "third_party/WebKit/public/web/WebFormElement.h" 13 #include "third_party/WebKit/public/web/WebFormElement.h"
14 14
15 using WebKit::WebFrame; 15 using blink::WebFrame;
16 using WebKit::WebString; 16 using blink::WebString;
17 using WebKit::WebURLError; 17 using blink::WebURLError;
18 18
19 typedef ChromeRenderViewTest FormAutocompleteTest; 19 typedef ChromeRenderViewTest FormAutocompleteTest;
20 20
21 namespace autofill { 21 namespace autofill {
22 22
23 // Tests that submitting a form generates a FormSubmitted message 23 // Tests that submitting a form generates a FormSubmitted message
24 // with the form fields. 24 // with the form fields.
25 TEST_F(FormAutocompleteTest, NormalFormSubmit) { 25 TEST_F(FormAutocompleteTest, NormalFormSubmit) {
26 // Load a form. 26 // Load a form.
27 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" 27 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 EXPECT_EQ(WebString("Rick"), form_field.value); 94 EXPECT_EQ(WebString("Rick"), form_field.value);
95 } 95 }
96 96
97 // Tests that submitting a form that has been dynamically set as autocomplete 97 // Tests that submitting a form that has been dynamically set as autocomplete
98 // off does not generate a FormSubmitted message. 98 // off does not generate a FormSubmitted message.
99 // http://crbug.com/36520 99 // http://crbug.com/36520
100 TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) { 100 TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) {
101 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" 101 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>"
102 "<input name='lname' value='Deckard'/></form></html>"); 102 "<input name='lname' value='Deckard'/></form></html>");
103 103
104 WebKit::WebElement element = 104 blink::WebElement element =
105 GetMainFrame()->document().getElementById(WebKit::WebString("myForm")); 105 GetMainFrame()->document().getElementById(blink::WebString("myForm"));
106 ASSERT_FALSE(element.isNull()); 106 ASSERT_FALSE(element.isNull());
107 WebKit::WebFormElement form = element.to<WebKit::WebFormElement>(); 107 blink::WebFormElement form = element.to<blink::WebFormElement>();
108 EXPECT_TRUE(form.autoComplete()); 108 EXPECT_TRUE(form.autoComplete());
109 109
110 // Dynamically mark the form as autocomplete off. 110 // Dynamically mark the form as autocomplete off.
111 ExecuteJavaScript("document.getElementById('myForm')." 111 ExecuteJavaScript("document.getElementById('myForm')."
112 "setAttribute('autocomplete', 'off');"); 112 "setAttribute('autocomplete', 'off');");
113 ProcessPendingMessages(); 113 ProcessPendingMessages();
114 EXPECT_FALSE(form.autoComplete()); 114 EXPECT_FALSE(form.autoComplete());
115 115
116 // Submit the form. 116 // Submit the form.
117 ExecuteJavaScript("document.getElementById('myForm').submit();"); 117 ExecuteJavaScript("document.getElementById('myForm').submit();");
118 ProcessPendingMessages(); 118 ProcessPendingMessages();
119 119
120 // No FormSubmitted message should have been sent. 120 // No FormSubmitted message should have been sent.
121 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 121 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
122 AutofillHostMsg_FormSubmitted::ID)); 122 AutofillHostMsg_FormSubmitted::ID));
123 } 123 }
124 124
125 } // namespace autofill 125 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/autofill_renderer_browsertest.cc ('k') | chrome/renderer/autofill/form_autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698