]> git.proxmox.com Git - mirror_novnc.git/blob - tests/vnc_playback.html
Merge branch 'util-console' of https://github.com/tghw/noVNC
[mirror_novnc.git] / tests / vnc_playback.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>VNC Playback</title>
5 </head>
6 <body>
7
8 Iterations: <input id='iterations' style='width:50'>&nbsp;
9 Perftest:<input type='radio' id='mode1' name='mode' checked>&nbsp;
10 Realtime:<input type='radio' id='mode2' name='mode'>&nbsp;&nbsp;
11
12 <input id='startButton' type='button' value='Start' style='width:100px'
13 onclick="start();" disabled>&nbsp;
14
15 <br><br>
16
17 Results:<br>
18 <textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
19
20 <br><br>
21
22 <div id="VNC_screen">
23 <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
24 <table border=0 width=100%><tr>
25 <td><div id="VNC_status">Loading</div></td>
26 </tr></table>
27 </div>
28 <canvas id="VNC_canvas" width="640px" height="20px">
29 Canvas not supported.
30 </canvas>
31 </div>
32
33 </body>
34
35 <!--
36 <script type='text/javascript'
37 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
38 -->
39
40 <script type="text/javascript">
41 var INCLUDE_URI= "../";
42 </script>
43 <script src="../core/util.js"></script>
44 <script src="../app/webutil.js"></script>
45
46 <script>
47 var fname, start_time;
48
49 function message(str) {
50 console.log(str);
51 var cell = document.getElementById('messages');
52 cell.textContent += str + "\n";
53 cell.scrollTop = cell.scrollHeight;
54 }
55
56 fname = WebUtil.getQueryVar('data', null);
57 if (fname) {
58 message("Loading " + fname);
59 // Load supporting scripts
60 WebUtil.load_scripts({
61 'core': ["base64.js", "websock.js", "des.js", "input/keysym.js",
62 "input/keysymdef.js", "input/xtscancodes.js", "input/util.js",
63 "input/devices.js", "display.js", "rfb.js", "inflator.js"],
64 'tests': ["playback.js"],
65 'recordings': [fname]});
66
67 } else {
68 message("Must specify data=FOO in query string.");
69 }
70
71 disconnected = function (rfb, reason) {
72 if (reason) {
73 message("noVNC sent '" + state + "' state during iteration " + iteration + " frame " + frame_idx);
74 test_state = 'failed';
75 }
76 }
77
78 notification = function (rfb, mesg, level, options) {
79 document.getElementById('VNC_status').textContent = mesg;
80 }
81
82 function start() {
83 document.getElementById('startButton').value = "Running";
84 document.getElementById('startButton').disabled = true;
85
86 iterations = document.getElementById('iterations').value;
87 iteration = 0;
88 start_time = (new Date()).getTime();
89
90 if (document.getElementById('mode1').checked) {
91 message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
92 mode = 'perftest';
93 } else {
94 message("Starting realtime playback [" + iterations + " iteration(s)]");
95 mode = 'realtime';
96 }
97
98 //recv_message = rfb.testMode(send_array, VNC_frame_encoding);
99
100 next_iteration();
101 }
102
103 function finish() {
104 // Finished with all iterations
105 var total_time, end_time = (new Date()).getTime();
106 total_time = end_time - start_time;
107
108 iter_time = parseInt(total_time / iterations, 10);
109 message(iterations + " iterations took " + total_time + "ms, " +
110 iter_time + "ms per iteration");
111 // Shut-off event interception
112 rfb.get_mouse().ungrab();
113 rfb.get_keyboard().ungrab();
114 document.getElementById('startButton').disabled = false;
115 document.getElementById('startButton').value = "Start";
116
117 }
118
119 window.onscriptsload = function () {
120 iterations = WebUtil.getQueryVar('iterations', 3);
121 document.getElementById('iterations').value = iterations;
122 mode = WebUtil.getQueryVar('mode', 3);
123 if (mode === 'realtime') {
124 document.getElementById('mode2').checked = true;
125 } else {
126 document.getElementById('mode1').checked = true;
127 }
128 if (fname) {
129 message("VNC_frame_data.length: " + VNC_frame_data.length);
130 }
131 document.getElementById('startButton').disabled = false;
132 }
133 </script>
134 </html>