SHINDIG-1056 by lipeng, BasicRemoteContentTest doesn't depend on static private key...
[shindig.git] / javascript / container / rpctest_container.html
blob29564cc5651ef688c95aec7943b7a4003160f844
1 <!--
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 -->
20 <!--
21 Simple page for testing gadgets.rpc performance.
22 Allows you to add a simulated "gadget" (in this case just a static
23 HTML page which loads gadgets.rpc also), and pass some
24 specified number of random messages of specified size to
25 and from it.
27 A simple recommended setup is to start up two instances of
28 the Shindig Gadgets Server on two separate ports to test
29 "real" cross-domain communication, since port is factored
30 into the same-domain policy enforced by browsers.
32 If your servers are on localhost:8080 and localhost:8081, then hit:
33 http://localhost:8080/gadgets/files/container/rpctest_container.html? \
34 http://localhost:8081/gadgets/files/container/rpctest_gadget.html& \
35 http://localhost:8081/gadgets/files/container/rpc_relay.uncompressed.html& \
36 [ http://localhost:8080/gadgets/files/container/rpc_relay.uncompressed.html ]
38 (Note the backslashes should be removed, as they exist for formatting only.)
40 There are two arguments, separated by an ampersand:
41 1. URL of the "gadget" test page.
42 2. URL of the "gadget" test page's RPC relay (for browsers requiring it).
43 -->
44 <html>
45 <head>
46 <title>gadgets.rpc Performance Tests: Container</title>
47 <script src="../../js/rpc.js?c=1&debug=1"></script>
48 <script src="rpctest_perf.js"></script>
49 <script>
50 function initTest() {
51 var container = document.getElementById("container");
53 // query string is assumed to be the "gadget" URL as arg 1,
54 // and optionally the relay URL as arg 2
55 var pageArgs = window.location.search.substring(1).split('&');
56 var gadgetUrl = pageArgs[0];
57 var secret = Math.round(Math.random() * 10000000);
58 if (pageArgs[1]) {
59 gadgets.rpc.setRelayUrl('gadget', pageArgs[1]);
61 var containerRelay = pageArgs[2] || window.location.href;
62 container.innerHTML = "<iframe id='gadget' name='gadget' height=400 width=800 src='" + gadgetUrl + "?parent=" + containerRelay + "#rpctoken=" + secret + "'></iframe>";
63 gadgets.rpc.setAuthToken('gadget', secret);
65 document.getElementById('relaymethod').innerHTML = gadgets.rpc.getRelayChannel();
67 initPerfTest();
69 </script>
70 </head>
71 <body style="background-color: #cccccc" onload="initTest();">
72 <div>gadgets.rpc Performance: Container Page (method: <span id="relaymethod"></span>)</div><hr/>
73 <div>Test<br/>
74 <ul>
75 <li>Number of messages to send:
76 <select name="num_msgs" id="num_msgs">
77 <option value="1">1</option>
78 <option value="10">10</option>
79 <option value="100" selected>100</option>
80 <option value="1000">1000</option>
81 </select>
82 </li>
83 <li>Message size:
84 <select name="msg_size" id="msg_size">
85 <option value="10">10 B</option>
86 <option value="100">100 B</option>
87 <option value="1024" selected>1 kB</option>
88 <option value="10240">10 kB</option>
89 <option value="102400">100 kB</option>
90 <option value="1048576">1 MB</option>
91 </select>
92 </li>
93 <li>
94 <input type="button" value="Start The Test!" onclick="runPerfTest('gadget');" />
95 </li>
96 </ul>
97 </div>
98 <div id="test_running" style="display:none;">
99 Running test...
100 </div>
101 <div id="results" style="display:none;">
102 Results: Gadget-to-Container<br/>
103 Messages: <span id="results_num_received"></span>, Bytes: <span id="results_bytes_received"></span> <span id="in_or_out"></span><br/>
104 Time elapsed for test run: <span id="results_time_used"></span><br/>
105 Messages/second: <span id="results_msgs_per_sec"></span><br/>
106 Bytes/second: <span id="results_bytes_per_sec"></span>
107 </div>
108 <hr/>
109 <div>Gadget:</div>
110 <div id="container"></div>
111 </body>
112 </html>