Commit 414a9028 authored by jinsukkim's avatar jinsukkim Committed by Commit bot

Add a test for RenderWidgetHostConnector

A new test got added to render_widget_host_connector_browsertest.cc
which ensures RWHVA gets connected to objects inheriting
RenderWidgetHostConnector regardless of the order in which they
are created. Previously this had a bug resulting in RWHVA not
connected ImeAdapter if RWHVA was created first, hence keeping
soft keyboard from showing up.

Also removed |WebContentsObserver::RenderViewReady()| override. It was
overridden to initialize rwvha in the connector after creation. But it
only covers the following cases:

- connector created -> rwhva created -> RenderViewReady invoked
- rwhva created -> connector created -> RenderViewReady invoked

Can't cover the following case:
 - rwhva created -> RenderViewReady invoked -> connector created

Now Initialize() covers them all, the method became redundant.

BUG=713924

Review-Url: https://codereview.chromium.org/2840443002
Cr-Commit-Position: refs/heads/master@{#466877}
parent 9649adfe
......@@ -19,7 +19,6 @@ class RenderWidgetHostConnector::Observer
~Observer() override;
// WebContentsObserver implementation.
void RenderViewReady() override;
void RenderViewHostChanged(RenderViewHost* old_host,
RenderViewHost* new_host) override;
void DidAttachInterstitialPage() override;
......@@ -55,10 +54,6 @@ RenderWidgetHostConnector::Observer::~Observer() {
DCHECK(!active_rwhva_);
}
void RenderWidgetHostConnector::Observer::RenderViewReady() {
UpdateRenderWidgetHostView(GetRenderWidgetHostViewAndroid());
}
void RenderWidgetHostConnector::Observer::RenderViewHostChanged(
RenderViewHost* old_host,
RenderViewHost* new_host) {
......
......@@ -8,6 +8,7 @@
#include "content/public/browser/interstitial_page_delegate.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
......@@ -32,6 +33,26 @@ void RenderWidgetHostConnectorTest::SetUpOnMainThread() {
ASSERT_TRUE(embedded_test_server()->Start());
}
IN_PROC_BROWSER_TEST_F(RenderWidgetHostConnectorTest,
RenderViewCreatedBeforeConnector) {
GURL main_url(embedded_test_server()->GetURL("/page_with_popup.html"));
EXPECT_TRUE(NavigateToURL(shell(), main_url));
// Navigate to the enclosed <iframe>.
FrameTreeNode* iframe = web_contents()->GetFrameTree()->root()->child_at(0);
GURL frame_url(embedded_test_server()->GetURL("/title1.html"));
NavigateFrameToURL(iframe, frame_url);
// Open a popup from the iframe. This creates a render widget host view
// view before the corresponding web contents. Tests if rwhva gets connected.
Shell* new_shell = OpenPopup(iframe, GURL(url::kAboutBlankURL), "");
EXPECT_TRUE(new_shell);
auto* rwhva_popup = static_cast<RenderWidgetHostViewAndroid*>(
new_shell->web_contents()->GetRenderWidgetHostView());
EXPECT_TRUE(connector_in_rwhva(rwhva_popup) != nullptr);
}
IN_PROC_BROWSER_TEST_F(RenderWidgetHostConnectorTest,
UpdateRWHVAInConnectorAtRenderViewHostSwapping) {
net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
......
<html>
<title>page with a iframe for popup</title>
<head></head>
<body>
<iframe id="test"></iframe>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment