[Pkg-javascript-commits] [sockjs-client] 121/434: Example/smoke tests revamped.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 44a204db85a6b18473fcf60f09c393f72de1127d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Mon Sep 5 16:44:48 2011 +0100

    Example/smoke tests revamped.
---
 tests/html/example-cursors.html  | 48 +++++++++++++++++++++++++++++++++++-----
 tests/html/smoke-reconnect.html  | 13 +++--------
 tests/html/smoke-throughput.html |  3 +++
 3 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/tests/html/example-cursors.html b/tests/html/example-cursors.html
index 7eb577b..21ca706 100644
--- a/tests/html/example-cursors.html
+++ b/tests/html/example-cursors.html
@@ -17,6 +17,7 @@
         width: 30px;
         position: absolute;
         border: 1px solid grey;
+        z-index:-1;
       }
 
   </style>
@@ -24,6 +25,21 @@
 </head>
 <body>
 
+<form>
+  <select id="transport">
+  <option value="">- any - </option>
+  <option value="websocket">websocket</option>
+  <option value="xhr-streaming">xhr-streaming</option>
+  <option value="iframe-eventsource">iframe-eventsource</option>
+  <option value="iframe-htmlfile">iframe-htmlfile</option>
+  <option value="xhr-polling">xhr-polling</option>
+  <option value="iframe-xhr-polling">iframe-xhr-polling</option>
+  <option value="jsonp-polling">jsonp-polling</option>
+  </select>
+  <input type="button" value="Connect" id="connect">
+  <input type="button" value="Disconnect" id="disconnect" disabled="yes">
+</form>
+
   Latency: <code id="latency"></code><br>
   <code id="logs" style="height:200px; overflow:auto; display: block; border: 1px grey solid;">
   </code>
@@ -38,16 +54,34 @@
             $('#logs').scrollTop($('#logs').scrollTop()+10000);
       }
 
+    var sjs = null;
+    var protocol;
+    $('#connect').click(function() {
+        $('#connect').attr('disabled', true);
+        $('#disconnect').attr('disabled', false);
+        var protocol = $('#transport').val() || undefined;
+        log('[connecting] ' + protocol);
+        sjs = new SockJS(client_opts.url + '/broadcast', protocol, client_opts.sockjs_opts);
+        sjs.onopen = onopen
+        sjs.onclose = onclose;
+        sjs.onmessage = onmessage;
+    });
+    $('#disconnect').click(function() {
+        $('#disconnect').attr('disabled', true);
+        log('[disconnecting]');
+        sjs.close();
+    });
 
-    var sjs = new SockJS(client_opts.url + '/broadcast', undefined, client_opts.sockjs_opts);
-    sjs.onopen = function() {
+    var onopen = function() {
         log('connected ' + sjs.protocol);
     };
-    sjs.onclose = function(e) {
+    var onclose = function(e) {
         log('disconnected ' + e);
+        $('#connect').attr('disabled', false);
+        $('#disconnect').attr('disabled', true);
     };
     var myself = (''+Math.random()).substr(2);
-    sjs.onmessage = function(e) {
+    var onmessage = function(e) {
         var msg = JSON.parse(e.data);
         if (msg.id === myself) {
             var td = (new Date()).getTime() - msg.t;
@@ -65,18 +99,20 @@
          x = e.pageX; y = e.pageY;
          if(!tref) poll();
     });
-    function poll() {
+    var poll = function() {
          tref = null;
          if (last_x === x && last_y === y)
              return;
          var msg = {x:x, y:y, t: (new Date()).getTime(), id:myself};
          last_x = x; last_y = y;
          var raw_msg = JSON.stringify(msg);
-         if (sjs.readyState === SockJS.OPEN) {
+         if (sjs && sjs.readyState === SockJS.OPEN) {
              sjs.send(raw_msg);
          }
          tref = setTimeout(poll, 200);
     };
+    $('#connect').attr('disabled', false);
+    $('#disconnect').attr('disabled', true);
 </script>
 </body>
 </html>
diff --git a/tests/html/smoke-reconnect.html b/tests/html/smoke-reconnect.html
index e1f2011..060d5aa 100644
--- a/tests/html/smoke-reconnect.html
+++ b/tests/html/smoke-reconnect.html
@@ -10,23 +10,15 @@
   <script type="text/javascript" src="static/jquery.min.js"></script>
 
   <script type="text/javascript" src="config.js"></script>
-
-  <style type="text/css">
-      .cursor {
-        height: 30px;
-        width: 30px;
-        position: absolute;
-        border: 1px solid grey;
-      }
-  </style>
-
 </head>
 <body>
 <form>
   <select id="transport">
   <option value="">- any - </option>
   <option value="websocket">websocket</option>
+  <option value="xhr-streaming">xhr-streaming</option>
   <option value="iframe-eventsource">iframe-eventsource</option>
+  <option value="iframe-htmlfile">iframe-htmlfile</option>
   <option value="xhr-polling">xhr-polling</option>
   <option value="iframe-xhr-polling">iframe-xhr-polling</option>
   <option value="jsonp-polling">jsonp-polling</option>
@@ -88,6 +80,7 @@
         $('#disconnect').attr('disabled', false);
     });
     $('#disconnect').click(function() {
+        $('#disconnect').attr('disabled', true);
         log('[stopping...]');
         started = false;
     });
diff --git a/tests/html/smoke-throughput.html b/tests/html/smoke-throughput.html
index 4a11bd4..e017d8e 100644
--- a/tests/html/smoke-throughput.html
+++ b/tests/html/smoke-throughput.html
@@ -26,7 +26,9 @@
   <select id="transport">
   <option value="">- any - </option>
   <option value="websocket">websocket</option>
+  <option value="xhr-streaming">xhr-streaming</option>
   <option value="iframe-eventsource">iframe-eventsource</option>
+  <option value="iframe-htmlfile">iframe-htmlfile</option>
   <option value="xhr-polling">xhr-polling</option>
   <option value="iframe-xhr-polling">iframe-xhr-polling</option>
   <option value="jsonp-polling">jsonp-polling</option>
@@ -83,6 +85,7 @@
         sjs.onmessage = onmessage;
     });
     $('#disconnect').click(function() {
+        $('#disconnect').attr('disabled', true);
         log('[disconnecting]');
         sjs.close();
     });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list