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

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

Issue 196283013: Make to call WebContentsImpl::RenderViewCreated() when we create child window. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 8 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: content/browser/web_contents/web_contents_impl_browsertest.cc
===================================================================
--- content/browser/web_contents/web_contents_impl_browsertest.cc (revision 256801)
+++ content/browser/web_contents/web_contents_impl_browsertest.cc (working copy)
@@ -385,4 +385,67 @@
EXPECT_EQ(observer.last_rfh(), shell()->web_contents()->GetMainFrame());
}
+class RenderViewCreatedObserver : public WebContentsObserver {
+ public:
+ static void Create(WebContents* web_contents) {
+ current_ = new RenderViewCreatedObserver(web_contents);
+ }
+
+ static void Clean() {
+ if (!current_) return;
+ delete current_;
+ current_ = NULL;
+ }
+
+ public:
+ RenderViewCreatedObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents),
+ call_render_view_created_(false) {
+ }
+
+ // WebContentsObserver:
+ virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE {
+ call_render_view_created_ = true;
+ }
+
+ bool call_render_view_created_;
+ static RenderViewCreatedObserver* current_;
+};
+
+RenderViewCreatedObserver* RenderViewCreatedObserver::current_ = NULL;
+
+class NewChildWindowNotificationObserver : public WindowedNotificationObserver {
+ public:
+ NewChildWindowNotificationObserver(WebContents* web_contens)
+ : WindowedNotificationObserver(
+ NOTIFICATION_WEB_CONTENTS_CREATE_NEW_WINDOW,
+ Source<WebContents>(web_contens)) {
+ }
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE {
+ if (type ==
+ NOTIFICATION_WEB_CONTENTS_CREATE_NEW_WINDOW) {
+ WebContents* child_web_contents =
+ content::Details<WebContents>(details).ptr();
+ RenderViewCreatedObserver::Create(child_web_contents);
+ }
+ WindowedNotificationObserver::Observe(type, source, details);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
+ RenderViewCreatedForChildWindow) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ NewChildWindowNotificationObserver observer(shell()->web_contents());
Charlie Reis 2014/04/29 16:55:25 You can use a ShellAddedObserver here instead, wit
+ NavigateToURL(shell(),
+ embedded_test_server()->GetURL("/openChildWindow.html"));
+
+ observer.Wait();
+ EXPECT_TRUE(
+ RenderViewCreatedObserver::current_->call_render_view_created_ == true);
Charlie Reis 2014/04/29 16:55:25 nit: No need for "== true"
+ RenderViewCreatedObserver::Clean();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698