summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2010-12-10 08:25:36 -0600
committerJoel Martin <github@martintribe.org>2010-12-10 08:25:36 -0600
commite46719100c52b65921f941945ccd1440cef702cd (patch)
tree6c97bea5614bddba8c124fd78f9a2a646fd3a33e /tests
parent5b0bbd5c122cc019432011d420af7807ed4562b4 (diff)
downloadwebsockify-e46719100c52b65921f941945ccd1440cef702cd.tar.gz
Make compatible with jQuery. Slight API change.
Rename the $() selector to $D() so that it doesn't collide with the jQuery name. The API change is that the 'target' option for Canvas and RFB objects must now be a DOM Canvas element. A string is no longer accepted because this requires that a DOM lookup is done and the Canvas and RFB should have no UI code in them. Modularity.
Diffstat (limited to 'tests')
-rw-r--r--tests/base64.html2
-rw-r--r--tests/canvas.html20
-rw-r--r--tests/cursor.html8
-rw-r--r--tests/input.html4
-rw-r--r--tests/vnc_perf.html20
-rw-r--r--tests/vnc_playback.html28
-rw-r--r--tests/ws.html28
-rw-r--r--tests/wsencoding.html20
8 files changed, 65 insertions, 65 deletions
diff --git a/tests/base64.html b/tests/base64.html
index b13253e..24ad80b 100644
--- a/tests/base64.html
+++ b/tests/base64.html
@@ -19,7 +19,7 @@
<script>
function debug(str) {
console.log(str);
- cell = $('debug');
+ cell = $D('debug');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
diff --git a/tests/canvas.html b/tests/canvas.html
index 382e1dd..9ff5bd8 100644
--- a/tests/canvas.html
+++ b/tests/canvas.html
@@ -40,7 +40,7 @@
function message(str) {
console.log(str);
- cell = $('messages');
+ cell = $D('messages');
cell.innerHTML += msg_cnt + ": " + str + "\n";
cell.scrollTop = cell.scrollHeight;
msg_cnt += 1;
@@ -80,10 +80,10 @@
}
function begin () {
- $('startButton').value = "Running";
- $('startButton').disabled = true;
+ $D('startButton').value = "Running";
+ $D('startButton').disabled = true;
setTimeout(start_delayed, 250);
- iterations = $('iterations').value;
+ iterations = $D('iterations').value;
}
function start_delayed () {
@@ -109,14 +109,14 @@
canvas.resize(start_width, start_height, true);
test_functions();
}
- $('startButton').disabled = false;
- $('startButton').value = "Do Performance Test";
+ $D('startButton').disabled = false;
+ $D('startButton').value = "Do Performance Test";
}
function run_test () {
var width, height;
- width = $('width').value;
- height = $('height').value;
+ width = $D('width').value;
+ height = $D('height').value;
canvas.resize(width, height);
var color, start_time = (new Date()).getTime(), w, h;
for (var i=0; i < iterations; i++) {
@@ -137,8 +137,8 @@
window.onload = function() {
message("in onload");
- $('iterations').value = 10;
- canvas = Canvas({'target' : 'canvas'});
+ $D('iterations').value = 10;
+ canvas = new Canvas({'target' : $D('canvas')});
canvas.resize(start_width, start_height, true);
message("Canvas initialized");
test_functions();
diff --git a/tests/cursor.html b/tests/cursor.html
index 0e0dd9a..0fdd7a8 100644
--- a/tests/cursor.html
+++ b/tests/cursor.html
@@ -34,7 +34,7 @@
<script>
function debug(str) {
console.log(str);
- cell = $('debug');
+ cell = $D('debug');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -119,16 +119,16 @@
debug("onload");
var canvas, cross, cursor, cursor64;
- canvas = new Canvas({'target' : "testcanvas"});
+ canvas = new Canvas({'target' : $D("testcanvas")});
debug("canvas indicates Data URI cursor support is: " + canvas.get_cursor_uri());
- $('button1').style.cursor="url(face.png), default";
+ $D('button1').style.cursor="url(face.png), default";
cursor = makeCursor();
cursor64 = Base64.encode(cursor);
//debug("cursor: " + cursor.slice(0,100) + " (" + cursor.length + ")");
//debug("cursor64: " + cursor64.slice(0,100) + " (" + cursor64.length + ")");
- $('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default";
+ $D('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default";
debug("onload complete");
}
diff --git a/tests/input.html b/tests/input.html
index b3fc8ed..7f47a2b 100644
--- a/tests/input.html
+++ b/tests/input.html
@@ -29,7 +29,7 @@
function message(str) {
console.log(str);
- cell = $('messages');
+ cell = $D('messages');
cell.innerHTML += msg_cnt + ": " + str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -53,7 +53,7 @@
}
window.onload = function() {
- var canvas = Canvas({'target' : 'canvas'});
+ var canvas = new Canvas({'target' : $D('canvas')});
canvas.resize(width, height, true);
canvas.start(keyPress, mouseButton, mouseMove);
message("Canvas initialized");
diff --git a/tests/vnc_perf.html b/tests/vnc_perf.html
index 8e9c925..1fde5dd 100644
--- a/tests/vnc_perf.html
+++ b/tests/vnc_perf.html
@@ -47,7 +47,7 @@
function msg(str) {
console.log(str);
- var cell = $('messages');
+ var cell = $D('messages');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -68,20 +68,20 @@
test_state = 'failed';
break;
case 'loaded':
- $('startButton').disabled = false;
+ $D('startButton').disabled = false;
break;
}
if (typeof mesg !== 'undefined') {
- $('VNC_status').innerHTML = mesg;
+ $D('VNC_status').innerHTML = mesg;
}
}
function start() {
- $('startButton').value = "Running";
- $('startButton').disabled = true;
+ $D('startButton').value = "Running";
+ $D('startButton').disabled = true;
mode = 'perftest'; // full-speed
- passes = $('passes').value;
+ passes = $D('passes').value;
pass = 1;
encIdx = 0;
@@ -123,8 +123,8 @@
if (pass > passes) {
// We are finished
rfb.get_canvas().stop(); // Shut-off event interception
- $('startButton').disabled = false;
- $('startButton').value = "Start";
+ $D('startButton').disabled = false;
+ $D('startButton').value = "Start";
finish_passes();
return; // We are finished, terminate
}
@@ -189,8 +189,8 @@
enc = encOrder[i];
dbgmsg(" " + enc + ": " + VNC_frame_data_multi[enc].length);
}
- rfb = RFB({'target': 'VNC_canvas',
- 'updateState': updateState});
+ rfb = new RFB({'target': $D('VNC_canvas'),
+ 'updateState': updateState});
rfb.testMode(send_array);
}
</script>
diff --git a/tests/vnc_playback.html b/tests/vnc_playback.html
index d777a84..3a1f49a 100644
--- a/tests/vnc_playback.html
+++ b/tests/vnc_playback.html
@@ -45,7 +45,7 @@
function message(str) {
console.log(str);
- var cell = $('messages');
+ var cell = $D('messages');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -67,23 +67,23 @@
test_state = 'failed';
break;
case 'loaded':
- $('startButton').disabled = false;
+ $D('startButton').disabled = false;
break;
}
if (typeof msg !== 'undefined') {
- $('VNC_status').innerHTML = msg;
+ $D('VNC_status').innerHTML = msg;
}
}
function start() {
- $('startButton').value = "Running";
- $('startButton').disabled = true;
+ $D('startButton').value = "Running";
+ $D('startButton').disabled = true;
- iterations = $('iterations').value;
+ iterations = $D('iterations').value;
iteration = 0;
start_time = (new Date()).getTime();
- if ($('mode1').checked) {
+ if ($D('mode1').checked) {
message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
mode = 'perftest';
} else {
@@ -103,24 +103,24 @@
message(iterations + " iterations took " + total_time + "ms, " +
iter_time + "ms per iteration");
rfb.get_canvas().stop(); // Shut-off event interception
- $('startButton').disabled = false;
- $('startButton').value = "Start";
+ $D('startButton').disabled = false;
+ $D('startButton').value = "Start";
}
window.onload = function() {
iterations = WebUtil.getQueryVar('iterations', 3);
- $('iterations').value = iterations;
+ $D('iterations').value = iterations;
mode = WebUtil.getQueryVar('mode', 3);
if (mode === 'realtime') {
- $('mode2').checked = true;
+ $D('mode2').checked = true;
} else {
- $('mode1').checked = true;
+ $D('mode1').checked = true;
}
if (fname) {
message("VNC_frame_data.length: " + VNC_frame_data.length);
- rfb = RFB({'target': 'VNC_canvas',
- 'updateState': updateState});
+ rfb = new RFB({'target': $D('VNC_canvas'),
+ 'updateState': updateState});
rfb.testMode(send_array);
}
}
diff --git a/tests/ws.html b/tests/ws.html
index e6bf5ac..c56c4c7 100644
--- a/tests/ws.html
+++ b/tests/ws.html
@@ -47,7 +47,7 @@
function error(str) {
console.error(str);
- cell = $('error');
+ cell = $D('error');
cell.innerHTML += errors + ": " + str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -147,15 +147,15 @@
}
function update_stats() {
- $('sent').innerHTML = sent;
- $('received').innerHTML = received;
- $('errors').innerHTML = errors;
+ $D('sent').innerHTML = sent;
+ $D('received').innerHTML = received;
+ $D('errors').innerHTML = errors;
}
function init_ws() {
console.log(">> init_ws");
var scheme = "ws://";
- if ($('encrypt').checked) {
+ if ($D('encrypt').checked) {
scheme = "wss://";
}
var uri = scheme + host + ":" + port;
@@ -188,9 +188,9 @@
function connect() {
console.log(">> connect");
- host = $('host').value;
- port = $('port').value;
- sendDelay = parseInt($('sendDelay').value, 10);
+ host = $D('host').value;
+ port = $D('port').value;
+ sendDelay = parseInt($D('sendDelay').value, 10);
if ((!host) || (!port)) {
console.log("must set host and port");
return;
@@ -202,8 +202,8 @@
init_ws();
update_ref = setInterval(update_stats, 1);
- $('connectButton').value = "Stop";
- $('connectButton').onclick = disconnect;
+ $D('connectButton').value = "Stop";
+ $D('connectButton').onclick = disconnect;
console.log("<< connect");
}
@@ -218,8 +218,8 @@
recv_seq = 0;
send_seq = 0;
- $('connectButton').value = "Start";
- $('connectButton').onclick = connect;
+ $D('connectButton').value = "Start";
+ $D('connectButton').onclick = connect;
console.log("<< disconnect");
}
@@ -244,8 +244,8 @@
WebSocket.__initialize();
}
var url = document.location.href;
- $('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
- $('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
+ $D('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
+ $D('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
}
</script>
diff --git a/tests/wsencoding.html b/tests/wsencoding.html
index 48277c9..846645e 100644
--- a/tests/wsencoding.html
+++ b/tests/wsencoding.html
@@ -34,7 +34,7 @@
function message(str) {
console.log(str);
- cell = $('messages');
+ cell = $D('messages');
cell.innerHTML += str + "\n";
cell.scrollTop = cell.scrollHeight;
}
@@ -65,7 +65,7 @@
function init_ws() {
console.log(">> init_ws");
var scheme = "ws://";
- if ($('encrypt').checked) {
+ if ($D('encrypt').checked) {
scheme = "wss://";
}
var uri = scheme + host + ":" + port;
@@ -97,8 +97,8 @@
function connect() {
console.log(">> connect");
- host = $('host').value;
- port = $('port').value;
+ host = $D('host').value;
+ port = $D('port').value;
if ((!host) || (!port)) {
console.log("must set host and port");
return;
@@ -109,8 +109,8 @@
}
init_ws();
- $('connectButton').value = "Stop";
- $('connectButton').onclick = disconnect;
+ $D('connectButton').value = "Stop";
+ $D('connectButton').onclick = disconnect;
console.log("<< connect");
}
@@ -120,8 +120,8 @@
ws.close();
}
- $('connectButton').value = "Start";
- $('connectButton').onclick = connect;
+ $D('connectButton').value = "Start";
+ $D('connectButton').onclick = connect;
console.log("<< disconnect");
}
@@ -143,8 +143,8 @@
WebSocket.__initialize();
}
var url = document.location.href;
- $('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
- $('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
+ $D('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
+ $D('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
}
</script>