Skip to content

Commit

Permalink
#1685: fine grained javascript debug logging
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@17768 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 27, 2017
1 parent 39e3cc0 commit b426bcc
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 80 deletions.
16 changes: 13 additions & 3 deletions src/html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,14 @@ <h4 class="panel-title">Advanced options</h4>
<input type="checkbox" id="video"> <span>Video (experimental) <input type="checkbox" id="mediasource_video"> Native decoding</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="debug"> <span>Debugging</span>
<span>Debugging</span>:
<input type="checkbox" id="debug_main"> <span>Main</span>,
<input type="checkbox" id="debug_keyboard"> <span>keyboard</span>,
<input type="checkbox" id="debug_mouse"> <span>mouse</span>,
<input type="checkbox" id="debug_clipboard"> <span>clipboard</span>
<input type="checkbox" id="debug_draw"> <span>draw</span>,
<input type="checkbox" id="debug_audio"> <span>audio</span>,
<input type="checkbox" id="debug_network"> <span>network</span>
</li>
</ul>
</div>
Expand Down Expand Up @@ -307,7 +314,9 @@ <h4 class="panel-title">Advanced options</h4>
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect", "swap_keys",
"video", "mediasource_video",
"debug", "insecure"];
"insecure",
"debug_main", "debug_keyboard", "debug_mouse", "debug_clipboard", "debug_draw", "debug_audio", "debug_network",
];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
add_prop(prop, document.getElementById(prop).checked);
Expand Down Expand Up @@ -505,7 +514,8 @@ <h4 class="panel-title">Advanced options</h4>
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect", "swap_keys",
"video", "mediasource_video",
"debug", "insecure"];
"debug_main", "debug_keyboard", "debug_mouse", "debug_clipboard", "debug_draw", "debug_audio", "debug_network",
"insecure"];
var default_on = ["steal", "clipboard", "printing", "file_transfer", "reconnect", "exit_with_children", "exit_with_client"];
if (Utilities.isMacOS()) {
default_on.push("swap_keys");
Expand Down
46 changes: 30 additions & 16 deletions src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
var video = getboolparam("video", false);
var mediasource_video = getboolparam("mediasource_video", false);
var remote_logging = getboolparam("remote_logging", true);
var debug = getboolparam("debug", false);
var insecure = getboolparam("insecure", false);
var ignore_audio_blacklist = getboolparam("ignore_audio_blacklist", false);
var clipboard = getboolparam("clipboard", true);
Expand Down Expand Up @@ -155,9 +154,20 @@
}
}

var debug_categories = [];
var categories = ["main", "keyboard", "mouse", "clipboard", "draw", "audio", "network"];
for(var i=0, len=categories.length; i < len; i++) {
var category = categories[i];
var debug = getboolparam("debug_"+category, false);
if (debug) {
debug_categories.push(category);
}
}
console.log("debug enabled for:", debug_categories);

// create the client
var client = new XpraClient('screen');
client.debug = debug;
client.debug_categories = debug_categories;
client.remote_logging = remote_logging;
client.sharing = sharing;
client.insecure = insecure;
Expand All @@ -178,16 +188,16 @@
if (debug) {
//example of client event hooks:
client.on_open = function() {
cdebug("connection open");
cdebug("network", "connection open");
};
client.on_connect = function() {
cdebug("connection established");
cdebug("network", "connection established");
};
client.on_first_ui_event = function() {
cdebug("first ui event");
cdebug("network", "first ui event");
};
client.on_last_window = function() {
cdebug("last window disappeared");
cdebug("network", "last window disappeared");
};
}

Expand Down Expand Up @@ -255,7 +265,8 @@
}

// attach a callback for when client closes
if(!debug) {
var debug_main = getboolparam("debug_main", false);
if(!debug_main) {
client.callback_close = function(reason) {
if(submit) {
var message = "Connection closed (socket closed)";
Expand Down Expand Up @@ -297,11 +308,14 @@
"steal" : steal,
"video" : video,
"mediasource_video" : mediasource_video,
"debug" : debug,
"remote_logging" : remote_logging,
"insecure" : insecure,
"ignore_audio_blacklist" : ignore_audio_blacklist,
}
for (var i=0, len=client.debug_categories.length; i < len; i++) {
var category = client.debug_categories[i];
props["debug_"+category] = true;
}
if (insecure || sessionStorage) {
props["password"] = password;
}
Expand Down Expand Up @@ -335,7 +349,7 @@
pasteboard.on("input", function(e) {
var txt = pasteboard.val();
pasteboard.val("");
cdebug("oninput:", txt);
cdebug("keyboard", "oninput:", txt);
if (!client.topwindow) {
return;
}
Expand All @@ -347,10 +361,10 @@
keyval = keycode;
group = 0;
packet = ["key-action", client.topwindow, str, true, modifiers, keyval, str, keycode, group];
cdebug(packet);
cdebug("keyboard", packet);
client.send(packet);
packet = ["key-action", client.topwindow, str, false, modifiers, keyval, str, keycode, group];
cdebug(packet);
cdebug("keyboard", packet);
client.send(packet);
}
catch (e) {
Expand All @@ -365,23 +379,23 @@
//clipboard hooks:
pasteboard.on('paste', function (e) {
var paste_data = (e.originalEvent || e).clipboardData.getData('text/plain');
cdebug("paste event, data=", paste_data);
cdebug("clipboard", "paste event, data=", paste_data);
client.send_clipboard_token(unescape(encodeURIComponent(paste_data)));
return false;
});
pasteboard.on('copy', function (e) {
var clipboard_buffer = client.get_clipboard_buffer();
pasteboard.text(decodeURIComponent(escape(clipboard_buffer)));
pasteboard.select();
cdebug("copy event, clipboard buffer=", clipboard_buffer);
cdebug("clipboard", "copy event, clipboard buffer=", clipboard_buffer);
client.clipboard_pending = false;
return true;
});
pasteboard.on('cut', function (e) {
var clipboard_buffer = client.get_clipboard_buffer();
pasteboard.text(decodeURIComponent(escape(clipboard_buffer)));
pasteboard.select();
cdebug("cut event, clipboard buffer=", clipboard_buffer);
cdebug("clipboard", "cut event, clipboard buffer=", clipboard_buffer);
client.clipboard_pending = false;
return true;
});
Expand All @@ -391,7 +405,7 @@
var clipboard_buffer = client.get_clipboard_buffer();
pasteboard.text(clipboard_buffer);
pasteboard.select();
cdebug("click event, with pending clipboard buffer=", clipboard_buffer);
cdebug("clipboard", "click event, with pending clipboard buffer=", clipboard_buffer);
//for IE:
var success = true;
if (window.clipboardData && window.clipboardData.setData) {
Expand Down Expand Up @@ -447,7 +461,7 @@
client.log.apply(client, arguments);
}
cdebug = function() {
client._debug.apply(client, arguments);
client.debug.apply(client, arguments);
}
init_tablet_input(client);
if (client.clipboard_enabled) {
Expand Down
Loading

0 comments on commit b426bcc

Please sign in to comment.