3 <title>VNC Test
</title>
4 <link rel=
"stylesheet" href=
"include/plain.css">
8 Iterations:
<input id='iterations' style='width:
50'
value=
"3">
10 <input id='startButton' type='button' value='Start' style='width:
100px'
11 onclick=
"start();" disabled
>
16 <div id=
"VNC_status_bar" class=
"VNC_status_bar" style=
"margin-top: 0px;">
17 <table border=
0 width=
100%
><tr>
18 <td><div id=
"VNC_status">Loading
</div></td>
21 <canvas id=
"VNC_canvas" width=
"640px" height=
"20px">
28 <textarea id=
"messages" style=
"font-size: 9;" cols=
80 rows=
25></textarea>
32 <script type='text/javascript'
33 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
36 <script src=
"include/vnc.js"></script>
39 var rfb, fname, test_state, frame_idx, frame_length, iteration,
40 iterations, start_time, packetID, waitTimer;
42 function message(str) {
45 cell.innerHTML += str +
"\n";
46 cell.scrollTop = cell.scrollHeight;
49 fname = (document.location.href.match(
50 /data=([A-Za-z0-
9\._\-]*)/) ||
54 message(
"Loading " + fname);
55 document.write('
<script src=
"' + fname + '"><\/script
>');
57 message(
"Must specify data=FOO in query string.");
60 // Override send_array
61 send_array = function (arr) {
62 // Stub out send_array
65 updateState = function (rfb, state, oldstate, msg) {
69 message(
"noVNC sent '" + state +
"' state during iteration " + iteration);
70 test_state = 'failed';
73 $('startButton').disabled = false;
76 if (typeof msg !== 'undefined') {
77 $('VNC_status').innerHTML = msg;
82 $('startButton').value =
"Running";
83 $('startButton').disabled = true;
84 test_state = 'running';
86 iterations = $('iterations').value;
88 frame_length = VNC_frame_data.length;
90 start_time = (new Date()).getTime();
92 setTimeout(next_iteration,
1);
95 function next_iteration () {
96 var time, iter_time, end_time;
98 if (test_state !== 'running') { return; }
100 if (iteration !==
0) {
105 if (iteration
> iterations) {
106 // Finished with all iterations
107 var end_time = (new Date()).getTime();
108 total_time = end_time - start_time;
110 iter_time = parseInt(total_time / iterations,
10);
111 message(iterations +
" iterations took " + total_time +
"ms, " +
112 iter_time +
"ms per iteration");
113 rfb.get_canvas().stop(); // Shut-off event interception
114 $('startButton').disabled = false;
115 $('startButton').value =
"Start";
120 rfb.connect('test',
0,
"bogus");
122 setTimeout(do_packet,
1);
126 function do_packet () {
128 if (test_state !== 'running') { return; }
130 frame = VNC_frame_data[frame_idx];
131 while (frame.charAt(
0) ===
"}") {
132 //message(
"Send frame " + frame_idx);
134 frame = VNC_frame_data[frame_idx];
135 if (frame_idx
>= frame_length) {
141 //message(
"Processing frame: " + frame_idx);
143 rfb.recv_message({'data' : frame.slice(frame.indexOf('{',
1)+
1)});
147 if (frame_idx
>= frame_length) {
150 setTimeout(do_packet,
1);
154 window.onload = function() {
156 message(
"VNC_frame_data.length: " + VNC_frame_data.length);
157 rfb = RFB({'target': 'VNC_canvas',
158 'updateState': updateState});
159 rfb.testMode(send_array);