summaryrefslogtreecommitdiffstats
path: root/tests/WebViewTests
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-05-25 14:01:52 +0100
committerSteve Block <steveblock@google.com>2012-05-25 14:24:40 +0100
commit830698b1d94fc7215bd7a8ec50f884141a29212f (patch)
tree9635bb78caa09a1b9731208259969da137b1c386 /tests/WebViewTests
parent213efc48e4089075c9f4eec46f3365e016b33326 (diff)
downloadframeworks_base-830698b1d94fc7215bd7a8ec50f884141a29212f.zip
frameworks_base-830698b1d94fc7215bd7a8ec50f884141a29212f.tar.gz
frameworks_base-830698b1d94fc7215bd7a8ec50f884141a29212f.tar.bz2
Avoid unintended side-effects of loading javascript: URLS in Java Bridge tests
Change-Id: I8ba9a32ca0d0d80395029d92886155d2ed13d6f4
Diffstat (limited to 'tests/WebViewTests')
-rw-r--r--tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java
index 1af3f63..a451015 100644
--- a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java
+++ b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java
@@ -106,7 +106,12 @@ public class JavaBridgeTestBase extends ActivityInstrumentationTestCase2<WebView
runTestOnUiThread(new Runnable() {
@Override
public void run() {
- getWebView().loadUrl("javascript:" + script);
+ // When a JavaScript URL is executed, if the value of the last
+ // expression evaluated is not 'undefined', this value is
+ // converted to a string and used as the new document for the
+ // frame. We don't want this behaviour, so wrap the script in
+ // an anonymous function.
+ getWebView().loadUrl("javascript:(function() { " + script + " })()");
}
});
}