You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Ilya Buziuk (JIRA)" <ji...@apache.org> on 2013/07/08 13:07:48 UTC
[jira] [Updated] (CB-3503) Incorrect way of message processing
[ https://issues.apache.org/jira/browse/CB-3503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ilya Buziuk updated CB-3503:
----------------------------
Affects Version/s: (was: 2.7.0)
2.9.0
> Incorrect way of message processing
> -----------------------------------
>
> Key: CB-3503
> URL: https://issues.apache.org/jira/browse/CB-3503
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaJS
> Affects Versions: 2.9.0
> Reporter: Ilya Buziuk
> Assignee: Filip Maj
> Attachments: prompt.png
>
>
> Steps to reproduce:
> 1) Create html file:
> {code}
> <!DOCTYPE html>
> <html>
> <head>
> <script type="text/javascript" src="cordova-2.7.0.js"></script>
> <meta charset="UTF-8">
> <title>Insert title here</title>
> </head>
> <body>
> <h1>Hello World!</h1>
> </body>
> </html>
> {code}
> 2. Add cordova-2.7.0.js in the same directory
> 3. Open newly created file in chrome
> 4. The prompt alert will be shown !prompt.png! -> press "Ok" -> cordova.js will trap in endless loop
> NOTE: the root of the problem is pretty obvious - incorrect while cycle (lines 988 - 1009)
> {code}
> while (messagesFromNative.length) {
> // Don't unshift until the end so that reentrancy can be detected.
> messages = messagesFromNative[0];
> // The Java side can send a * message to indicate that it
> // still has messages waiting to be retrieved.
> if (messages == '*') {
> messagesFromNative.shift();
> window.setTimeout(pollOnce, 0);
> return;
> }
> var spaceIdx = messages.indexOf(' ');
> var msgLen = +messages.slice(0, spaceIdx);
> var message = messages.substr(spaceIdx + 1, msgLen);
> messages = messages.slice(spaceIdx + msgLen + 1);
> processMessage(message);
> if (messages) {
> messagesFromNative[0] = messages;
> } else {
> messagesFromNative.shift();
> }
> }
> {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