-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugintest.html
78 lines (72 loc) · 2.18 KB
/
plugintest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<title>Object test</title>
<script>
var cp;
function runRegressionTests() {
document.getElementById('plugin').createRegressionTests().runTests(
function(name, res) {
document.getElementById('test_results').innerHTML
+= '<tr><td><pre>'
+ name
+ '</pre></td><td><pre style="color: '
+ ((res == 'SUCCEEDED') ? 'green' : 'red')
+ ';">'
+ res
+ '</pre></td></tr>';
});
}
function pluginLoaded() {
window.ConnectionPeer = function(config) {
return document.getElementById('plugin').createConnectionPeer(config);
}
cp = new ConnectionPeer('');
cp.onconnect = function() {
document.getElementById('status').innerHTML = "connected";
}
cp.ondisconnect = function() {
document.getElementById('status').innerHTML = "not connected";
}
cp.ontext = function(text) {
document.getElementById('data').innerHTML += "<pre>RECV:" + text + "</pre>";
}
cp.getLocalConfiguration(function(configuration) {
document.getElementById('local_sdp').innerHTML = configuration;
});
}
function addRemoteConfiguration() {
var config = document.getElementById('remote_sdp').value;
cp.addRemoteConfiguration(config);
}
function sendText() {
var text = document.getElementById('data_input').value;
cp.sendText(text, true);
document.getElementById('data').innerHTML += "<pre>SENT:" + text + "</pre>";
}
</script>
</head>
<body>
<table id="test_results"><thead><td>Regression test name</td><td>Result</td></thead></table>
<br />
<input type="button" value="Run regression tests" onclick="runRegressionTests()" />
<br />
<p>Local SDP:</p>
<pre id="local_sdp" style="width:600px; background-color: silver;"></pre>
<p>Remote SDP:</p>
<textarea id="remote_sdp" style="width: 600px; height: 200px;"></textarea>
<br />
<input type="button" value="Add Remote SDP" onclick="addRemoteConfiguration();" />
<br />
<p>Status:</p>
<pre id="status">not connected</pre>
<p>Exchanged data:</p>
<div id="data"></div>
<form onsubmit="sendText(); return false;">
<input type="text" id="data_input" /><input type="submit" value="Send text" />
</form>
<br/>
<object id="plugin" type="application/x-WebP2P" width="300" height="300">
<param name="onload" value="pluginLoaded" />
</object><br />
</body>
</html>