| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "components/autofill/content/common/autofill_messages.h" | 9 #include "components/autofill/content/common/autofill_messages.h" |
| 10 #include "components/autofill/content/renderer/autofill_agent.h" | 10 #include "components/autofill/content/renderer/autofill_agent.h" |
| 11 #include "components/autofill/core/common/form_data.h" | 11 #include "components/autofill/core/common/form_data.h" |
| 12 #include "components/autofill/core/common/form_field_data.h" | 12 #include "components/autofill/core/common/form_field_data.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 17 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
| 18 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
| 19 #include "third_party/WebKit/public/web/WebFormElement.h" | 19 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 20 #include "third_party/WebKit/public/web/WebFrame.h" | |
| 21 #include "third_party/WebKit/public/web/WebInputElement.h" | 20 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 23 | 22 |
| 24 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
| 25 using blink::WebDocument; | 24 using blink::WebDocument; |
| 26 using blink::WebElement; | 25 using blink::WebElement; |
| 27 using blink::WebFormElement; | 26 using blink::WebFormElement; |
| 28 using blink::WebFrame; | 27 using blink::WebFrame; |
| 29 using blink::WebLocalFrame; | 28 using blink::WebLocalFrame; |
| 30 using blink::WebInputElement; | 29 using blink::WebInputElement; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 LoadHTML(base::StringPrintf(kDoubleIframeHtml, url.spec().c_str()).c_str()); | 208 LoadHTML(base::StringPrintf(kDoubleIframeHtml, url.spec().c_str()).c_str()); |
| 210 | 209 |
| 211 WebElement subframe = GetMainFrame()->document().getElementById("subframe"); | 210 WebElement subframe = GetMainFrame()->document().getElementById("subframe"); |
| 212 ASSERT_FALSE(subframe.isNull()); | 211 ASSERT_FALSE(subframe.isNull()); |
| 213 invoking_frame_ = WebLocalFrame::fromFrameOwnerElement(subframe); | 212 invoking_frame_ = WebLocalFrame::fromFrameOwnerElement(subframe); |
| 214 ASSERT_TRUE(invoking_frame()); | 213 ASSERT_TRUE(invoking_frame()); |
| 215 ASSERT_EQ(GetMainFrame(), invoking_frame()->parent()); | 214 ASSERT_EQ(GetMainFrame(), invoking_frame()->parent()); |
| 216 | 215 |
| 217 WebElement sibling = GetMainFrame()->document().getElementById("sibling"); | 216 WebElement sibling = GetMainFrame()->document().getElementById("sibling"); |
| 218 ASSERT_FALSE(sibling.isNull()); | 217 ASSERT_FALSE(sibling.isNull()); |
| 219 sibling_frame_ = WebFrame::fromFrameOwnerElement(sibling); | 218 sibling_frame_ = WebLocalFrame::fromFrameOwnerElement(sibling); |
| 220 ASSERT_TRUE(sibling_frame()); | 219 ASSERT_TRUE(sibling_frame()); |
| 221 | 220 |
| 222 WebVector<WebFormElement> forms; | 221 WebVector<WebFormElement> forms; |
| 223 invoking_frame()->document().forms(forms); | 222 invoking_frame()->document().forms(forms); |
| 224 ASSERT_EQ(1U, forms.size()); | 223 ASSERT_EQ(1U, forms.size()); |
| 225 invoking_form_ = forms[0]; | 224 invoking_form_ = forms[0]; |
| 226 ASSERT_FALSE(invoking_form().isNull()); | 225 ASSERT_FALSE(invoking_form().isNull()); |
| 227 | 226 |
| 228 render_thread_->sink().ClearMessages(); | 227 render_thread_->sink().ClearMessages(); |
| 229 | 228 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 300 } |
| 302 | 301 |
| 303 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { | 302 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { |
| 304 // Attempting to show the requestAutocomplete dialog again should be ignored. | 303 // Attempting to show the requestAutocomplete dialog again should be ignored. |
| 305 autofill_agent_->didRequestAutocomplete(invoking_frame(), invoking_form()); | 304 autofill_agent_->didRequestAutocomplete(invoking_frame(), invoking_form()); |
| 306 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 305 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 307 AutofillHostMsg_RequestAutocomplete::ID)); | 306 AutofillHostMsg_RequestAutocomplete::ID)); |
| 308 } | 307 } |
| 309 | 308 |
| 310 } // namespace autofill | 309 } // namespace autofill |
| OLD | NEW |