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

Unified Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 2949593003: Move navigation-induced hiding of form-validation-bubble to the browser process. (Closed)
Patch Set: Remove now unnecessary call from WebContentsImpl::RenderViewTerminated to delegate_->HideValidation… Created 3 years, 6 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_browsertest.cc
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc
index 2f161b0134423a18edfa73ad2a9d3d710586340e..fea1eb689970be47a719c141df99207907b1f4c4 100644
--- a/content/browser/web_contents/web_contents_impl_browsertest.cc
+++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -1467,4 +1467,78 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
wc->SetJavaScriptDialogManagerForTesting(nullptr);
}
+class FormBubbleDelegate : public WebContentsDelegate {
+ public:
+ FormBubbleDelegate() = default;
+
+ void WaitUntilShown() {
+ while (!is_visible_) {
+ message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_->Run();
+ }
+ }
+
+ void WaitUntilHidden() {
+ while (is_visible_) {
+ message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_->Run();
+ }
+ }
+
+ private:
+ void ShowValidationMessage(WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const base::string16& main_text,
+ const base::string16& sub_text) override {
+ is_visible_ = true;
+ if (message_loop_runner_)
+ message_loop_runner_->Quit();
+ }
+
+ void HideValidationMessage(WebContents* web_contents) override {
+ is_visible_ = false;
+ if (message_loop_runner_)
+ message_loop_runner_->Quit();
+ }
+
+ bool is_visible_ = false;
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+};
+
+IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
+ NavigationHidesFormValidationBubble) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+ EXPECT_TRUE(NavigateToURL(
+ shell(), embedded_test_server()->GetURL("a.com", "/title1.html")));
+
+ // Start listening for requests to show or hide the form validation bubble.
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+ FormBubbleDelegate bubble_delegate;
+ web_contents->SetDelegate(&bubble_delegate);
+
+ // Trigger a form validation bubble and verify that the bubble is shown.
+ std::string script = R"(
+ var input_field = document.createElement('input');
+ input_field.required = true;
+ var form = document.createElement('form');
+ form.appendChild(input_field);
+ document.body.appendChild(form);
+
+ setTimeout(function() {
+ input_field.setCustomValidity('Custom validity message');
+ input_field.reportValidity();
+ },
+ 0);
+ )";
+ ASSERT_TRUE(ExecuteScript(web_contents, script));
+ bubble_delegate.WaitUntilShown();
+
+ // Navigate to another page and verify that the form validation bubble is
+ // hidden.
+ EXPECT_TRUE(NavigateToURL(
+ shell(), embedded_test_server()->GetURL("b.com", "/title2.html")));
+ bubble_delegate.WaitUntilHidden();
+}
+
} // namespace content
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698