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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwJavaBridgeTest.java

Issue 498633003: Cache pending JS bridge sync IPC replies, and send in case of RenderFrame deletion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spelling Created 6 years, 4 months 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 | « no previous file | content/browser/android/java/gin_java_bridge_dispatcher_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwJavaBridgeTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwJavaBridgeTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwJavaBridgeTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a15244bb79db2a4c12a869017d8bba3f0219716
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwJavaBridgeTest.java
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.test;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.android_webview.AwContents;
+import org.chromium.base.test.util.Feature;
+import org.chromium.content.browser.JavascriptInterface;
+
+/**
+ * Test suite for the WebView specific JavaBridge features.
+ */
+public class AwJavaBridgeTest extends AwTestBase {
+
+ private TestAwContentsClient mContentsClient = new TestAwContentsClient();
+ private AwTestContainerView mTestContainerView;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTestContainerView = createAwTestContainerViewOnMainSync(mContentsClient);
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView", "Android-JavaBridge"})
+ public void testDestroyFromJavaObject() throws Throwable {
+ final String HTML = "<html>Hello World</html>";
+ final TestAwContentsClient client2 = new TestAwContentsClient();
+ final AwTestContainerView view2 = createAwTestContainerViewOnMainSync(client2);
+ final AwContents awContents = mTestContainerView.getAwContents();
+
+ class Test {
+ @JavascriptInterface
+ public void destroy() {
+ try {
+ runTestOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ awContents.destroy();
+ }
+ });
+ // Destroying one AwContents from within the JS callback should still
+ // leave others functioning.
+ loadDataSync(view2.getAwContents(), client2.getOnPageFinishedHelper(),
+ HTML, "text/html", false);
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+ }
+
+ enableJavaScriptOnUiThread(awContents);
+ runTestOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ awContents.addPossiblyUnsafeJavascriptInterface(new Test(), "test", null);
+ }
+ });
+
+ loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(), HTML,
+ "text/html", false);
+
+ // Ensure the JS interface object is there, and invoke the test method.
+ assertEquals("\"function\"", executeJavaScriptAndWaitForResult(
+ awContents, mContentsClient, "typeof test.destroy"));
+ awContents.evaluateJavaScript("test.destroy()", null);
+
+ client2.getOnPageFinishedHelper().waitForCallback(
+ client2.getOnPageFinishedHelper().getCallCount());
+ }
+}
« no previous file with comments | « no previous file | content/browser/android/java/gin_java_bridge_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698