| Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
|
| index 472b253d547142a38af69ca85b6e301793ce4a50..3afecfe9acab39b815623c2e122831a8c334bf6b 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
|
| @@ -153,11 +153,39 @@ public class JavaBridgeCoercionTest extends JavaBridgeTestBase {
|
|
|
| private TestObject mTestObject;
|
|
|
| + private class TestController extends Controller {
|
| + private boolean mBooleanValue;
|
| +
|
| + public synchronized void setBooleanValue(boolean x) {
|
| + mBooleanValue = x;
|
| + notifyResultIsReady();
|
| + }
|
| + public synchronized boolean waitForBooleanValue() {
|
| + waitForResult();
|
| + return mBooleanValue;
|
| + }
|
| + }
|
| +
|
| + TestController mTestController;
|
| +
|
| + // Note that this requires that we can pass a JavaScript boolean to Java.
|
| + private void assertRaisesException(String script) throws Throwable {
|
| + executeJavaScript("try {" +
|
| + script + ";" +
|
| + " testController.setBooleanValue(false);" +
|
| + "} catch (exception) {" +
|
| + " testController.setBooleanValue(true);" +
|
| + "}");
|
| + assertTrue(mTestController.waitForBooleanValue());
|
| + }
|
| +
|
| @Override
|
| protected void setUp() throws Exception {
|
| super.setUp();
|
| mTestObject = new TestObject();
|
| setUpContentView(mTestObject, "testObject");
|
| + mTestController = new TestController();
|
| + setUpContentView(mTestController, "testController");
|
| }
|
|
|
| // Test passing a 32-bit integer JavaScript number to a method of an
|
| @@ -539,14 +567,11 @@ public class JavaBridgeCoercionTest extends JavaBridgeTestBase {
|
| executeJavaScript("testObject.setObjectValue(testObject.getCustomTypeInstance());");
|
| assertTrue(mTestObject.getCustomTypeInstance() == mTestObject.waitForObjectValue());
|
|
|
| - executeJavaScript("testObject.setCustomTypeValue(testObject.getObjectInstance());");
|
| - assertTrue(mTestObject.getObjectInstance() == mTestObject.waitForCustomTypeValue());
|
| + assertRaisesException("testObject.setCustomTypeValue(testObject.getObjectInstance());");
|
| executeJavaScript("testObject.setCustomTypeValue(testObject.getCustomTypeInstance());");
|
| assertTrue(mTestObject.getCustomTypeInstance() == mTestObject.waitForCustomTypeValue());
|
| - // LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception, as the types are unrelated.
|
| - executeJavaScript("testObject.setCustomTypeValue(testObject.getCustomType2Instance());");
|
| - assertTrue(mTestObject.getCustomType2Instance() ==
|
| - (Object)mTestObject.waitForCustomTypeValue());
|
| + assertRaisesException(
|
| + "testObject.setCustomTypeValue(testObject.getCustomType2Instance());");
|
|
|
| // LIVECONNECT_COMPLIANCE: Should call toString() on object.
|
| executeJavaScript("testObject.setStringValue(testObject.getObjectInstance());");
|
|
|