gecko-dev/testing/web-platform/tests/tools/pywebsocket/example/console.html
Geoffrey Sneddon 8b783a7e69 Bug 1439967 [wpt PR 9606] - Update pywebsockets, a=testonly
Automatic update from web-platform-testsMerge pull request #9606 from gsnedders/update_pywebsockets

Update pywebsockets

wpt-commits: 38811892842f1db4a029ee0d4d42764c5e12ae6d
wpt-pr: 9606
wpt-commits: 38811892842f1db4a029ee0d4d42764c5e12ae6d
wpt-pr: 9606


--HG--
rename : testing/web-platform/tests/tools/pywebsocket/src/COPYING => testing/web-platform/tests/tools/pywebsocket/LICENSE
rename : testing/web-platform/tests/tools/pywebsocket/src/MANIFEST.in => testing/web-platform/tests/tools/pywebsocket/MANIFEST.in
rename : testing/web-platform/tests/tools/pywebsocket/src/README => testing/web-platform/tests/tools/pywebsocket/README
rename : testing/web-platform/tests/tools/pywebsocket/src/example/abort_handshake_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/abort_handshake_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/abort_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/abort_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/arraybuffer_benchmark.html => testing/web-platform/tests/tools/pywebsocket/example/arraybuffer_benchmark.html
rename : testing/web-platform/tests/tools/pywebsocket/src/example/bench_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/bench_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/benchmark_helper_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/benchmark_helper_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/close_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/close_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/console.html => testing/web-platform/tests/tools/pywebsocket/example/console.html
rename : testing/web-platform/tests/tools/pywebsocket/src/example/cookie_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/cookie_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/echo_client.py => testing/web-platform/tests/tools/pywebsocket/example/echo_client.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/echo_noext_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/echo_noext_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/echo_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/echo_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/eventsource.cgi => testing/web-platform/tests/tools/pywebsocket/example/eventsource.cgi
rename : testing/web-platform/tests/tools/pywebsocket/src/example/eventsource.html => testing/web-platform/tests/tools/pywebsocket/example/eventsource.html
rename : testing/web-platform/tests/tools/pywebsocket/src/example/handler_map.txt => testing/web-platform/tests/tools/pywebsocket/example/handler_map.txt
rename : testing/web-platform/tests/tools/pywebsocket/src/example/hsts_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/hsts_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/internal_error_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/internal_error_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/origin_check_wsh.py => testing/web-platform/tests/tools/pywebsocket/example/origin_check_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/example/pywebsocket.conf => testing/web-platform/tests/tools/pywebsocket/example/pywebsocket.conf
rename : testing/web-platform/tests/tools/pywebsocket/src/example/special_headers.cgi => testing/web-platform/tests/tools/pywebsocket/example/special_headers.cgi
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/__init__.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/__init__.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/_stream_base.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/_stream_base.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/_stream_hixie75.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/_stream_hixie75.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/dispatch.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/dispatch.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/fast_masking.i => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/fast_masking.i
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/handshake/__init__.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/handshake/__init__.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/handshake/_base.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/handshake/_base.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/handshake/hybi.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/handshake/hybi.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/handshake/hybi00.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/handshake/hybi00.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/http_header_util.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/http_header_util.py
rename : testing/web-platform/tests/tools/pywebsocket/src/mod_pywebsocket/msgutil.py => testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/msgutil.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/cert/cacert.pem => testing/web-platform/tests/tools/pywebsocket/test/cert/cacert.pem
rename : testing/web-platform/tests/tools/pywebsocket/src/test/cert/cert.pem => testing/web-platform/tests/tools/pywebsocket/test/cert/cert.pem
rename : testing/web-platform/tests/tools/pywebsocket/src/test/cert/client_cert.p12 => testing/web-platform/tests/tools/pywebsocket/test/cert/client_cert.p12
rename : testing/web-platform/tests/tools/pywebsocket/src/test/cert/key.pem => testing/web-platform/tests/tools/pywebsocket/test/cert/key.pem
rename : testing/web-platform/tests/tools/pywebsocket/src/test/client_for_testing.py => testing/web-platform/tests/tools/pywebsocket/test/client_for_testing.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/endtoend_with_external_server.py => testing/web-platform/tests/tools/pywebsocket/test/endtoend_with_external_server.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/mock.py => testing/web-platform/tests/tools/pywebsocket/test/mock.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/mux_client_for_testing.py => testing/web-platform/tests/tools/pywebsocket/test/mux_client_for_testing.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/run_all.py => testing/web-platform/tests/tools/pywebsocket/test/run_all.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/set_sys_path.py => testing/web-platform/tests/tools/pywebsocket/test/set_sys_path.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_dispatch.py => testing/web-platform/tests/tools/pywebsocket/test/test_dispatch.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_endtoend.py => testing/web-platform/tests/tools/pywebsocket/test/test_endtoend.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_handshake.py => testing/web-platform/tests/tools/pywebsocket/test/test_handshake.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_handshake_hybi00.py => testing/web-platform/tests/tools/pywebsocket/test/test_handshake_hybi00.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_http_header_util.py => testing/web-platform/tests/tools/pywebsocket/test/test_http_header_util.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_memorizingfile.py => testing/web-platform/tests/tools/pywebsocket/test/test_memorizingfile.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_mock.py => testing/web-platform/tests/tools/pywebsocket/test/test_mock.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_stream.py => testing/web-platform/tests/tools/pywebsocket/test/test_stream.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_stream_hixie75.py => testing/web-platform/tests/tools/pywebsocket/test/test_stream_hixie75.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/test_util.py => testing/web-platform/tests/tools/pywebsocket/test/test_util.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/README => testing/web-platform/tests/tools/pywebsocket/test/testdata/README
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/abort_by_user_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/abort_by_user_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/blank_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/blank_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/origin_check_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/origin_check_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/exception_in_transfer_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/exception_in_transfer_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/no_wsh_at_the_end.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/no_wsh_at_the_end.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/non_callable_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/non_callable_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/plain_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/plain_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/wrong_handshake_sig_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/wrong_handshake_sig_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/handlers/sub/wrong_transfer_sig_wsh.py => testing/web-platform/tests/tools/pywebsocket/test/testdata/handlers/sub/wrong_transfer_sig_wsh.py
rename : testing/web-platform/tests/tools/pywebsocket/src/test/testdata/hello.pl => testing/web-platform/tests/tools/pywebsocket/test/testdata/hello.pl
2018-03-31 22:24:31 +01:00

317 lines
8.1 KiB
HTML

<!--
Copyright 2011, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!--
A simple console for testing WebSocket server.
Type an address into the top text input and click connect to establish
WebSocket. Then, type some message into the bottom text input and click send
to send the message. Received/sent messages and connection state will be shown
on the middle textarea.
-->
<html>
<head>
<title>WebSocket console</title>
<script>
var socket = null;
var showTimeStamp = false;
var addressBox = null;
var protocolsBox = null;
var logBox = null;
var messageBox = null;
var fileBox = null;
var codeBox = null;
var reasonBox = null;
function getTimeStamp() {
return new Date().getTime();
}
function addToLog(log) {
if (showTimeStamp) {
logBox.value += '[' + getTimeStamp() + '] ';
}
logBox.value += log + '\n'
// Large enough to keep showing the latest message.
logBox.scrollTop = 1000000;
}
function setbinarytype(binaryType) {
if (!socket) {
addToLog('Not connected');
return;
}
socket.binaryType = binaryType;
addToLog('Set binaryType to ' + binaryType);
}
function send() {
if (!socket) {
addToLog('Not connected');
return;
}
socket.send(messageBox.value);
addToLog('> ' + messageBox.value);
messageBox.value = '';
}
function sendfile() {
if (!socket) {
addToLog('Not connected');
return;
}
var files = fileBox.files;
if (files.length == 0) {
addToLog('File not selected');
return;
}
socket.send(files[0]);
addToLog('> Send ' + files[0].name);
}
function parseProtocols(protocolsText) {
var protocols = protocolsText.split(',');
for (var i = 0; i < protocols.length; ++i) {
protocols[i] = protocols[i].trim();
}
if (protocols.length == 0) {
// Don't pass.
protocols = null;
} else if (protocols.length == 1) {
if (protocols[0].length == 0) {
// Don't pass.
protocols = null;
} else {
// Pass as a string.
protocols = protocols[0];
}
}
return protocols;
}
function connect() {
var url = addressBox.value;
var protocols = parseProtocols(protocolsBox.value);
if ('WebSocket' in window) {
if (protocols) {
socket = new WebSocket(url, protocols);
} else {
socket = new WebSocket(url);
}
} else {
return;
}
socket.onopen = function () {
var extraInfo = [];
if (('protocol' in socket) && socket.protocol) {
extraInfo.push('protocol = ' + socket.protocol);
}
if (('extensions' in socket) && socket.extensions) {
extraInfo.push('extensions = ' + socket.extensions);
}
var logMessage = 'Opened';
if (extraInfo.length > 0) {
logMessage += ' (' + extraInfo.join(', ') + ')';
}
addToLog(logMessage);
};
socket.onmessage = function (event) {
if (('ArrayBuffer' in window) && (event.data instanceof ArrayBuffer)) {
addToLog('< Received an ArrayBuffer of ' + event.data.byteLength +
' bytes')
} else if (('Blob' in window) && (event.data instanceof Blob)) {
addToLog('< Received a Blob of ' + event.data.size + ' bytes')
} else {
addToLog('< ' + event.data);
}
};
socket.onerror = function () {
addToLog('Error');
};
socket.onclose = function (event) {
var logMessage = 'Closed (';
if ((arguments.length == 1) && ('CloseEvent' in window) &&
(event instanceof CloseEvent)) {
logMessage += 'wasClean = ' + event.wasClean;
// code and reason are present only for
// draft-ietf-hybi-thewebsocketprotocol-06 and later
if ('code' in event) {
logMessage += ', code = ' + event.code;
}
if ('reason' in event) {
logMessage += ', reason = ' + event.reason;
}
} else {
logMessage += 'CloseEvent is not available';
}
addToLog(logMessage + ')');
};
if (protocols) {
addToLog('Connect ' + url + ' (protocols = ' + protocols + ')');
} else {
addToLog('Connect ' + url);
}
}
function closeSocket() {
if (!socket) {
addToLog('Not connected');
return;
}
if (codeBox.value || reasonBox.value) {
socket.close(codeBox.value, reasonBox.value);
} else {
socket.close();
}
}
function printState() {
if (!socket) {
addToLog('Not connected');
return;
}
addToLog(
'url = ' + socket.url +
', readyState = ' + socket.readyState +
', bufferedAmount = ' + socket.bufferedAmount);
}
function init() {
var scheme = window.location.protocol == 'https:' ? 'wss://' : 'ws://';
var defaultAddress = scheme + window.location.host + '/echo';
addressBox = document.getElementById('address');
protocolsBox = document.getElementById('protocols');
logBox = document.getElementById('log');
messageBox = document.getElementById('message');
fileBox = document.getElementById('file');
codeBox = document.getElementById('code');
reasonBox = document.getElementById('reason');
addressBox.value = defaultAddress;
if (!('WebSocket' in window)) {
addToLog('WebSocket is not available');
}
}
</script>
<style type="text/css">
form {
margin: 0px;
}
#connect_div, #log_div, #send_div, #sendfile_div, #close_div, #printstate_div {
padding: 5px;
margin: 5px;
border-width: 0px 0px 0px 10px;
border-style: solid;
border-color: silver;
}
</style>
</head>
<body onload="init()">
<div>
<div id="connect_div">
<form action="#" onsubmit="connect(); return false;">
url <input type="text" id="address" size="40">
<input type="submit" value="connect">
<br/>
protocols <input type="text" id="protocols" size="20">
</form>
</div>
<div id="log_div">
<textarea id="log" rows="10" cols="40" readonly></textarea>
<br/>
<input type="checkbox"
name="showtimestamp"
value="showtimestamp"
onclick="showTimeStamp = this.checked">Show time stamp
</div>
<div id="send_div">
<form action="#" onsubmit="send(); return false;">
data <input type="text" id="message" size="40">
<input type="submit" value="send">
</form>
</div>
<div id="sendfile_div">
<form action="#" onsubmit="sendfile(); return false;">
<input type="file" id="file" size="40">
<input type="submit" value="send file">
</form>
Set binaryType
<input type="radio"
name="binarytype"
value="blob"
onclick="setbinarytype('blob')" checked>blob
<input type="radio"
name="binarytype"
value="arraybuffer"
onclick="setbinarytype('arraybuffer')">arraybuffer
</div>
<div id="close_div">
<form action="#" onsubmit="closeSocket(); return false;">
code <input type="text" id="code" size="10">
reason <input type="text" id="reason" size="20">
<input type="submit" value="close">
</form>
</div>
<div id="printstate_div">
<input type="button" value="print state" onclick="printState();">
</div>
</div>
</body>
</html>