Commit 2ea849e2 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

[remoteobjects] Use new codepath for Java bridge in instrumentation tests

This CL is parameterizing the Java bridge instrumentation tests to
run with and without using Mojo in JavascriptInjector, running all
the relevant tests and using
JavaBridgeActivityTestRule#MojoTestParams for the ones that pass
and JavaBridgeActivityTestRule#LegacyTestParams for the ones that
fails. So, all tests still run for the old codepath.

Bug: 1105928
Change-Id: Idb3ee3ed4d1cb49fa0fc37d7609ac2e8ef166177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348488Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#798370}
parent ef690472
...@@ -11,6 +11,8 @@ import org.junit.runners.model.Statement; ...@@ -11,6 +11,8 @@ import org.junit.runners.model.Statement;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.test.SetUpStatement; import org.chromium.base.test.SetUpStatement;
import org.chromium.base.test.SetUpTestRule; import org.chromium.base.test.SetUpTestRule;
import org.chromium.base.test.params.ParameterProvider;
import org.chromium.base.test.params.ParameterSet;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.content_public.browser.JavascriptInjector; import org.chromium.content_public.browser.JavascriptInjector;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
...@@ -20,14 +22,44 @@ import org.chromium.content_shell_apk.ContentShellActivity; ...@@ -20,14 +22,44 @@ import org.chromium.content_shell_apk.ContentShellActivity;
import org.chromium.content_shell_apk.ContentShellActivityTestRule; import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;
/** /**
* ActivityTestRule with common functionality for testing the Java Bridge. * ActivityTestRule with common functionality for testing the Java Bridge.
*/ */
public class JavaBridgeActivityTestRule public class JavaBridgeActivityTestRule
extends ContentShellActivityTestRule implements SetUpTestRule<JavaBridgeActivityTestRule> { extends ContentShellActivityTestRule implements SetUpTestRule<JavaBridgeActivityTestRule> {
/**
* {@link ParameterProvider} used for parameterized test that provides the Mojo usage state.
*/
public static class MojoTestParams implements ParameterProvider {
private static List<ParameterSet> sMojoTestParams =
Arrays.asList(new ParameterSet().value(false).name("MojoUnused"),
new ParameterSet().value(true).name("MojoUsed"));
@Override
public List<ParameterSet> getParameters() {
return sMojoTestParams;
}
}
/**
* {@link ParameterProvider} used for parameterized test that keeps the legacy tests.
*/
public static class LegacyTestParams implements ParameterProvider {
private static List<ParameterSet> sLegacyTestParams =
Arrays.asList(new ParameterSet().value(false));
@Override
public List<ParameterSet> getParameters() {
return sLegacyTestParams;
}
}
private TestCallbackHelperContainer mTestCallbackHelperContainer; private TestCallbackHelperContainer mTestCallbackHelperContainer;
private boolean mSetup; private boolean mSetup;
private boolean mUseMojo;
public static class Controller { public static class Controller {
private static final int RESULT_WAIT_TIME = 5000; private static final int RESULT_WAIT_TIME = 5000;
...@@ -116,7 +148,8 @@ public class JavaBridgeActivityTestRule ...@@ -116,7 +148,8 @@ public class JavaBridgeActivityTestRule
@Override @Override
public void run() { public void run() {
WebContents webContents = getWebContents(); WebContents webContents = getWebContents();
JavascriptInjector injector = JavascriptInjector.fromWebContents(webContents); JavascriptInjector injector =
JavascriptInjector.fromWebContents(webContents, mUseMojo);
injector.addPossiblyUnsafeInterface(object1, name1, requiredAnnotation); injector.addPossiblyUnsafeInterface(object1, name1, requiredAnnotation);
if (object2 != null && name2 != null) { if (object2 != null && name2 != null) {
injector.addPossiblyUnsafeInterface(object2, name2, requiredAnnotation); injector.addPossiblyUnsafeInterface(object2, name2, requiredAnnotation);
...@@ -130,6 +163,9 @@ public class JavaBridgeActivityTestRule ...@@ -130,6 +163,9 @@ public class JavaBridgeActivityTestRule
"Failed to injectObjectsAndReload: " + Log.getStackTraceString(e)); "Failed to injectObjectsAndReload: " + Log.getStackTraceString(e));
} }
} }
public void setupMojoTest(boolean useMojo) {
mUseMojo = useMojo;
}
public void synchronousPageReload() throws Throwable { public void synchronousPageReload() throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
......
...@@ -12,7 +12,11 @@ import org.junit.Rule; ...@@ -12,7 +12,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
...@@ -27,7 +31,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; ...@@ -27,7 +31,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not * FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210. * break backwards-compatibility. See b/4408210.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeArrayCoercionTest { public class JavaBridgeArrayCoercionTest {
private static final double ASSERTION_DELTA = 0; private static final double ASSERTION_DELTA = 0;
...@@ -158,6 +163,11 @@ public class JavaBridgeArrayCoercionTest { ...@@ -158,6 +163,11 @@ public class JavaBridgeArrayCoercionTest {
private static class CustomType { private static class CustomType {
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject; private TestObject mTestObject;
@Before @Before
...@@ -174,7 +184,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -174,7 +184,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberInt32() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInt32(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([0]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([0]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
// LIVECONNECT_COMPLIANCE: Should convert to boolean. // LIVECONNECT_COMPLIANCE: Should convert to boolean.
...@@ -220,7 +231,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -220,7 +231,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberDouble() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberDouble(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should convert to boolean. // LIVECONNECT_COMPLIANCE: Should convert to boolean.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([42.1]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([42.1]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
...@@ -265,7 +277,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -265,7 +277,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberNaN() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberNaN(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Number.NaN]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Number.NaN]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
...@@ -308,7 +321,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -308,7 +321,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberInfinity() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInfinity(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Infinity]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Infinity]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
...@@ -354,7 +368,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -354,7 +368,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassBoolean() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassBoolean(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([true]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([true]);");
Assert.assertTrue(mTestObject.waitForBooleanArray()[0]); Assert.assertTrue(mTestObject.waitForBooleanArray()[0]);
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([false]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([false]);");
...@@ -420,7 +435,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -420,7 +435,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassString() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassString(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Non-empty string should convert to true. // LIVECONNECT_COMPLIANCE: Non-empty string should convert to true.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([\"+042.10\"]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([\"+042.10\"]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
...@@ -470,7 +486,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -470,7 +486,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassJavaScriptObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassJavaScriptObject(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception. // LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([{foo: 42}]);"); mActivityTestRule.executeJavaScript("testObject.setBooleanArray([{foo: 42}]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]); Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
...@@ -521,7 +538,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -521,7 +538,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassJavaObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassJavaObject(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception. // LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
"testObject.setBooleanArray([testObject.getObjectInstance()]);"); "testObject.setBooleanArray([testObject.getObjectInstance()]);");
...@@ -586,7 +604,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -586,7 +604,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNull() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteArray([null]);"); mActivityTestRule.executeJavaScript("testObject.setByteArray([null]);");
Assert.assertEquals(0, mTestObject.waitForByteArray()[0]); Assert.assertEquals(0, mTestObject.waitForByteArray()[0]);
...@@ -628,7 +647,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -628,7 +647,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUndefined() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteArray([undefined]);"); mActivityTestRule.executeJavaScript("testObject.setByteArray([undefined]);");
Assert.assertEquals(0, mTestObject.waitForByteArray()[0]); Assert.assertEquals(0, mTestObject.waitForByteArray()[0]);
...@@ -669,7 +689,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -669,7 +689,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassInt8Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt8Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);");
mActivityTestRule.executeJavaScript("int8_array = new Int8Array(buffer);"); mActivityTestRule.executeJavaScript("int8_array = new Int8Array(buffer);");
mActivityTestRule.executeJavaScript("int8_array[0] = 42;"); mActivityTestRule.executeJavaScript("int8_array[0] = 42;");
...@@ -712,7 +733,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -712,7 +733,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUint8Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint8Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);");
mActivityTestRule.executeJavaScript("uint8_array = new Uint8Array(buffer);"); mActivityTestRule.executeJavaScript("uint8_array = new Uint8Array(buffer);");
mActivityTestRule.executeJavaScript("uint8_array[0] = 42;"); mActivityTestRule.executeJavaScript("uint8_array[0] = 42;");
...@@ -755,7 +777,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -755,7 +777,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassInt16Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt16Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);");
mActivityTestRule.executeJavaScript("int16_array = new Int16Array(buffer);"); mActivityTestRule.executeJavaScript("int16_array = new Int16Array(buffer);");
mActivityTestRule.executeJavaScript("int16_array[0] = 42;"); mActivityTestRule.executeJavaScript("int16_array[0] = 42;");
...@@ -798,7 +821,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -798,7 +821,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUint16Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint16Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);");
mActivityTestRule.executeJavaScript("uint16_array = new Uint16Array(buffer);"); mActivityTestRule.executeJavaScript("uint16_array = new Uint16Array(buffer);");
mActivityTestRule.executeJavaScript("uint16_array[0] = 42;"); mActivityTestRule.executeJavaScript("uint16_array[0] = 42;");
...@@ -841,7 +865,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -841,7 +865,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassInt32Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt32Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("int32_array = new Int32Array(buffer);"); mActivityTestRule.executeJavaScript("int32_array = new Int32Array(buffer);");
mActivityTestRule.executeJavaScript("int32_array[0] = 42;"); mActivityTestRule.executeJavaScript("int32_array[0] = 42;");
...@@ -884,7 +909,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -884,7 +909,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUint32Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint32Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("uint32_array = new Uint32Array(buffer);"); mActivityTestRule.executeJavaScript("uint32_array = new Uint32Array(buffer);");
mActivityTestRule.executeJavaScript("uint32_array[0] = 42;"); mActivityTestRule.executeJavaScript("uint32_array[0] = 42;");
...@@ -927,7 +953,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -927,7 +953,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassFloat32Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFloat32Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("float32_array = new Float32Array(buffer);"); mActivityTestRule.executeJavaScript("float32_array = new Float32Array(buffer);");
mActivityTestRule.executeJavaScript("float32_array[0] = 42.0;"); mActivityTestRule.executeJavaScript("float32_array[0] = 42.0;");
...@@ -970,7 +997,8 @@ public class JavaBridgeArrayCoercionTest { ...@@ -970,7 +997,8 @@ public class JavaBridgeArrayCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassFloat64Array() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFloat64Array(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(8);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(8);");
mActivityTestRule.executeJavaScript("float64_array = new Float64Array(buffer);"); mActivityTestRule.executeJavaScript("float64_array = new Float64Array(buffer);");
mActivityTestRule.executeJavaScript("float64_array[0] = 42.0;"); mActivityTestRule.executeJavaScript("float64_array[0] = 42.0;");
......
...@@ -12,7 +12,11 @@ import org.junit.Rule; ...@@ -12,7 +12,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
...@@ -26,7 +30,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; ...@@ -26,7 +30,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not * FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210. * break backwards-compatibility. See b/4408210.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeArrayTest { public class JavaBridgeArrayTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
...@@ -96,6 +101,11 @@ public class JavaBridgeArrayTest { ...@@ -96,6 +101,11 @@ public class JavaBridgeArrayTest {
} }
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject; private TestObject mTestObject;
@Before @Before
...@@ -107,7 +117,8 @@ public class JavaBridgeArrayTest { ...@@ -107,7 +117,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testArrayLength() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testArrayLength(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray([42, 43, 44]);"); mActivityTestRule.executeJavaScript("testObject.setIntArray([42, 43, 44]);");
int[] result = mTestObject.waitForIntArray(); int[] result = mTestObject.waitForIntArray();
Assert.assertEquals(3, result.length); Assert.assertEquals(3, result.length);
...@@ -119,7 +130,8 @@ public class JavaBridgeArrayTest { ...@@ -119,7 +130,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNull() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray(null);"); mActivityTestRule.executeJavaScript("testObject.setIntArray(null);");
Assert.assertNull(mTestObject.waitForIntArray()); Assert.assertNull(mTestObject.waitForIntArray());
} }
...@@ -127,7 +139,8 @@ public class JavaBridgeArrayTest { ...@@ -127,7 +139,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUndefined() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray(undefined);"); mActivityTestRule.executeJavaScript("testObject.setIntArray(undefined);");
Assert.assertNull(mTestObject.waitForIntArray()); Assert.assertNull(mTestObject.waitForIntArray());
} }
...@@ -135,7 +148,8 @@ public class JavaBridgeArrayTest { ...@@ -135,7 +148,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassEmptyArray() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassEmptyArray(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray([]);"); mActivityTestRule.executeJavaScript("testObject.setIntArray([]);");
Assert.assertEquals(0, mTestObject.waitForIntArray().length); Assert.assertEquals(0, mTestObject.waitForIntArray().length);
} }
...@@ -145,7 +159,8 @@ public class JavaBridgeArrayTest { ...@@ -145,7 +159,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassArrayToStringMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassArrayToStringMethod(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should call toString() on array. // LIVECONNECT_COMPLIANCE: Should call toString() on array.
mActivityTestRule.executeJavaScript("testObject.setStringValue([42, 42, 42]);"); mActivityTestRule.executeJavaScript("testObject.setStringValue([42, 42, 42]);");
Assert.assertEquals("undefined", mTestObject.waitForStringValue()); Assert.assertEquals("undefined", mTestObject.waitForStringValue());
...@@ -156,7 +171,8 @@ public class JavaBridgeArrayTest { ...@@ -156,7 +171,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassArrayToNonStringNonArrayMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassArrayToNonStringNonArrayMethod(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise JavaScript exception. // LIVECONNECT_COMPLIANCE: Should raise JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntValue([42, 42, 42]);"); mActivityTestRule.executeJavaScript("testObject.setIntValue([42, 42, 42]);");
Assert.assertEquals(0, mTestObject.waitForIntValue()); Assert.assertEquals(0, mTestObject.waitForIntValue());
...@@ -165,7 +181,8 @@ public class JavaBridgeArrayTest { ...@@ -165,7 +181,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNonArrayToArrayMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNonArrayToArrayMethod(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise JavaScript exception. // LIVECONNECT_COMPLIANCE: Should raise JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray(42);"); mActivityTestRule.executeJavaScript("testObject.setIntArray(42);");
Assert.assertNull(mTestObject.waitForIntArray()); Assert.assertNull(mTestObject.waitForIntArray());
...@@ -174,7 +191,8 @@ public class JavaBridgeArrayTest { ...@@ -174,7 +191,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testObjectWithLengthProperty() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testObjectWithLengthProperty(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: 3, 1: 42});"); mActivityTestRule.executeJavaScript("testObject.setIntArray({length: 3, 1: 42});");
int[] result = mTestObject.waitForIntArray(); int[] result = mTestObject.waitForIntArray();
Assert.assertEquals(3, result.length); Assert.assertEquals(3, result.length);
...@@ -186,7 +204,8 @@ public class JavaBridgeArrayTest { ...@@ -186,7 +204,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testNonNumericLengthProperty() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testNonNumericLengthProperty(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: This should not count as an array, so we // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
// should raise a JavaScript exception. // should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: \"foo\"});"); mActivityTestRule.executeJavaScript("testObject.setIntArray({length: \"foo\"});");
...@@ -196,7 +215,8 @@ public class JavaBridgeArrayTest { ...@@ -196,7 +215,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testLengthOutOfBounds() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testLengthOutOfBounds(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: This should not count as an array, so we // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
// should raise a JavaScript exception. // should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: -1});"); mActivityTestRule.executeJavaScript("testObject.setIntArray({length: -1});");
...@@ -218,7 +238,8 @@ public class JavaBridgeArrayTest { ...@@ -218,7 +238,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testSparseArray() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testSparseArray(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
"var x = [42, 43]; x[3] = 45; testObject.setIntArray(x);"); "var x = [42, 43]; x[3] = 45; testObject.setIntArray(x);");
int[] result = mTestObject.waitForIntArray(); int[] result = mTestObject.waitForIntArray();
...@@ -234,7 +255,8 @@ public class JavaBridgeArrayTest { ...@@ -234,7 +255,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMethodReturningArrayNotCalled() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturningArrayNotCalled(boolean useMojo) throws Throwable {
// We don't invoke methods which return arrays, but note that no // We don't invoke methods which return arrays, but note that no
// exception is raised. // exception is raised.
// LIVECONNECT_COMPLIANCE: Should call method and convert result to // LIVECONNECT_COMPLIANCE: Should call method and convert result to
...@@ -248,7 +270,8 @@ public class JavaBridgeArrayTest { ...@@ -248,7 +270,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMultiDimensionalArrayMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMultiDimensionalArrayMethod(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays. // LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
mActivityTestRule.executeJavaScript("testObject.setIntIntArray([ [42, 43], [44, 45] ]);"); mActivityTestRule.executeJavaScript("testObject.setIntIntArray([ [42, 43], [44, 45] ]);");
Assert.assertNull(mTestObject.waitForIntIntArray()); Assert.assertNull(mTestObject.waitForIntIntArray());
...@@ -257,7 +280,8 @@ public class JavaBridgeArrayTest { ...@@ -257,7 +280,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassMultiDimensionalArray() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassMultiDimensionalArray(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays. // LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
mActivityTestRule.executeJavaScript("testObject.setIntArray([ [42, 43], [44, 45] ]);"); mActivityTestRule.executeJavaScript("testObject.setIntArray([ [42, 43], [44, 45] ]);");
int[] result = mTestObject.waitForIntArray(); int[] result = mTestObject.waitForIntArray();
...@@ -272,7 +296,8 @@ public class JavaBridgeArrayTest { ...@@ -272,7 +296,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassArrayBuffer() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassArrayBuffer(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setIntArray(buffer);"); mActivityTestRule.executeJavaScript("testObject.setIntArray(buffer);");
Assert.assertNull(mTestObject.waitForIntArray()); Assert.assertNull(mTestObject.waitForIntArray());
...@@ -287,7 +312,8 @@ public class JavaBridgeArrayTest { ...@@ -287,7 +312,8 @@ public class JavaBridgeArrayTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassDataView() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDataView(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setIntArray(new DataView(buffer));"); mActivityTestRule.executeJavaScript("testObject.setIntArray(new DataView(buffer));");
Assert.assertNull(mTestObject.waitForIntArray()); Assert.assertNull(mTestObject.waitForIntArray());
......
...@@ -12,7 +12,11 @@ import org.junit.Rule; ...@@ -12,7 +12,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer; import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer;
...@@ -22,13 +26,21 @@ import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer ...@@ -22,13 +26,21 @@ import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer
/** /**
* Common functionality for testing the Java Bridge. * Common functionality for testing the Java Bridge.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeBareboneTest { public class JavaBridgeBareboneTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
new JavaBridgeActivityTestRule().shouldSetUp(false); new JavaBridgeActivityTestRule().shouldSetUp(false);
private TestCallbackHelperContainer mTestCallbackHelperContainer; private TestCallbackHelperContainer mTestCallbackHelperContainer;
private boolean mUseMojo;
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mUseMojo = useMojo;
mActivityTestRule.setupMojoTest(useMojo);
}
@Before @Before
public void setUp() { public void setUp() {
...@@ -43,7 +55,7 @@ public class JavaBridgeBareboneTest { ...@@ -43,7 +55,7 @@ public class JavaBridgeBareboneTest {
mActivityTestRule.runOnUiThread(new Runnable() { mActivityTestRule.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface( mActivityTestRule.getJavascriptInjector(mUseMojo).addPossiblyUnsafeInterface(
new Object(), name, null); new Object(), name, null);
} }
}); });
...@@ -83,7 +95,8 @@ public class JavaBridgeBareboneTest { ...@@ -83,7 +95,8 @@ public class JavaBridgeBareboneTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testImmediateAddition() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testImmediateAddition(boolean useMojo) throws Throwable {
injectDummyObject("testObject"); injectDummyObject("testObject");
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject")); Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
} }
...@@ -93,7 +106,8 @@ public class JavaBridgeBareboneTest { ...@@ -93,7 +106,8 @@ public class JavaBridgeBareboneTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testNoImmediateAdditionAfterJSEvaluation() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testNoImmediateAdditionAfterJSEvaluation(boolean useMojo) throws Throwable {
evaluateJsSync("true"); evaluateJsSync("true");
injectDummyObject("testObject"); injectDummyObject("testObject");
Assert.assertEquals("\"undefined\"", evaluateJsSync("typeof testObject")); Assert.assertEquals("\"undefined\"", evaluateJsSync("typeof testObject"));
...@@ -102,7 +116,8 @@ public class JavaBridgeBareboneTest { ...@@ -102,7 +116,8 @@ public class JavaBridgeBareboneTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testImmediateAdditionAfterReload() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testImmediateAdditionAfterReload(boolean useMojo) throws Throwable {
reloadSync(); reloadSync();
injectDummyObject("testObject"); injectDummyObject("testObject");
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject")); Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
...@@ -111,7 +126,8 @@ public class JavaBridgeBareboneTest { ...@@ -111,7 +126,8 @@ public class JavaBridgeBareboneTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReloadAfterAddition() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReloadAfterAddition(boolean useMojo) throws Throwable {
injectDummyObject("testObject"); injectDummyObject("testObject");
reloadSync(); reloadSync();
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject")); Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
......
...@@ -16,12 +16,16 @@ import org.junit.Rule; ...@@ -16,12 +16,16 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner; import org.chromium.content_public.browser.test.ContentJUnit4RunnerDelegate;
import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer; import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
...@@ -43,7 +47,8 @@ import java.util.concurrent.CountDownLatch; ...@@ -43,7 +47,8 @@ import java.util.concurrent.CountDownLatch;
* - Threading * - Threading
* - Inheritance * - Inheritance
*/ */
@RunWith(ContentJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(ContentJUnit4RunnerDelegate.class)
public class JavaBridgeBasicsTest { public class JavaBridgeBasicsTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
...@@ -100,6 +105,11 @@ public class JavaBridgeBasicsTest { ...@@ -100,6 +105,11 @@ public class JavaBridgeBasicsTest {
} }
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestController mTestController; TestController mTestController;
@Before @Before
...@@ -137,19 +147,21 @@ public class JavaBridgeBasicsTest { ...@@ -137,19 +147,21 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testTypeOfInjectedObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfInjectedObject(boolean useMojo) throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAdditionNotReflectedUntilReload() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAdditionNotReflectedUntilReload(boolean useMojo) throws Throwable {
Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject")); Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject"));
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface( mActivityTestRule.getJavascriptInjector(useMojo).addPossiblyUnsafeInterface(
new Object(), "testObject", null); new Object(), "testObject", null);
} }
}); });
...@@ -161,7 +173,8 @@ public class JavaBridgeBasicsTest { ...@@ -161,7 +173,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testRemovalNotReflectedUntilReload() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testRemovalNotReflectedUntilReload(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void method() { public void method() {
mTestController.setStringValue("I'm here"); mTestController.setStringValue("I'm here");
...@@ -173,7 +186,7 @@ public class JavaBridgeBasicsTest { ...@@ -173,7 +186,7 @@ public class JavaBridgeBasicsTest {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().removeInterface("testObject"); mActivityTestRule.getJavascriptInjector(useMojo).removeInterface("testObject");
} }
}); });
// Check that the Java object is being held by the Java bridge, thus it's not // Check that the Java object is being held by the Java bridge, thus it's not
...@@ -190,14 +203,15 @@ public class JavaBridgeBasicsTest { ...@@ -190,14 +203,15 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testRemoveObjectNotAdded() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testRemoveObjectNotAdded(boolean useMojo) throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
mActivityTestRule.getTestCallBackHelperContainer().getOnPageFinishedHelper(); mActivityTestRule.getTestCallBackHelperContainer().getOnPageFinishedHelper();
int currentCallCount = onPageFinishedHelper.getCallCount(); int currentCallCount = onPageFinishedHelper.getCallCount();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().removeInterface("foo"); mActivityTestRule.getJavascriptInjector(useMojo).removeInterface("foo");
mActivityTestRule.getWebContents().getNavigationController().reload(true); mActivityTestRule.getWebContents().getNavigationController().reload(true);
} }
}); });
...@@ -208,7 +222,8 @@ public class JavaBridgeBasicsTest { ...@@ -208,7 +222,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testTypeOfMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfMethod(boolean useMojo) throws Throwable {
Assert.assertEquals("function", Assert.assertEquals("function",
executeJavaScriptAndGetStringResult("typeof testController.setStringValue")); executeJavaScriptAndGetStringResult("typeof testController.setStringValue"));
} }
...@@ -216,7 +231,8 @@ public class JavaBridgeBasicsTest { ...@@ -216,7 +231,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testTypeOfInvalidMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfInvalidMethod(boolean useMojo) throws Throwable {
Assert.assertEquals( Assert.assertEquals(
"undefined", executeJavaScriptAndGetStringResult("typeof testController.foo")); "undefined", executeJavaScriptAndGetStringResult("typeof testController.foo"));
} }
...@@ -224,14 +240,17 @@ public class JavaBridgeBasicsTest { ...@@ -224,14 +240,17 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallingInvalidMethodRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingInvalidMethodRaisesException(boolean useMojo) throws Throwable {
assertRaisesException("testController.foo()"); assertRaisesException("testController.foo()");
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testUncaughtJavaExceptionRaisesJavaScriptException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testUncaughtJavaExceptionRaisesJavaScriptException(boolean useMojo)
throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void method() { public void method() {
throw new RuntimeException("foo"); throw new RuntimeException("foo");
...@@ -243,21 +262,24 @@ public class JavaBridgeBasicsTest { ...@@ -243,21 +262,24 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallingAsConstructorRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingAsConstructorRaisesException(boolean useMojo) throws Throwable {
assertRaisesException("new testController.setStringValue('foo')"); assertRaisesException("new testController.setStringValue('foo')");
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallingOnNonInjectedObjectRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingOnNonInjectedObjectRaisesException(boolean useMojo) throws Throwable {
assertRaisesException("testController.setStringValue.call({}, 'foo')"); assertRaisesException("testController.setStringValue.call({}, 'foo')");
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallingOnInstanceOfOtherClassRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingOnInstanceOfOtherClassRaisesException(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject"); mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
...@@ -270,7 +292,8 @@ public class JavaBridgeBasicsTest { ...@@ -270,7 +292,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testTypeOfStaticMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfStaticMethod(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject"); mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject");
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
"testController.setStringValue(typeof testObject.staticMethod)"); "testController.setStringValue(typeof testObject.staticMethod)");
...@@ -281,7 +304,8 @@ public class JavaBridgeBasicsTest { ...@@ -281,7 +304,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallStaticMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallStaticMethod(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject"); mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject");
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
"testController.setStringValue(testObject.staticMethod())"); "testController.setStringValue(testObject.staticMethod())");
...@@ -291,7 +315,8 @@ public class JavaBridgeBasicsTest { ...@@ -291,7 +315,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPrivateMethodNotExposed() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPrivateMethodNotExposed(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
private void method() {} private void method() {}
protected void method2() {} protected void method2() {}
...@@ -305,7 +330,8 @@ public class JavaBridgeBasicsTest { ...@@ -305,7 +330,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReplaceInjectedObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceInjectedObject(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void method() { public void method() {
mTestController.setStringValue("object 1"); mTestController.setStringValue("object 1");
...@@ -326,7 +352,8 @@ public class JavaBridgeBasicsTest { ...@@ -326,7 +352,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testInjectNullObjectIsIgnored() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testInjectNullObjectIsIgnored(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(null, "testObject"); mActivityTestRule.injectObjectAndReload(null, "testObject");
Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject")); Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject"));
} }
...@@ -334,7 +361,8 @@ public class JavaBridgeBasicsTest { ...@@ -334,7 +361,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReplaceInjectedObjectWithNullObjectIsIgnored() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceInjectedObjectWithNullObjectIsIgnored(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject"); mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
mActivityTestRule.injectObjectAndReload(null, "testObject"); mActivityTestRule.injectObjectAndReload(null, "testObject");
...@@ -344,7 +372,9 @@ public class JavaBridgeBasicsTest { ...@@ -344,7 +372,9 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallOverloadedMethodWithDifferentNumberOfArguments() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallOverloadedMethodWithDifferentNumberOfArguments(boolean useMojo)
throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void method() { public void method() {
mTestController.setStringValue("0 args"); mTestController.setStringValue("0 args");
...@@ -373,7 +403,9 @@ public class JavaBridgeBasicsTest { ...@@ -373,7 +403,9 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallMethodWithWrongNumberOfArgumentsRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallMethodWithWrongNumberOfArgumentsRaisesException(boolean useMojo)
throws Throwable {
assertRaisesException("testController.setIntValue()"); assertRaisesException("testController.setIntValue()");
assertRaisesException("testController.setIntValue(42, 42)"); assertRaisesException("testController.setIntValue(42, 42)");
} }
...@@ -381,7 +413,8 @@ public class JavaBridgeBasicsTest { ...@@ -381,7 +413,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testObjectPersistsAcrossPageLoads() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testObjectPersistsAcrossPageLoads(boolean useMojo) throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
mActivityTestRule.synchronousPageReload(); mActivityTestRule.synchronousPageReload();
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
...@@ -390,7 +423,8 @@ public class JavaBridgeBasicsTest { ...@@ -390,7 +423,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCustomPropertiesCleanedUpOnPageReloads() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCustomPropertiesCleanedUpOnPageReloads(boolean useMojo) throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController")); Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
mActivityTestRule.executeJavaScript("testController.myProperty = 42;"); mActivityTestRule.executeJavaScript("testController.myProperty = 42;");
Assert.assertEquals("42", executeJavaScriptAndGetStringResult("testController.myProperty")); Assert.assertEquals("42", executeJavaScriptAndGetStringResult("testController.myProperty"));
...@@ -403,7 +437,8 @@ public class JavaBridgeBasicsTest { ...@@ -403,7 +437,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testSameObjectInjectedMultipleTimes() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testSameObjectInjectedMultipleTimes(boolean useMojo) throws Throwable {
class TestObject { class TestObject {
private int mNumMethodInvocations; private int mNumMethodInvocations;
...@@ -423,7 +458,8 @@ public class JavaBridgeBasicsTest { ...@@ -423,7 +458,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCallMethodOnReturnedObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallMethodOnReturnedObject(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public Object getInnerObject() { public Object getInnerObject() {
return new Object() { return new Object() {
...@@ -440,7 +476,8 @@ public class JavaBridgeBasicsTest { ...@@ -440,7 +476,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReturnedObjectInjectedElsewhere() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReturnedObjectInjectedElsewhere(boolean useMojo) throws Throwable {
class InnerObject { class InnerObject {
private int mNumMethodInvocations; private int mNumMethodInvocations;
...@@ -470,7 +507,8 @@ public class JavaBridgeBasicsTest { ...@@ -470,7 +507,8 @@ public class JavaBridgeBasicsTest {
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
@CommandLineFlags.Add("js-flags=--expose-gc") @CommandLineFlags.Add("js-flags=--expose-gc")
public void testReturnedObjectIsGarbageCollected() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReturnedObjectIsGarbageCollected(boolean useMojo) throws Throwable {
Assert.assertEquals("function", executeJavaScriptAndGetStringResult("typeof gc")); Assert.assertEquals("function", executeJavaScriptAndGetStringResult("typeof gc"));
class InnerObject { class InnerObject {
} }
...@@ -511,7 +549,8 @@ public class JavaBridgeBasicsTest { ...@@ -511,7 +549,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testSameReturnedObjectUsesSameWrapper() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testSameReturnedObjectUsesSameWrapper(boolean useMojo) throws Throwable {
class InnerObject { class InnerObject {
} }
final InnerObject innerObject = new InnerObject(); final InnerObject innerObject = new InnerObject();
...@@ -531,7 +570,8 @@ public class JavaBridgeBasicsTest { ...@@ -531,7 +570,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMethodInvokedOnBackgroundThread() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testMethodInvokedOnBackgroundThread(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void captureThreadId() { public void captureThreadId() {
mTestController.setLongValue(Thread.currentThread().getId()); mTestController.setLongValue(Thread.currentThread().getId());
...@@ -551,7 +591,8 @@ public class JavaBridgeBasicsTest { ...@@ -551,7 +591,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testBlockingUiThreadDoesNotBlockCallsFromJs() { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testBlockingUiThreadDoesNotBlockCallsFromJs(boolean useMojo) {
class TestObject { class TestObject {
private CountDownLatch mLatch; private CountDownLatch mLatch;
public TestObject() { public TestObject() {
...@@ -594,7 +635,8 @@ public class JavaBridgeBasicsTest { ...@@ -594,7 +635,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPublicInheritedMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPublicInheritedMethod(boolean useMojo) throws Throwable {
class Base { class Base {
public void method(int x) { public void method(int x) {
mTestController.setIntValue(x); mTestController.setIntValue(x);
...@@ -612,7 +654,8 @@ public class JavaBridgeBasicsTest { ...@@ -612,7 +654,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPrivateInheritedMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPrivateInheritedMethod(boolean useMojo) throws Throwable {
class Base { class Base {
private void method() {} private void method() {}
} }
...@@ -626,7 +669,8 @@ public class JavaBridgeBasicsTest { ...@@ -626,7 +669,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testOverriddenMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testOverriddenMethod(boolean useMojo) throws Throwable {
class Base { class Base {
public void method() { public void method() {
mTestController.setStringValue("base"); mTestController.setStringValue("base");
...@@ -646,7 +690,8 @@ public class JavaBridgeBasicsTest { ...@@ -646,7 +690,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testEnumerateMembers() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testEnumerateMembers(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {} public void method() {}
private void privateMethod() {} private void privateMethod() {}
...@@ -663,7 +708,8 @@ public class JavaBridgeBasicsTest { ...@@ -663,7 +708,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReflectPublicMethod() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPublicMethod(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() { public Class<?> myGetClass() {
return getClass(); return getClass();
...@@ -682,7 +728,8 @@ public class JavaBridgeBasicsTest { ...@@ -682,7 +728,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReflectPublicField() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPublicField(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() { public Class<?> myGetClass() {
return getClass(); return getClass();
...@@ -698,7 +745,8 @@ public class JavaBridgeBasicsTest { ...@@ -698,7 +745,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReflectPrivateMethodRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPrivateMethodRaisesException(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() { public Class<?> myGetClass() {
return getClass(); return getClass();
...@@ -718,7 +766,8 @@ public class JavaBridgeBasicsTest { ...@@ -718,7 +766,8 @@ public class JavaBridgeBasicsTest {
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
@DisabledTest(message = "https://crbug.com/795378") @DisabledTest(message = "https://crbug.com/795378")
public void testReflectPrivateFieldRaisesException() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReflectPrivateFieldRaisesException(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() { public Class<?> myGetClass() {
return getClass(); return getClass();
...@@ -738,7 +787,8 @@ public class JavaBridgeBasicsTest { ...@@ -738,7 +787,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAllowNonAnnotatedMethods() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAllowNonAnnotatedMethods(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
public String allowed() { public String allowed() {
return "foo"; return "foo";
...@@ -756,7 +806,8 @@ public class JavaBridgeBasicsTest { ...@@ -756,7 +806,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAllowOnlyAnnotatedMethods() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAllowOnlyAnnotatedMethods(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() { mActivityTestRule.injectObjectAndReload(new Object() {
@JavascriptInterface @JavascriptInterface
public String allowed() { public String allowed() {
...@@ -788,7 +839,9 @@ public class JavaBridgeBasicsTest { ...@@ -788,7 +839,9 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAnnotationRequirementRetainsPropertyAcrossObjects() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAnnotationRequirementRetainsPropertyAcrossObjects(boolean useMojo)
throws Throwable {
class Test { class Test {
@JavascriptInterface @JavascriptInterface
public String safe() { public String safe() {
...@@ -838,7 +891,8 @@ public class JavaBridgeBasicsTest { ...@@ -838,7 +891,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAnnotationDoesNotGetInherited() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAnnotationDoesNotGetInherited(boolean useMojo) throws Throwable {
class Base { class Base {
@JavascriptInterface @JavascriptInterface
public void base() { } public void base() { }
...@@ -868,7 +922,8 @@ public class JavaBridgeBasicsTest { ...@@ -868,7 +922,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testCustomAnnotationRestriction() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testCustomAnnotationRestriction(boolean useMojo) throws Throwable {
class Test { class Test {
@TestAnnotation @TestAnnotation
public String checkTestAnnotationFoo() { public String checkTestAnnotationFoo() {
...@@ -914,7 +969,8 @@ public class JavaBridgeBasicsTest { ...@@ -914,7 +969,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testObjectsInspection() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testObjectsInspection(boolean useMojo) throws Throwable {
class Test { class Test {
@JavascriptInterface @JavascriptInterface
public String m1() { public String m1() {
...@@ -954,7 +1010,7 @@ public class JavaBridgeBasicsTest { ...@@ -954,7 +1010,7 @@ public class JavaBridgeBasicsTest {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().setAllowInspection(false); mActivityTestRule.getJavascriptInjector(useMojo).setAllowInspection(false);
} }
}); });
...@@ -972,7 +1028,8 @@ public class JavaBridgeBasicsTest { ...@@ -972,7 +1028,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testAccessToObjectGetClassIsBlocked() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAccessToObjectGetClassIsBlocked(boolean useMojo) throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject"); mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals( Assert.assertEquals(
"function", executeJavaScriptAndGetStringResult("typeof testObject.getClass")); "function", executeJavaScriptAndGetStringResult("typeof testObject.getClass"));
...@@ -982,7 +1039,8 @@ public class JavaBridgeBasicsTest { ...@@ -982,7 +1039,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testReplaceJavascriptInterface() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceJavascriptInterface(boolean useMojo) throws Throwable {
class Test { class Test {
public Test(int value) { public Test(int value) {
mValue = value; mValue = value;
...@@ -1005,7 +1063,8 @@ public class JavaBridgeBasicsTest { ...@@ -1005,7 +1063,8 @@ public class JavaBridgeBasicsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMethodCalledOnAnotherInstance() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodCalledOnAnotherInstance(boolean useMojo) throws Throwable {
class TestObject { class TestObject {
private int mIndex; private int mIndex;
TestObject(int index) { TestObject(int index) {
......
...@@ -14,6 +14,10 @@ import org.junit.Rule; ...@@ -14,6 +14,10 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
...@@ -22,7 +26,7 @@ import org.chromium.content_public.browser.JavaScriptCallback; ...@@ -22,7 +26,7 @@ import org.chromium.content_public.browser.JavaScriptCallback;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner; import org.chromium.content_public.browser.test.ContentJUnit4RunnerDelegate;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
...@@ -35,7 +39,8 @@ import java.util.concurrent.TimeoutException; ...@@ -35,7 +39,8 @@ import java.util.concurrent.TimeoutException;
* Ensures that injected objects are exposed to child frames as well as the * Ensures that injected objects are exposed to child frames as well as the
* main frame. * main frame.
*/ */
@RunWith(ContentJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(ContentJUnit4RunnerDelegate.class)
public class JavaBridgeChildFrameTest { public class JavaBridgeChildFrameTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
...@@ -56,6 +61,11 @@ public class JavaBridgeChildFrameTest { ...@@ -56,6 +61,11 @@ public class JavaBridgeChildFrameTest {
} }
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestController mTestController; TestController mTestController;
@Before @Before
...@@ -67,7 +77,8 @@ public class JavaBridgeChildFrameTest { ...@@ -67,7 +77,8 @@ public class JavaBridgeChildFrameTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testInjectedObjectPresentInChildFrame() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testInjectedObjectPresentInChildFrame(boolean useMojo) throws Throwable {
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(), loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
"<html><body><iframe></iframe></body></html>", "text/html", false); "<html><body><iframe></iframe></body></html>", "text/html", false);
// We are not executing this code as a part of page loading routine to avoid races // We are not executing this code as a part of page loading routine to avoid races
...@@ -85,7 +96,8 @@ public class JavaBridgeChildFrameTest { ...@@ -85,7 +96,8 @@ public class JavaBridgeChildFrameTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMainPageWrapperIsNotBrokenByChildFrame() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMainPageWrapperIsNotBrokenByChildFrame(boolean useMojo) throws Throwable {
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(), loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
"<html><body><iframe></iframe></body></html>", "text/html", false); "<html><body><iframe></iframe></body></html>", "text/html", false);
// In case there is anything wrong with the JS wrapper, an attempt // In case there is anything wrong with the JS wrapper, an attempt
...@@ -108,7 +120,8 @@ public class JavaBridgeChildFrameTest { ...@@ -108,7 +120,8 @@ public class JavaBridgeChildFrameTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testWrapperIsNotSharedWithChildFrame() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testWrapperIsNotSharedWithChildFrame(boolean useMojo) throws Throwable {
// Test by setting a custom property on the parent page's injected // Test by setting a custom property on the parent page's injected
// object and then checking that child frame doesn't see the property. // object and then checking that child frame doesn't see the property.
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(), loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
...@@ -137,7 +150,8 @@ public class JavaBridgeChildFrameTest { ...@@ -137,7 +150,8 @@ public class JavaBridgeChildFrameTest {
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
@DisabledTest(message = "https://crbug.com/677182") @DisabledTest(message = "https://crbug.com/677182")
public void testRemovingTransientObjectHolders() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testRemovingTransientObjectHolders(boolean useMojo) throws Throwable {
class Test { class Test {
private Object mInner = new Object(); private Object mInner = new Object();
// Expecting the inner object to be retrieved twice. // Expecting the inner object to be retrieved twice.
...@@ -199,7 +213,8 @@ public class JavaBridgeChildFrameTest { ...@@ -199,7 +213,8 @@ public class JavaBridgeChildFrameTest {
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
@CommandLineFlags.Add("js-flags=--expose-gc") @CommandLineFlags.Add("js-flags=--expose-gc")
@DisabledTest(message = "https://crbug.com/646843") @DisabledTest(message = "https://crbug.com/646843")
public void testHolderFrame() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testHolderFrame(boolean useMojo) throws Throwable {
class Test { class Test {
WeakReference<Object> mWeakRefForInner; WeakReference<Object> mWeakRefForInner;
private CountDownLatch mLatch = new CountDownLatch(1); private CountDownLatch mLatch = new CountDownLatch(1);
......
...@@ -14,7 +14,11 @@ import org.junit.Rule; ...@@ -14,7 +14,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
...@@ -33,7 +37,8 @@ import java.io.File; ...@@ -33,7 +37,8 @@ import java.io.File;
* FIXME: Consider making our implementation more compliant, if it will not * FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210. * break backwards-compatibility. See b/4408210.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeCoercionTest { public class JavaBridgeCoercionTest {
private static final double ASSERTION_DELTA = 0; private static final double ASSERTION_DELTA = 0;
...@@ -171,6 +176,11 @@ public class JavaBridgeCoercionTest { ...@@ -171,6 +176,11 @@ public class JavaBridgeCoercionTest {
private static class CustomType2 { private static class CustomType2 {
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject; private TestObject mTestObject;
private static class TestController extends Controller { private static class TestController extends Controller {
...@@ -213,7 +223,8 @@ public class JavaBridgeCoercionTest { ...@@ -213,7 +223,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberInt32() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInt32(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(42);"); mActivityTestRule.executeJavaScript("testObject.setByteValue(42);");
Assert.assertEquals(42, mTestObject.waitForByteValue()); Assert.assertEquals(42, mTestObject.waitForByteValue());
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
...@@ -266,7 +277,8 @@ public class JavaBridgeCoercionTest { ...@@ -266,7 +277,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberDouble() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassNumberDouble(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(42.1);"); mActivityTestRule.executeJavaScript("testObject.setByteValue(42.1);");
Assert.assertEquals(42, mTestObject.waitForByteValue()); Assert.assertEquals(42, mTestObject.waitForByteValue());
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
...@@ -347,7 +359,8 @@ public class JavaBridgeCoercionTest { ...@@ -347,7 +359,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberNaN() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberNaN(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(Number.NaN);"); mActivityTestRule.executeJavaScript("testObject.setByteValue(Number.NaN);");
Assert.assertEquals(0, mTestObject.waitForByteValue()); Assert.assertEquals(0, mTestObject.waitForByteValue());
...@@ -388,7 +401,8 @@ public class JavaBridgeCoercionTest { ...@@ -388,7 +401,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNumberInfinity() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInfinity(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(Infinity);"); mActivityTestRule.executeJavaScript("testObject.setByteValue(Infinity);");
Assert.assertEquals(-1, mTestObject.waitForByteValue()); Assert.assertEquals(-1, mTestObject.waitForByteValue());
...@@ -432,7 +446,8 @@ public class JavaBridgeCoercionTest { ...@@ -432,7 +446,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassBoolean() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassBoolean(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanValue(true);"); mActivityTestRule.executeJavaScript("testObject.setBooleanValue(true);");
Assert.assertTrue(mTestObject.waitForBooleanValue()); Assert.assertTrue(mTestObject.waitForBooleanValue());
mActivityTestRule.executeJavaScript("testObject.setBooleanValue(false);"); mActivityTestRule.executeJavaScript("testObject.setBooleanValue(false);");
...@@ -498,7 +513,8 @@ public class JavaBridgeCoercionTest { ...@@ -498,7 +513,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassString() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassString(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setStringValue(\"+042.10\");"); mActivityTestRule.executeJavaScript("testObject.setStringValue(\"+042.10\");");
Assert.assertEquals("+042.10", mTestObject.waitForStringValue()); Assert.assertEquals("+042.10", mTestObject.waitForStringValue());
...@@ -551,7 +567,8 @@ public class JavaBridgeCoercionTest { ...@@ -551,7 +567,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassJavaScriptObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaScriptObject(boolean useMojo) throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception. // LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setObjectValue({foo: 42});"); mActivityTestRule.executeJavaScript("testObject.setObjectValue({foo: 42});");
Assert.assertNull(mTestObject.waitForObjectValue()); Assert.assertNull(mTestObject.waitForObjectValue());
...@@ -603,7 +620,8 @@ public class JavaBridgeCoercionTest { ...@@ -603,7 +620,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassJavaObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaObject(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript( mActivityTestRule.executeJavaScript(
"testObject.setObjectValue(testObject.getObjectInstance());"); "testObject.setObjectValue(testObject.getObjectInstance());");
Assert.assertTrue(mTestObject.getObjectInstance() == mTestObject.waitForObjectValue()); Assert.assertTrue(mTestObject.getObjectInstance() == mTestObject.waitForObjectValue());
...@@ -682,7 +700,8 @@ public class JavaBridgeCoercionTest { ...@@ -682,7 +700,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassJavaObjectFromCustomClassLoader() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaObjectFromCustomClassLoader(boolean useMojo) throws Throwable {
// Compiled bytecode (dex) for the following class: // Compiled bytecode (dex) for the following class:
// //
// package org.example; // package org.example;
...@@ -706,7 +725,7 @@ public class JavaBridgeCoercionTest { ...@@ -706,7 +725,7 @@ public class JavaBridgeCoercionTest {
mActivityTestRule.runOnUiThread(new Runnable() { mActivityTestRule.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface( mActivityTestRule.getJavascriptInjector(useMojo).addPossiblyUnsafeInterface(
selfConsuming, "selfConsuming", null); selfConsuming, "selfConsuming", null);
} }
}); });
...@@ -720,7 +739,8 @@ public class JavaBridgeCoercionTest { ...@@ -720,7 +739,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassNull() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setObjectValue(null);"); mActivityTestRule.executeJavaScript("testObject.setObjectValue(null);");
Assert.assertNull(mTestObject.waitForObjectValue()); Assert.assertNull(mTestObject.waitForObjectValue());
...@@ -759,7 +779,8 @@ public class JavaBridgeCoercionTest { ...@@ -759,7 +779,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassUndefined() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setObjectValue(undefined);"); mActivityTestRule.executeJavaScript("testObject.setObjectValue(undefined);");
Assert.assertNull(mTestObject.waitForObjectValue()); Assert.assertNull(mTestObject.waitForObjectValue());
...@@ -800,7 +821,8 @@ public class JavaBridgeCoercionTest { ...@@ -800,7 +821,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassArrayBuffer() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassArrayBuffer(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setObjectValue(buffer);"); mActivityTestRule.executeJavaScript("testObject.setObjectValue(buffer);");
...@@ -817,7 +839,8 @@ public class JavaBridgeCoercionTest { ...@@ -817,7 +839,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassDataView() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDataView(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);"); mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setObjectValue(new DataView(buffer));"); mActivityTestRule.executeJavaScript("testObject.setObjectValue(new DataView(buffer));");
...@@ -831,7 +854,8 @@ public class JavaBridgeCoercionTest { ...@@ -831,7 +854,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassDateObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDateObject(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setDoubleValue(new Date(2000, 0, 1));"); mActivityTestRule.executeJavaScript("testObject.setDoubleValue(new Date(2000, 0, 1));");
Assert.assertEquals(0.0, mTestObject.waitForDoubleValue(), ASSERTION_DELTA); Assert.assertEquals(0.0, mTestObject.waitForDoubleValue(), ASSERTION_DELTA);
...@@ -846,7 +870,8 @@ public class JavaBridgeCoercionTest { ...@@ -846,7 +870,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassRegExpObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassRegExpObject(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setStringValue(/abc/);"); mActivityTestRule.executeJavaScript("testObject.setStringValue(/abc/);");
Assert.assertEquals("undefined", mTestObject.waitForStringValue()); Assert.assertEquals("undefined", mTestObject.waitForStringValue());
...@@ -858,7 +883,8 @@ public class JavaBridgeCoercionTest { ...@@ -858,7 +883,8 @@ public class JavaBridgeCoercionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testPassFunctionObject() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFunctionObject(boolean useMojo) throws Throwable {
mActivityTestRule.executeJavaScript("func = new Function('a', 'b', 'return a + b');"); mActivityTestRule.executeJavaScript("func = new Function('a', 'b', 'return a + b');");
mActivityTestRule.executeJavaScript("testObject.setStringValue(func);"); mActivityTestRule.executeJavaScript("testObject.setStringValue(func);");
......
...@@ -12,7 +12,11 @@ import org.junit.Rule; ...@@ -12,7 +12,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
...@@ -20,7 +24,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; ...@@ -20,7 +24,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* Part of the test suite for the Java Bridge. This test tests the * Part of the test suite for the Java Bridge. This test tests the
* use of fields. * use of fields.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeFieldsTest { public class JavaBridgeFieldsTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
...@@ -56,6 +61,11 @@ public class JavaBridgeFieldsTest { ...@@ -56,6 +61,11 @@ public class JavaBridgeFieldsTest {
private static class CustomType { private static class CustomType {
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestObject mTestObject; TestObject mTestObject;
@Before @Before
...@@ -75,7 +85,8 @@ public class JavaBridgeFieldsTest { ...@@ -75,7 +85,8 @@ public class JavaBridgeFieldsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testFieldTypes() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testFieldTypes(boolean useMojo) throws Throwable {
Assert.assertEquals( Assert.assertEquals(
"undefined", executeJavaScriptAndGetStringResult("typeof testObject.booleanField")); "undefined", executeJavaScriptAndGetStringResult("typeof testObject.booleanField"));
Assert.assertEquals( Assert.assertEquals(
......
...@@ -12,7 +12,11 @@ import org.junit.Rule; ...@@ -12,7 +12,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
...@@ -27,7 +31,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller; ...@@ -27,7 +31,8 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not * FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210. * break backwards-compatibility. See b/4408210.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class JavaBridgeReturnValuesTest { public class JavaBridgeReturnValuesTest {
@Rule @Rule
public JavaBridgeActivityTestRule mActivityTestRule = public JavaBridgeActivityTestRule mActivityTestRule =
...@@ -113,6 +118,11 @@ public class JavaBridgeReturnValuesTest { ...@@ -113,6 +118,11 @@ public class JavaBridgeReturnValuesTest {
private static class CustomType { private static class CustomType {
} }
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestObject mTestObject; TestObject mTestObject;
@Before @Before
...@@ -136,7 +146,8 @@ public class JavaBridgeReturnValuesTest { ...@@ -136,7 +146,8 @@ public class JavaBridgeReturnValuesTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMethodReturnTypes() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturnTypes(boolean useMojo) throws Throwable {
Assert.assertEquals("boolean", Assert.assertEquals("boolean",
executeJavaScriptAndGetStringResult("typeof testObject.getBooleanValue()")); executeJavaScriptAndGetStringResult("typeof testObject.getBooleanValue()"));
Assert.assertEquals( Assert.assertEquals(
...@@ -178,7 +189,8 @@ public class JavaBridgeReturnValuesTest { ...@@ -178,7 +189,8 @@ public class JavaBridgeReturnValuesTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"}) @Feature({"AndroidWebView", "Android-JavaBridge"})
public void testMethodReturnValues() throws Throwable { @UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturnValues(boolean useMojo) throws Throwable {
// We do the string comparison in JavaScript, to avoid relying on the // We do the string comparison in JavaScript, to avoid relying on the
// coercion algorithm from JavaScript to Java. // coercion algorithm from JavaScript to Java.
Assert.assertTrue(executeJavaScriptAndGetBooleanResult("testObject.getBooleanValue()")); Assert.assertTrue(executeJavaScriptAndGetBooleanResult("testObject.getBooleanValue()"));
......
...@@ -34,6 +34,7 @@ android_library("content_java_test_support") { ...@@ -34,6 +34,7 @@ android_library("content_java_test_support") {
"javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettings.java", "javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettings.java",
"javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettingsHook.java", "javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettingsHook.java",
"javatests/src/org/chromium/content_public/browser/test/ContentJUnit4ClassRunner.java", "javatests/src/org/chromium/content_public/browser/test/ContentJUnit4ClassRunner.java",
"javatests/src/org/chromium/content_public/browser/test/ContentJUnit4RunnerDelegate.java",
"javatests/src/org/chromium/content_public/browser/test/NativeLibraryTestUtils.java", "javatests/src/org/chromium/content_public/browser/test/NativeLibraryTestUtils.java",
"javatests/src/org/chromium/content_public/browser/test/RenderFrameHostTestExt.java", "javatests/src/org/chromium/content_public/browser/test/RenderFrameHostTestExt.java",
"javatests/src/org/chromium/content_public/browser/test/mock/MockNavigationController.java", "javatests/src/org/chromium/content_public/browser/test/mock/MockNavigationController.java",
......
// Copyright 2020 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_public.browser.test;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.chromium.base.test.params.ParameterizedRunner.ParameterizedTestInstantiationException;
import org.chromium.base.test.params.ParameterizedRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunnerDelegateCommon;
import java.util.List;
/**
* A custom runner delegate for running //content JUnit4 parameterized tests.
*/
public final class ContentJUnit4RunnerDelegate
extends ContentJUnit4ClassRunner implements ParameterizedRunnerDelegate {
private final ParameterizedRunnerDelegateCommon mDelegateCommon;
public ContentJUnit4RunnerDelegate(Class<?> klass,
ParameterizedRunnerDelegateCommon delegateCommon) throws InitializationError {
super(klass);
mDelegateCommon = delegateCommon;
}
@Override
public void collectInitializationErrors(List<Throwable> errors) {
ParameterizedRunnerDelegateCommon.collectInitializationErrors(errors);
}
@Override
public List<FrameworkMethod> computeTestMethods() {
return mDelegateCommon.computeTestMethods();
}
@Override
public Object createTest() throws ParameterizedTestInstantiationException {
return mDelegateCommon.createTest();
}
}
...@@ -226,7 +226,11 @@ public class ContentShellActivityTestRule extends ActivityTestRule<ContentShellA ...@@ -226,7 +226,11 @@ public class ContentShellActivityTestRule extends ActivityTestRule<ContentShellA
} }
public JavascriptInjector getJavascriptInjector() { public JavascriptInjector getJavascriptInjector() {
return JavascriptInjector.fromWebContents(getWebContents()); return getJavascriptInjector(false);
}
public JavascriptInjector getJavascriptInjector(boolean useMojo) {
return JavascriptInjector.fromWebContents(getWebContents(), useMojo);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment