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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 796493004: Remove FrameDetached and FrameWillClose listeners from AutofillAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix init order Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
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 bac59cef9ad888292ee71370de18176c960bd5c1..401731ce4212081f71ab374ee23f1f95b2466713 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
@@ -462,6 +462,45 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
return !!controller;
}
+ void RunTestPageInIframe(const net::SpawnedTestServer& server) {
+ InitializeDOMMessageQueue();
+ GURL iframe_url = 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() + "\";"
+ "function navigateFrame() {"
+ "racFrame.src = 'about:blank';"
+ "}"
+ "</script>"
+ "</body>"
+ "</html>"));
+
+ ChromeAutofillClient* client =
+ ChromeAutofillClient::FromWebContents(GetActiveWebContents());
+ ExpectDomMessage("iframe loaded");
+ EXPECT_FALSE(client->GetDialogControllerForTesting());
+ InitiateDialog();
+ EXPECT_TRUE(client->GetDialogControllerForTesting());
+ }
+
// Wait for a message from the DOM automation controller (from JS in the
// page). Requires |SetUpHtmlAndInvoke()| be called first.
void ExpectDomMessage(const std::string& expected) {
@@ -472,14 +511,17 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
}
void InitiateDialog() {
- dom_message_queue_.reset(new content::DOMMessageQueue);
-
+ InitializeDOMMessageQueue();
// 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) {
@@ -1773,4 +1815,48 @@ 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) {
+ net::SpawnedTestServer http_server(
+ net::SpawnedTestServer::TYPE_HTTP,
+ net::SpawnedTestServer::kLocalhost,
+ base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
+ ASSERT_TRUE(http_server.Start());
+ RunTestPageInIframe(http_server);
+
+ ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
+ ChromeAutofillClient* client =
+ ChromeAutofillClient::FromWebContents(GetActiveWebContents());
+ EXPECT_FALSE(client->GetDialogControllerForTesting());
+}
+
+// Tests that the rAc dialog hides when the iframe it's in is navigated.
+IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, HideOnNavigateIframe) {
+ net::SpawnedTestServer http_server(
+ net::SpawnedTestServer::TYPE_HTTP,
+ net::SpawnedTestServer::kLocalhost,
+ base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
+ ASSERT_TRUE(http_server.Start());
+ RunTestPageInIframe(http_server);
+
+ std::string unused;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(),
+ "navigateFrame();",
+ &unused));
+ ExpectDomMessage("iframe loaded");
+ ChromeAutofillClient* client =
+ ChromeAutofillClient::FromWebContents(GetActiveWebContents());
+ EXPECT_FALSE(client->GetDialogControllerForTesting());
+}
+
} // namespace autofill
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.h ('k') | chrome/browser/ui/autofill/chrome_autofill_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698