Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 830698b1 authored by Steve Block's avatar Steve Block
Browse files

Avoid unintended side-effects of loading javascript: URLS in Java Bridge tests

Change-Id: I8ba9a32ca0d0d80395029d92886155d2ed13d6f4
parent 213efc48
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -106,7 +106,12 @@ public class JavaBridgeTestBase extends ActivityInstrumentationTestCase2<WebView
        runTestOnUiThread(new Runnable() {
        runTestOnUiThread(new Runnable() {
            @Override
            @Override
            public void run() {
            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 + " })()");
            }
            }
        });
        });
    }
    }