summaryrefslogtreecommitdiffstats
path: root/tests/WebViewTests
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-11-16 15:53:46 +0000
committerSteve Block <steveblock@google.com>2011-11-21 18:31:14 +0000
commitfc6cf2888426f5192b9f284d14b911f3bbc7c2fb (patch)
tree94031f8112ac6dd932819f45de327b0d32c4e462 /tests/WebViewTests
parent38bc731875fec30d1a39f50cf3bf7234656f6698 (diff)
downloadframeworks_base-fc6cf2888426f5192b9f284d14b911f3bbc7c2fb.zip
frameworks_base-fc6cf2888426f5192b9f284d14b911f3bbc7c2fb.tar.gz
frameworks_base-fc6cf2888426f5192b9f284d14b911f3bbc7c2fb.tar.bz2
Add tests for array length bounds in WebView's Java Bridge
Tests for https://android-git.corp.google.com/g/150320. We test that when the legnth property of a JavaScript object is out of the bounds for a Java array, we convert to null. Also update a test in the case that the length property is not numeric. Bug: 5626284 Change-Id: If41acb117eb4b786d671b5ffece2704c6f045d52
Diffstat (limited to 'tests/WebViewTests')
-rw-r--r--tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
index 98f2391..2fd42a7 100644
--- a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
+++ b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
@@ -165,7 +165,26 @@ public class JavaBridgeArrayTest extends JavaBridgeTestBase {
// LIVECONNECT_COMPLIANCE: This should not count as an array, so we
// should raise a JavaScript exception.
executeJavaScript("testObject.setIntArray({length: \"foo\"});");
- assertEquals(0, mTestObject.waitForIntArray().length);
+ assertNull(mTestObject.waitForIntArray());
+ }
+
+ public void testLengthOutOfBounds() throws Throwable {
+ // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
+ // should raise a JavaScript exception.
+ executeJavaScript("testObject.setIntArray({length: -1});");
+ assertNull(mTestObject.waitForIntArray());
+
+ // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
+ // should raise a JavaScript exception.
+ long length = (long)Integer.MAX_VALUE + 1L;
+ executeJavaScript("testObject.setIntArray({length: " + length + "});");
+ assertNull(mTestObject.waitForIntArray());
+
+ // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
+ // should raise a JavaScript exception.
+ length = (long)Integer.MAX_VALUE + 1L - (long)Integer.MIN_VALUE + 1L;
+ executeJavaScript("testObject.setIntArray({length: " + length + "});");
+ assertNull(mTestObject.waitForIntArray());
}
public void testSparseArray() throws Throwable {