1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.content.browser;
7 import android.test.suitebuilder.annotation.SmallTest;
9 import org.chromium.base.test.util.Feature;
12 * Part of the test suite for the WebView's Java Bridge.
14 * Ensures that injected objects are exposed to child frames as well as the
17 public class JavaBridgeChildFrameTest extends JavaBridgeTestBase {
18 private class TestController extends Controller {
19 private String mStringValue;
21 @SuppressWarnings("unused") // Called via reflection
22 public synchronized void setStringValue(String x) {
24 notifyResultIsReady();
26 public synchronized String waitForStringValue() {
32 TestController mTestController;
35 protected void setUp() throws Exception {
37 mTestController = new TestController();
38 setUpContentView(mTestController, "testController");
42 @Feature({"AndroidWebView", "Android-JavaBridge"})
43 public void testInjectedObjectPresentInChildFrame() throws Throwable {
44 // In the case that the test fails (i.e. the child frame doesn't get the injected object,
45 // the call to testController.setStringValue in the child frame's onload handler will
47 loadDataSync(getContentViewCore(),
48 "<html><head></head><body>" +
49 "<iframe id=\"childFrame\" onload=\"testController.setStringValue('PASS');\" />" +
50 "</body></html>", "text/html", false);
51 assertEquals("PASS", mTestController.waitForStringValue());