[
https://issues.apache.org/jira/browse/CB-4788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13764982#comment-13764982
]
Peter commented on CB-4788:
---------------------------
I agree that the mobile-spec test which includes cordova.js is really what
should be changed.
That is why I hesitated to even categorise this suggestion as a "fix". It is
just a peice of code that prevents a careless user from killing themselves by
accident. So it is more forgiving than the status quo, and the warning is an
added bonus. AFAIK the code does no harm at all, and the logging might actually
save somebody from hours of guessing where they went wrong.
> Android InAppBrowser workaround for destructive PROMPT bridge problems
> ----------------------------------------------------------------------
>
> Key: CB-4788
> URL: https://issues.apache.org/jira/browse/CB-4788
> Project: Apache Cordova
> Issue Type: Improvement
> Components: Android, mobile-spec, Plugin InAppBrowser
> Affects Versions: 2.9.0
> Reporter: Peter
> Assignee: Joe Bowser
>
> We encountered the same problem as CB-4005 when running the manual
> mobile-spec tests.
> Please consider the following modified InAppBrowser code as a workaround to
> this issue.
> *Observations:*
> * If InAppBrowser uses Cordova API at all then the cordova.js falls back to
> using the PROMPT bridge because there is no _cordovaNative defined by
> InAppBrowser.
> * The InAppBrowser’s onJsPrompt method (current implementation) is not
> capable of handling the PROMPT bridge messages (eg "gap:", "gap_poll:" etc)
> The combination of the above causes the huge number of prompts which results
> in the application non-responsiveness issues already described by CB-4005 and
> elsewhere.
> *Solution:*
> Change the IAB onJsPrompt to simply _ignore_ those unhandled messages from
> Cordova PROMPT bridge.
> * Since there is no ability for IAB to run the API calls anyway [Ref 3] no
> functionality is lost.
> * Now the mobile-spec tests for InAppBrowser can run OK without suffering the
> unresponsive problems reported by CB-4005 and CB-3665
> Perhaps this is not be a true "fix", but it is certainly more forgiving than
> the current implementation which just hangs.
> Here is my suggested modification for InAppBrowser.onJsPrompt()
> {code}
> @Override
> public boolean onJsPrompt(WebView view, String url, String message, String
> defaultValue, JsPromptResult result) {
> if (defaultValue != null) {
> // See if the prompt string uses the 'gap-iab' protocol. If so, the
> remainder should be the id of a callback to execute.
> if (defaultValue.startsWith("gap-iab://")) {
> ...
> // blah blah same code as before
> ...
> }
> /*
> * IAP does not support ability to execute Cordova API calls so just
> gobble them up
> * and log a warning.
> */
> if (defaultValue.startsWith("gap")) {
> if (!defaultValue.equals("gap_poll:")) {
> LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API
> calls: " + url + " " + defaultValue);
> }
> result.cancel();
> return true;
> }
>
> }
> return false;
> }
> {code}
> Please try it. Works for me :)
> Related to:
> [1] CB-4005
> [2] CB-3665
> [3] PG Forum https://groups.google.com/forum/#!topic/phonegap/wyOezp7B-iI
--
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