[Pkg-javascript-commits] [sockjs-client] 154/350: Allow toggle of same-origin on smoke tests.
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:03:57 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit 4a865c10cf49988e2f09ace44dd2f0dbc78646b4
Author: Bryce Kahle <bkahle at gmail.com>
Date: Thu Oct 16 19:53:05 2014 -0400
Allow toggle of same-origin on smoke tests.
---
tests/html/example-cursors.html | 15 ++++++++++++++-
tests/html/smoke-latency.html | 15 ++++++++++++++-
tests/html/smoke-reconnect.html | 13 +++++++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/tests/html/example-cursors.html b/tests/html/example-cursors.html
index f1b84c1..238f5f3 100644
--- a/tests/html/example-cursors.html
+++ b/tests/html/example-cursors.html
@@ -38,6 +38,7 @@
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
+ <input type="checkbox" id="sameOrigin" checked>Same Origin?
<input type="button" value="Connect" id="connect">
<input type="button" value="Disconnect" id="disconnect" disabled="yes">
</form>
@@ -75,7 +76,17 @@
'jsonp-polling'];
}
log('[connecting] ' + transport);
- sjs = new SockJS(clientOptions.url + '/broadcast', null, transport);
+ var url;
+ if ($('#sameOrigin').prop('checked')) {
+ if (window.location.origin) url = window.location.origin;
+ else {
+ url = window.location.protocol + '//' + window.location.hostname +
+ (window.location.port ? ':' + window.location.port : '');
+ }
+ } else {
+ url = clientOptions.url;
+ }
+ sjs = new SockJS(url + '/broadcast', null, transport);
sjs.onopen = onopen
sjs.onclose = onclose;
sjs.onmessage = xonmessage;
@@ -88,11 +99,13 @@
var onopen = function() {
log('connected ' + sjs.transport);
+ $('#sameOrigin').attr('disabled', true);
};
var onclose = function(e) {
log('disconnected ' + e.code + ', ' + e.reason);
$('#connect').each(function(_,e){e.disabled='';});
$('#disconnect').attr('disabled', true);
+ $('#sameOrigin').attr('disabled', false);
};
var myself = (''+Math.random()).substr(2);
var xonmessage = function(e) {
diff --git a/tests/html/smoke-latency.html b/tests/html/smoke-latency.html
index 1f84f62..09f9f13 100644
--- a/tests/html/smoke-latency.html
+++ b/tests/html/smoke-latency.html
@@ -27,6 +27,7 @@
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
+ <input type="checkbox" id="sameOrigin" checked>Same Origin?
<input type="button" value="Connect" id="connect">
<input type="button" value="Disconnect" id="disconnect" disabled="yes">
</form>
@@ -48,12 +49,14 @@
var sjs;
function onopen() {
log('connected ' + sjs.transport);
+ $('#sameOrigin').attr('disabled', true);
send();
};
function onclose(e) {
log('disconnected ' + e.code + ', ' + e.reason);
$('#connect').each(function(_,e){e.disabled='';});
$('#disconnect').attr('disabled', true);
+ $('#sameOrigin').attr('disabled', false);
};
function send() {
sjs.send(JSON.stringify({t: (new Date()).getTime()}));
@@ -72,7 +75,17 @@
$('#disconnect').each(function(_,e){e.disabled='';});
var transport = $('#transport').val() || undefined;
log('[connecting] ' + transport);
- sjs = new SockJS(clientOptions.url + '/echo', null, transport);
+ var url;
+ if ($('#sameOrigin').prop('checked')) {
+ if (window.location.origin) url = window.location.origin;
+ else {
+ url = window.location.protocol + '//' + window.location.hostname +
+ (window.location.port ? ':' + window.location.port : '');
+ }
+ } else {
+ url = clientOptions.url;
+ }
+ sjs = new SockJS(url + '/echo', null, transport);
sjs.onopen = onopen
sjs.onclose = onclose;
sjs.onmessage = xonmessage;
diff --git a/tests/html/smoke-reconnect.html b/tests/html/smoke-reconnect.html
index bbe967b..334044c 100644
--- a/tests/html/smoke-reconnect.html
+++ b/tests/html/smoke-reconnect.html
@@ -25,6 +25,7 @@
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
+ <input type="checkbox" id="sameOrigin" checked>Same Origin?
<input type="button" value="Start" id="connect">
<input type="button" value="Stop" id="disconnect" disabled="yes">
</form>
@@ -49,6 +50,7 @@
var transport;
var t0;
function onopen() {
+ $('#sameOrigin').attr('disabled', true);
var td = (new Date()).getTime() - t0;
i += 1;
$('#out').text(''+i +' ' + td + ' ms');
@@ -57,6 +59,16 @@
function onclose(e) {
if (started && e.code === 1000) {
t0 = (new Date()).getTime();
+ var url;
+ if ($('#sameOrigin').prop('checked')) {
+ if (window.location.origin) url = window.location.origin;
+ else {
+ url = window.location.protocol + '//' + window.location.hostname +
+ (window.location.port ? ':' + window.location.port : '');
+ }
+ } else {
+ url = clientOptions.url;
+ }
sjs = new SockJS(clientOptions.url + '/echo', null, transport);
sjs.onopen = onopen
sjs.onclose = onclose;
@@ -64,6 +76,7 @@
log('[stopped] ' + e.code + ', ' + e.reason);
$('#connect').each(function(_,e){e.disabled='';});
$('#disconnect').attr('disabled', true);
+ $('#sameOrigin').attr('disabled', false);
}
};
--
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