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

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

Issue 251773003: [Android] Add more tests for Java Bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
index 03e9a705aca779ed831d5adc36a3d8e5c5357be6..603588626d65f613db1a43e8c7ef1ffc62a8568e 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
@@ -692,4 +692,42 @@ public class JavaBridgeCoercionTest extends JavaBridgeTestBase {
executeJavaScript("testObject.setStringValue(new DataView(buffer));");
assertEquals("undefined", mTestObject.waitForStringValue());
}
+
+ // Verify that Date objects are not converted into double values, strings or objects.
+ @SmallTest
+ @Feature({"AndroidWebView", "Android-JavaBridge"})
+ public void testPassDateObject() throws Throwable {
+ executeJavaScript("testObject.setDoubleValue(new Date(2000, 0, 1));");
+ assertEquals(0.0, mTestObject.waitForDoubleValue());
+
+ executeJavaScript("testObject.setStringValue(new Date(2000, 0, 1));");
+ assertEquals("undefined", mTestObject.waitForStringValue());
+
+ executeJavaScript("testObject.setObjectValue(new Date(2000, 0, 1));");
+ assertNull(mTestObject.waitForObjectValue());
+ }
+
+ // Verify that RegExp objects are not converted into strings or objects.
+ @SmallTest
+ @Feature({"AndroidWebView", "Android-JavaBridge"})
+ public void testPassRegExpObject() throws Throwable {
+ executeJavaScript("testObject.setStringValue(/abc/);");
+ assertEquals("undefined", mTestObject.waitForStringValue());
+
+ executeJavaScript("testObject.setObjectValue(/abc/);");
+ assertNull(mTestObject.waitForObjectValue());
+ }
+
+ // Verify that Function objects are not converted into strings or objects.
+ @SmallTest
+ @Feature({"AndroidWebView", "Android-JavaBridge"})
+ public void testPassFunctionObject() throws Throwable {
+ executeJavaScript("func = new Function('a', 'b', 'return a + b');");
+
+ executeJavaScript("testObject.setStringValue(func);");
+ assertEquals("undefined", mTestObject.waitForStringValue());
+
+ executeJavaScript("testObject.setObjectValue(func);");
+ assertNull(mTestObject.waitForObjectValue());
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698