noVNC/tests/vnc_playback.html
Solly Ross ae510306b5 Enable noVNC to become Browserifiable
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
2016-09-16 15:49:51 -04:00

141 lines
4.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>VNC Playback</title>
</head>
<body>
Iterations: <input id='iterations' style='width:50'>&nbsp;
Perftest:<input type='radio' id='mode1' name='mode' checked>&nbsp;
Realtime:<input type='radio' id='mode2' name='mode'>&nbsp;&nbsp;
<input id='startButton' type='button' value='Start' style='width:100px'
onclick="start();" disabled>&nbsp;
<br><br>
Results:<br>
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
<br><br>
<div id="VNC_screen">
<div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
<table border=0 width=100%><tr>
<td><div id="VNC_status">Loading</div></td>
</tr></table>
</div>
<canvas id="VNC_canvas" width="640px" height="20px">
Canvas not supported.
</canvas>
</div>
</body>
<!--
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
<script type="text/javascript">
var INCLUDE_URI= "../";
// TODO: Data file should override
var VNC_frame_encoding = "binary";
</script>
<script src="../core/util.js"></script>
<script src="../app/webutil.js"></script>
<script>
var fname, start_time;
function message(str) {
console.log(str);
var cell = document.getElementById('messages');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
fname = WebUtil.getQueryVar('data', null);
if (fname) {
message("Loading " + fname);
// Load supporting scripts
Util.load_scripts({
'core': ["base64.js", "websock.js", "des.js", "keysym.js",
"keysymdef.js", "xtscancodes.js", "keyboard.js",
"input.js", "display.js", "rfb.js", "inflator.js"],
'tests': ["playback.js"],
'recordings': [fname]});
} else {
message("Must specify data=FOO in query string.");
}
updateState = function (rfb, state, oldstate, msg) {
switch (state) {
case 'failed':
case 'fatal':
message("noVNC sent '" + state + "' state during iteration " + iteration + " frame " + frame_idx);
test_state = 'failed';
break;
case 'loaded':
break;
}
if (typeof msg !== 'undefined') {
document.getElementById('VNC_status').innerHTML = msg;
}
}
function start() {
document.getElementById('startButton').value = "Running";
document.getElementById('startButton').disabled = true;
iterations = document.getElementById('iterations').value;
iteration = 0;
start_time = (new Date()).getTime();
if (document.getElementById('mode1').checked) {
message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
mode = 'perftest';
} else {
message("Starting realtime playback [" + iterations + " iteration(s)]");
mode = 'realtime';
}
//recv_message = rfb.testMode(send_array, VNC_frame_encoding);
next_iteration();
}
function finish() {
// Finished with all iterations
var total_time, end_time = (new Date()).getTime();
total_time = end_time - start_time;
iter_time = parseInt(total_time / iterations, 10);
message(iterations + " iterations took " + total_time + "ms, " +
iter_time + "ms per iteration");
// Shut-off event interception
rfb.get_mouse().ungrab();
rfb.get_keyboard().ungrab();
document.getElementById('startButton').disabled = false;
document.getElementById('startButton').value = "Start";
}
window.onscriptsload = function () {
iterations = WebUtil.getQueryVar('iterations', 3);
document.getElementById('iterations').value = iterations;
mode = WebUtil.getQueryVar('mode', 3);
if (mode === 'realtime') {
document.getElementById('mode2').checked = true;
} else {
document.getElementById('mode1').checked = true;
}
if (fname) {
message("VNC_frame_data.length: " + VNC_frame_data.length);
}
document.getElementById('startButton').disabled = false;
}
</script>
</html>