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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java

Issue 767453003: [Android] Fix a subtle issue in Java Bridge regarding interfaces removal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « content/browser/android/java/gin_java_bridge_dispatcher_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java
index 6745a4085c73ae196401f1cc6449d8efa068f284..768f4c63931f53c337275ab01f634a48fb99009c 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java
@@ -172,15 +172,27 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase {
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
public void testRemovalNotReflectedUntilReload() throws Throwable {
- injectObjectAndReload(new Object(), "testObject");
+ injectObjectAndReload(new Object() {
+ public void method() {
+ mTestController.setStringValue("I'm here");
+ }
+ }, "testObject");
assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
+ executeJavaScript("testObject.method()");
+ assertEquals("I'm here", mTestController.waitForStringValue());
runTestOnUiThread(new Runnable() {
@Override
public void run() {
getContentViewCore().removeJavascriptInterface("testObject");
}
});
+ // Check that the Java object is being held by the Java bridge, thus it's not
+ // collected. Note that despite that what JavaDoc says about invoking "gc()", both Dalvik
+ // and ART actually run the collector if called via Runtime.
+ Runtime.getRuntime().gc();
assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
+ executeJavaScript("testObject.method()");
+ assertEquals("I'm here", mTestController.waitForStringValue());
synchronousPageReload();
assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject"));
}
« no previous file with comments | « content/browser/android/java/gin_java_bridge_dispatcher_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698