1 // Copyright (c) 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 public synchronized void setStringValue(String x) {
23 notifyResultIsReady();
25 public synchronized String waitForStringValue() {
31 TestController mTestController;
34 protected void setUp() throws Exception {
36 mTestController = new TestController();
37 setUpContentView(mTestController, "testController");
41 @Feature({"AndroidWebView", "Android-JavaBridge"})
42 public void testInjectedObjectPresentInChildFrame() throws Throwable {
43 // In the case that the test fails (i.e. the child frame doesn't get the injected object,
44 // the call to testController.setStringValue in the child frame's onload handler will
46 loadDataSync(getContentView(),
47 "<html><head></head><body>" +
48 "<iframe id=\"childFrame\" onload=\"testController.setStringValue('PASS');\" />" +
49 "</body></html>", "text/html", false);
50 assertEquals("PASS", mTestController.waitForStringValue());