[ 
https://issues.apache.org/jira/browse/CB-5219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13869606#comment-13869606
 ] 

Björn Andersson commented on CB-5219:
-------------------------------------

I just updated to the latest version of Cordova (3.3.1-0.1.2), created a new 
project and tried it out. Sadly no difference.

I had a discussion with xored on FreeNode about this as well in November and 
xored had noticed that weinre raises an exception. The exception raised is 
because there is no event object passed to the XHR object's 
{{onchangereadystate}}.

We found this out by adding an {{onerror}} handler that would output all errors 
for us:

{code}
        window.onerror = function(msg, url, line) {
            console.log('ERROR');
            console.log('Message: '+ msg +' --- line: '+ line);
            console.log('ENDERROR');
        };
{code}

To try and get to some kind of bottom of this I've been playing around with 
patching the 
[XHRShim|https://github.com/apache/cordova-wp8/blob/master/wp8/template/cordovalib/XHRHelper.cs#L34]
 a bit more but haven't been able to figure out anything really constructive. 

So far I've changed the 
[changeReadyState|https://github.com/apache/cordova-wp8/blob/master/wp8/template/cordovalib/XHRHelper.cs#L121]
 method on XHRShim to send {{ {target: this.wrappedXHR} }} as the first 
argument and that gets past the first exception raised.

But then it stops because {{xhr.httpSocketHandler}} isn't set. 
[Code|https://github.com/apache/cordova-weinre/blob/master/weinre.web/modules/weinre/common/WebSocketXhr.coffee#L215]

And if I return {{null}} if {{httpSocketHandler}} isn't set then there's 
another exception in turn.

The really curious thing here is that for some reason the weinre 
{{onreadystate}} handler is getting used, but {{httpSocket}} and 
{{httpSocketHandler}} isn't set on the object that is set as the event target. 
So when weinre tries to use the attributes it added to the object it fails.

> weinre disconnects when history.replaceState is used
> ----------------------------------------------------
>
>                 Key: CB-5219
>                 URL: https://issues.apache.org/jira/browse/CB-5219
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: WP8
>    Affects Versions: 3.1.0
>         Environment: Windows 8, Visual Studio 2012
>            Reporter: Björn Andersson
>            Assignee: Patrick Mueller
>
> I got an app that uses weinre and when developing on Android, BB10 and iOS I 
> never had any issues. But on WP8 it kept disconnect pretty much instantly 
> after connecting.
> I found that if I do:
> {code}
> history.replaceState(null, 'weinre, say bye-bye', '/some-fake-url')
> {code}
> Weinre will disconnect. I've tried this with the Cordova hello world app and 
> just adding in that line above disconnects weinre.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to