diff options
author | Steve Block <steveblock@google.com> | 2012-05-25 14:01:52 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2012-05-25 14:24:40 +0100 |
commit | 830698b1d94fc7215bd7a8ec50f884141a29212f (patch) | |
tree | 9635bb78caa09a1b9731208259969da137b1c386 /tests/WebViewTests/src/com | |
parent | 213efc48e4089075c9f4eec46f3365e016b33326 (diff) | |
download | frameworks_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/src/com')
-rw-r--r-- | tests/WebViewTests/src/com/android/webviewtests/JavaBridgeTestBase.java | 7 |
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 + " })()"); } }); } |