Bug 719127 - Debugger error: jschar out of char range; high bits of data lost. r=past

This commit is contained in:
Dave Camp 2012-02-14 11:45:35 -08:00
parent dbcb775601
commit b22b05ea44
2 changed files with 12 additions and 2 deletions

View File

@ -58,6 +58,11 @@ function DebuggerTransport(aInput, aOutput)
{
this._input = aInput;
this._output = aOutput;
this._converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
this._converter.charset = "UTF-8";
this._outgoing = "";
this._incoming = "";
}
@ -73,6 +78,7 @@ DebuggerTransport.prototype = {
send: function DT_send(aPacket) {
// TODO (bug 709088): remove pretty printing when the protocol is done.
let data = JSON.stringify(aPacket, null, 2);
data = this._converter.ConvertFromUnicode(data);
data = data.length + ':' + data;
this._outgoing += data;
this._flushOutgoing();
@ -159,6 +165,7 @@ DebuggerTransport.prototype = {
this._incoming = this._incoming.substring(count);
try {
packet = this._converter.ConvertToUnicode(packet);
var parsed = JSON.parse(packet);
} catch(e) {
dumpn("Error parsing incoming packet: " + packet + " (" + e + " - " + e.stack + ")");

View File

@ -28,17 +28,20 @@ function test_socket_conn()
{
DebuggerServer.openListener(2929, true);
let unicodeString = "(╯°□°)╯︵ ┻━┻";
let transport = debuggerSocketConnect("127.0.0.1", 2929);
transport.hooks = {
onPacket: function(aPacket) {
this.onPacket = function(aPacket) {
do_check_eq(aPacket.unicode, unicodeString);
transport.close();
}
// Verify that things work correctly when bigger than the output
// transport buffers...
// transport buffers and when transporting unicode...
transport.send({to: "root",
type: "echo",
reallylong: really_long()});
reallylong: really_long(),
unicode: unicodeString});
do_check_eq(aPacket.from, "root");
},
onClosed: function(aStatus) {