Bug 44849

Summary: xmlhttprequest event javascript String functions not available
Product: WebKit Reporter: ss
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Major    
Priority: P2    
Version: 420+   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
the networks class
none
the user code none

ss
Reported 2010-08-29 19:46:39 PDT
In a xmlhttprequest progress event callback. I try to use var t = "test" ; var p = t.subStr(2); and it fails the javascript string functions are not available CODE ***** function maChat() { this.url = "/mafw/chat.ma"; } maChat.prototype = new maWeb( this.url ); function callback( evt, maweb ) { var t = "test"; var p = t.subStr(2); var obj = maweb.getObj( evt ); var stat = maweb.getStat( evt ); alert( stat["code"]+stat["text"]+" "+ JSON.stringify( obj ) ); } function sendmsg( ) { var cmd = {}; cmd["type"] = "cmd"; cmd["cmd"] = "initdata"; cmd["me"] = 0; try { var conn = new maWeb( "http://localhost/mafw/chat.ma" ); conn.send( JSON.stringify ( cmd ), callback ); } catch (e ) { alert (e); } // try { // var conn1 = new maChat(); // conn1.send( JSON.stringify ( cmd ), callback ); // } catch (e ) { // alert (e); // } }; function sendpush() { var cmd = {}; cmd["type"] = "cmd"; cmd["cmd"] = "initdata"; cmd["me"] = 0; try { var conn = new maWeb( "http://localhost/mafw/chat.psh", true ); conn.setProgress( callback ); conn.send( JSON.stringify ( cmd ), callback ); } catch (e ) { alert (e); } } CODE2 ********************************* function maWeb( url, push, method ) { this.method = "POST"; this.multi = false; this.url = url; this.self = this; this.oldLen = 0; if ( method != undefined ) this.method = method; if ( push != undefined ) this.multi = push; var req = new XMLHttpRequest(); this._req = req; req.multipart = this.multi; this.send = function( data, loadcb ) { var self = this; this._req.onload = function( evt ) { loadcb( evt, self ); return false; }; this._req.open( this.method, this.url, true ); try { this._req.send( data ); } catch (e) { alert( e ); } }; this.setProgress = function( func ) { var self = this; self._req.onprogress = function ( evt ) { return func( evt, self ); } }; this.addCallback = function( name, func ) { var self = this; var cb = function ( evt ) { var r = evt.target; var s = r.responseText.length; func( evt, self ); } switch( name ) { case "loadstart": req.onloadstart = cb; break; case "progress": req.onprogress = cb; break; case "abort": req.onabort = cb; break; case "error": req.onerror = cb; break; default: req.addEventListener( name, function ( evt ) { func( evt, self ); }, false); }; }; this.abort = function() { req.abort(); }; this.getObj = function( evt ) { var r = evt.target; var str; switch ( r.readyState ) { case 4: //Firefox case 2: //Chrome str = r.responseText; break; case 3: //Chrome str = r.responseText.subStr( this.oldLen ); this.oldLen = r.responseText.length; break; default: break; }; try { var obj = JSON.parse( str ); } catch (e) { alert( e ); } return obj }; this.getStat = function( evt ) { var r = evt.target; var stat = {}; stat["code"] = r.status; stat["text"] = r.statusText; return stat; } };
Attachments
the networks class (1.81 KB, application/javascript)
2010-08-29 19:47 PDT, ss
no flags
the user code (975 bytes, application/javascript)
2010-08-29 19:48 PDT, ss
no flags
ss
Comment 1 2010-08-29 19:47:24 PDT
Created attachment 65870 [details] the networks class
ss
Comment 2 2010-08-29 19:48:20 PDT
Created attachment 65871 [details] the user code
Darin Adler
Comment 3 2014-04-24 16:45:18 PDT
Moving all JavaScriptGlue bugs to JavaScriptCore. The JavaScriptGlue framework itself is long gone. And most of the more recent bugs put in this component were put there by people who thought this was for some other aspect of “JavaScript glue” and have nothing to do with the actual original reason for the existence of this component, which was an OS-X-only framework named JavaScriptGlue.
Note You need to log in before you can comment on or make changes to this bug.