Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| index 447ec218d2e08994d50fe525a8fd825fcfa9bd56..ca16cf58bd867b807d529ecd28d6666a5d20f7ca 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| @@ -473,14 +473,17 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { |
| } |
| void InitiateDialog() { |
| - dom_message_queue_.reset(new content::DOMMessageQueue); |
| - |
| + InitializeDOMMessageQueue(); |
|
Dan Beam
2014/12/19 01:59:34
nit: InitializeDomMessageQueue() (I'm pretty sure
|
| // Triggers the onclick handler which invokes requestAutocomplete(). |
| content::WebContents* contents = GetActiveWebContents(); |
| content::SimulateMouseClick(contents, 0, blink::WebMouseEvent::ButtonLeft); |
| ExpectDomMessage("clicked"); |
| } |
| + void InitializeDOMMessageQueue() { |
| + dom_message_queue_.reset(new content::DOMMessageQueue); |
| + } |
| + |
| // Returns the value filled into the first field with autocomplete attribute |
| // equal to |autocomplete_type|, or an empty string if there is no such field. |
| std::string GetValueForHTMLFieldOfType(const std::string& autocomplete_type) { |
| @@ -1761,4 +1764,61 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_); |
| } |
| +IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, HideOnNavigate) { |
| + base::WeakPtr<TestAutofillDialogController> weak_ptr = |
| + controller()->AsWeakPtr(); |
| + EXPECT_TRUE(weak_ptr.get()); |
| + |
| + ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| + EXPECT_FALSE(weak_ptr.get()); |
| +} |
| + |
| +// Tests that the rAc dialog hides when the main frame is navigated, even if |
| +// it was invoked from a child frame. |
| +IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, HideOnNavigateMainFrame) { |
| + |
|
Dan Beam
2014/12/19 01:59:34
nit: ^H
Evan Stade
2014/12/19 21:21:12
Done.
|
| + net::SpawnedTestServer http_server( |
| + net::SpawnedTestServer::TYPE_HTTP, |
| + net::SpawnedTestServer::kLocalhost, |
| + base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| + ASSERT_TRUE(http_server.Start()); |
| + |
| + InitializeDOMMessageQueue(); |
| + GURL iframe_url = http_server.GetURL( |
| + "files/request_autocomplete/test_page.html"); |
| + |
| + ui_test_utils::NavigateToURL( |
| + browser(), GURL(std::string("data:text/html,") + |
| + "<!doctype html>" |
| + "<html>" |
| + "<body>" |
| + "<iframe style='position: fixed;" |
| + "height: 100%;" |
| + "width: 100%;'" |
| + "id='racFrame'></iframe>" |
| + "<script>" |
| + "function send(msg) {" |
| + "domAutomationController.setAutomationId(0);" |
| + "domAutomationController.send(msg);" |
| + "}" |
| + "var racFrame = document.getElementById('racFrame');" |
| + "racFrame.onload = function() {" |
| + "send('iframe loaded');" |
| + "};" |
| + "racFrame.src = \"" + iframe_url.spec() + "\";" |
| + "</script>" |
| + "</body>" |
| + "</html>")); |
| + |
| + ChromeAutofillClient* client = |
| + ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
| + ExpectDomMessage("iframe loaded"); |
| + EXPECT_FALSE(client->GetDialogControllerForTesting()); |
| + InitiateDialog(); |
| + |
| + EXPECT_TRUE(client->GetDialogControllerForTesting()); |
| + ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| + EXPECT_FALSE(client->GetDialogControllerForTesting()); |
| +} |
| + |
| } // namespace autofill |