Commit f622136b authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Make RemoteObjectHostImpl#close properly close the registry.

Noticed by inspection of the code which was obviously wrong.
Added a test for this.

Bug: 794320
Change-Id: Idca62abb1e9ec8719235528b213f9ca5f7e82e0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829760
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700878}
parent 3deab63e
...@@ -83,7 +83,7 @@ class RemoteObjectHostImpl implements RemoteObjectHost { ...@@ -83,7 +83,7 @@ class RemoteObjectHostImpl implements RemoteObjectHost {
@Override @Override
public void close() { public void close() {
RemoteObjectRegistry registry = mRegistry.get(); RemoteObjectRegistry registry = mRegistry.get();
if (registry != null) { if (registry == null) {
return; return;
} }
registry.close(); registry.close();
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
package org.chromium.content.browser.remoteobjects; package org.chromium.content.browser.remoteobjects;
import static org.hamcrest.Matchers.isIn;
import static org.hamcrest.Matchers.not;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
import org.junit.Assert; import org.junit.Assert;
...@@ -146,4 +149,15 @@ public final class RemoteObjectHostImplTest { ...@@ -146,4 +149,15 @@ public final class RemoteObjectHostImplTest {
host.releaseObject(id); host.releaseObject(id);
Assert.assertNull(mRegistry.getObjectById(id)); Assert.assertNull(mRegistry.getObjectById(id));
} }
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
public void testClose() {
RemoteObjectHostImpl host = new RemoteObjectHostImpl(
TestJavascriptInterface.class, /* auditor */ null, mRegistry);
Assert.assertThat(mRegistry, isIn(mRetainingSet));
host.close();
Assert.assertThat(mRegistry, not(isIn(mRetainingSet)));
}
} }
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