You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2013/05/30 20:13:21 UTC

[jira] [Updated] (CB-3548) Error handling in onJsPrompt not working

     [ https://issues.apache.org/jira/browse/CB-3548?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser updated CB-3548:
---------------------------

    Priority: Major  (was: Critical)

We only should be using the JSPrompt bridge if everything else fails to work, therefore I don't consider this a critical issue, since we should almost never use it.
                
> Error handling in onJsPrompt not working
> ----------------------------------------
>
>                 Key: CB-3548
>                 URL: https://issues.apache.org/jira/browse/CB-3548
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.7.0
>            Reporter: Peter
>            Assignee: Joe Bowser
>
> (This is a contrived scenario written to try to understand the bridging implementation)
> It seems the error handling in the onJsPrompt() bridge in CordovaChromeClient.java is not working correctly.
> {code}
>         if (reqOk && defaultValue != null && defaultValue.length() > 3 && defaultValue.substring(0, 4).equals("gap:")) {
>             JSONArray array;
>             try {
>                 array = new JSONArray(defaultValue.substring(4));
>                 String service = array.getString(0);
>                 String action = array.getString(1);
>                 String callbackId = array.getString(2);
>                 String r = this.appView.exposedJsApi.exec(service, action, callbackId, message);
>                 result.confirm(r == null ? "" : r);
>             } catch (JSONException e) {
>                 e.printStackTrace();
>             }
> {code}
> ---
> If JSONException occurs then my application fails and cannot recover. For example, try below.
> {code}
> <button onclick="myFunction()">Try it</button>
> <script>
> function myFunction()
> {
> var one=prompt("test1","Harry Potter");
> var two=prompt("test2","gap: abc");
> }
> </script>
> {code}
> ---
> But if I modify the onJsPrompt code as follows then it behaves more gracefully:
> {code}
>             } catch (JSONException e) {
>                 e.printStackTrace();
>                 return false; // added
>             }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira