Commit 20901fef authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[WebLayer] Destroy InfoBarContainer on Tab destruction

Neglected in the initial wiring up of infobars in WebLayer.

Bug: 1093846
Change-Id: I5fff123f3948c930ec78cfe80de3ed31785d287b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2257218Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781387}
parent 5875777d
......@@ -19,6 +19,7 @@ import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.weblayer.Browser;
import org.chromium.weblayer.Tab;
import org.chromium.weblayer.TestWebLayer;
import org.chromium.weblayer.shell.InstrumentationActivity;
......@@ -118,4 +119,22 @@ public class InfoBarTest {
CriteriaHelper.pollUiThread(
() -> Assert.assertEquals(0, (int) infoBarContainerView.getTranslationY()));
}
@Test
@SmallTest
/**
* Tests that the infobar container view is removed as part of tab destruction.
*
*/
public void testTabDestruction() throws Exception {
View infoBarContainerView = getInfoBarContainerView();
Assert.assertNotNull(infoBarContainerView.getParent());
TestThreadUtils.runOnUiThreadBlocking(() -> {
Browser browser = mActivityTestRule.getActivity().getBrowser();
browser.destroyTab(getActiveTab());
});
Assert.assertEquals(infoBarContainerView.getParent(), null);
}
}
......@@ -287,7 +287,7 @@ public class InfoBarContainer implements KeyboardVisibilityListener, InfoBar.Con
}
public void destroy() {
destroyContainerView();
if (mInfoBarContainerView != null) destroyContainerView();
if (mNativeInfoBarContainer != 0) {
InfoBarContainerJni.get().destroy(mNativeInfoBarContainer, InfoBarContainer.this);
mNativeInfoBarContainer = 0;
......
......@@ -354,7 +354,13 @@ public final class TabImpl extends ITab.Stub implements LoginPrompt.Observer {
public void onDidLoseActive() {
hideFindInPageUiAndNotifyClient();
updateWebContentsVisibility();
mInfoBarContainer.onTabDidLoseActive();
// This method is called as part of the final phase of TabImpl destruction, at which
// point mInfoBarContainer has already been destroyed.
if (mInfoBarContainer != null) {
mInfoBarContainer.onTabDidLoseActive();
}
TabImplJni.get().setBrowserControlsContainerViews(mNativeTab, 0, 0);
}
......@@ -771,6 +777,9 @@ public final class TabImpl extends ITab.Stub implements LoginPrompt.Observer {
mInterceptNavigationDelegateClient.destroy();
mInterceptNavigationDelegate = null;
mInfoBarContainer.destroy();
mInfoBarContainer = null;
mMediaStreamManager.destroy();
mMediaStreamManager = null;
......
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