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

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

Issue 10911131: Upstream JavaBridge tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing check_deps failure Created 8 years, 3 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
Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeChildFrameTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeChildFrameTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeChildFrameTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..18eb9119d9a3465f2df989a866a61844d303df34
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeChildFrameTest.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 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.content.browser;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.test.util.Feature;
+
+/**
+ * Part of the test suite for the WebView's Java Bridge.
+ *
+ * Ensures that injected objects are exposed to child frames as well as the
+ * main frame.
+ */
+public class JavaBridgeChildFrameTest extends JavaBridgeTestBase {
+ private class TestController extends Controller {
+ private String mStringValue;
+
+ public synchronized void setStringValue(String x) {
+ mStringValue = x;
+ notifyResultIsReady();
+ }
+ public synchronized String waitForStringValue() {
+ waitForResult();
+ return mStringValue;
+ }
+ }
+
+ TestController mTestController;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTestController = new TestController();
+ setUpContentView(mTestController, "testController");
+ }
+
+ @SmallTest
+ @Feature({"Android-WebView", "Android-JavaBridge"})
+ public void testInjectedObjectPresentInChildFrame() throws Throwable {
+ // In the case that the test fails (i.e. the child frame doesn't get the injected object,
+ // the call to testController.setStringValue in the child frame's onload handler will
+ // not be made.
+ loadDataSync(getContentView(),
+ "<html><head></head><body>" +
+ "<iframe id=\"childFrame\" onload=\"testController.setStringValue('PASS');\" />" +
+ "</body></html>", "text/html", false);
+ assertEquals("PASS", mTestController.waitForStringValue());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698