Commit d3ee3f44 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Fix a failing test TabsTest#HideKeyboard

It is possible that a few android.view.View APIs are called
after WebContents gets destroyed. This CL keeps them from
accessing the destroyed instance by safeguarding it at
ContentView where they pass through.

Alternatively this could be done at embedder level (i.e. parent
view of ContentView), but this approach reduces duplicated code.

And re-enabled the disabled test.

Bug: 821750
Change-Id: Ied55e7d36c589e6e7e324d081204c9a1294da7b2
Reviewed-on: https://chromium-review.googlesource.com/963149Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543249}
parent 2f862dc3
...@@ -311,7 +311,6 @@ public class TabsTest { ...@@ -311,7 +311,6 @@ public class TabsTest {
* Verify that opening a new tab, switching to an existing tab and closing current tab hide * Verify that opening a new tab, switching to an existing tab and closing current tab hide
* keyboard. * keyboard.
*/ */
@DisabledTest(message = "crbug.com/821750")
@Test @Test
@LargeTest @LargeTest
@Restriction(UiRestriction.RESTRICTION_TYPE_TABLET) @Restriction(UiRestriction.RESTRICTION_TYPE_TABLET)
......
...@@ -85,7 +85,10 @@ public class ContentView ...@@ -85,7 +85,10 @@ public class ContentView
} }
protected WebContentsAccessibility getWebContentsAccessibility() { protected WebContentsAccessibility getWebContentsAccessibility() {
return WebContentsAccessibility.fromWebContents(mWebContents); // TODO(jinsukkim): Make it possible to check WebContents directly rather than doing it
// via examining the availiability of ContentViewCore;
return getContentViewCore() != null ? WebContentsAccessibility.fromWebContents(mWebContents)
: null;
} }
@Override @Override
...@@ -133,12 +136,14 @@ public class ContentView ...@@ -133,12 +136,14 @@ public class ContentView
@Override @Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (getContentViewCore() == null) return null;
return ImeAdapter.fromWebContents(mWebContents).onCreateInputConnection(outAttrs); return ImeAdapter.fromWebContents(mWebContents).onCreateInputConnection(outAttrs);
} }
@Override @Override
public boolean onCheckIsTextEditor() { public boolean onCheckIsTextEditor() {
if (mWebContents == null) return false; if (getContentViewCore() == null) return false;
return ImeAdapter.fromWebContents(mWebContents).onCheckIsTextEditor(); return ImeAdapter.fromWebContents(mWebContents).onCheckIsTextEditor();
} }
......
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