Author: johnh
Date: Tue Jun 9 23:53:10 2009
New Revision: 783165
URL: http://svn.apache.org/viewvc?rev=783165&view=rev
Log:
Added gadget-in-a-gadget to rpc tests.
Added:
incubator/shindig/trunk/javascript/container/rpctest_childgadget.xml
Modified:
incubator/shindig/trunk/javascript/container/rpctest_container.html
incubator/shindig/trunk/javascript/container/rpctest_gadget.xml
Added: incubator/shindig/trunk/javascript/container/rpctest_childgadget.xml
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_childgadget.xml?rev=783165&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_childgadget.xml (added)
+++ incubator/shindig/trunk/javascript/container/rpctest_childgadget.xml Tue
Jun 9 23:53:10 2009
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<Module>
+ <ModulePrefs title="gadgets.rpc Performance/correctness tests:
gadget-in-a-gadget">
+ <Require feature="rpc"/>
+ </ModulePrefs>
+ <Content type="html">
+ <![CDATA[
+ <script>
+ function callGadgetServicePing() {
+ gadgets.rpc.call(null, 'gadget_service_ping');
+ }
+ </script>
+ <div>gadget-in-a-gadget</div><hr/>
+ <div><input type="button" value="Ping Parent Gadget"
onclick="callGadgetServicePing();" /></div>
+ ]]>
+ </Content>
+</Module>
Modified: incubator/shindig/trunk/javascript/container/rpctest_container.html
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_container.html?rev=783165&r1=783164&r2=783165&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_container.html
(original)
+++ incubator/shindig/trunk/javascript/container/rpctest_container.html Tue Jun
9 23:53:10 2009
@@ -86,6 +86,14 @@
status.innerHTML = 'gadget says: ' + message;
}
gadgets.rpc.register('initial_gadget_message',
handleInitialGadgetMessage);
+
+ function handleGadgetServicePing() {
+ var childping = document.getElementById('childping');
+ var pingval = childping.innerHTML;
+ pingval++;
+ childping.innerHTML = pingval;
+ }
+ gadgets.rpc.register('gadget_service_ping', handleGadgetServicePing);
function appendGadget() {
var secret = Math.round(Math.random() * 10000000);
@@ -125,7 +133,8 @@
</head>
<body style="background-color: #cccccc" onload="initTestContainer();">
<div>gadgets.rpc Performance: Container Page (method: <span
id="relaymethod"></span>)</div><hr/>
- <div>Initial gadget render console: <span id="initconsole">Gadget hasn't
commented yet.</span></div><hr/>
+ <div>Initial gadget render console: <span id="initconsole">Gadget hasn't
commented yet.</span></div>
+ <div>Child gadget ping count: <span id="childping">0</span></div><hr/>
<div>Test<br/>
<ul>
<li>Number of messages to send:
Modified: incubator/shindig/trunk/javascript/container/rpctest_gadget.xml
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_gadget.xml?rev=783165&r1=783164&r2=783165&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_gadget.xml (original)
+++ incubator/shindig/trunk/javascript/container/rpctest_gadget.xml Tue Jun 9
23:53:10 2009
@@ -31,12 +31,39 @@
document.write('<scr' + 'ipt language="JavaScript"
type="text/javascript" src="/gadgets/files/container/rpctest_perf.js?' +
cachebust + '"></scr' + 'ipt>');
</script>
<script>
+ // Register ping handler.
+ gadgets.rpc.register('gadget_service_ping', function() {
+ var queryConsole = document.getElementById('queryconsole');
+ var numQueries = queryConsole.innerHTML;
+ ++numQueries;
+ queryConsole.innerHTML = numQueries;
+ var whoAsked = document.getElementById('whoasked');
+ whoAsked.innerHTML = this.f;
+ });
+
+ function appendChildGadget() {
+ var childgadgetdiv = document.getElementById('childgadgetdiv');
+ var parentDomain =
gadgets.rpc.getDomainRoot(gadgets.util.getUrlParameters().parent);
+ var myDomain = gadgets.rpc.getDomainRoot(window.location.href);
+ var rpctoken = Math.round(Math.random() * 10000000);
+ var childGadgetUrl = parentDomain + '/gadgets/ifr?url=' + parentDomain
+ '/gadgets/files/container/rpctest_childgadget.xml&parent=' + myDomain +
'#rpctoken=' + rpctoken;
+ childgadgetdiv.innerHTML = '<div><input type="button" value="Ping
Parent (Container)" onclick="callGadgetServicePing();"/><hr/>' +
+ '<div>Who-am-I query count: <span id="queryconsole">0</span>, last q
from: <span id="whoasked"></span></div>' +
+ '<div><iframe id="childgadget" name="childgadget" height=100
width=200 src="about:blank"></iframe></div>';
+ document.getElementById("childgadget").src = childGadgetUrl;
+ gadgets.rpc.setAuthToken('childgadget', rpctoken);
+ }
+
+ function callGadgetServicePing() {
+ gadgets.rpc.call(null, 'gadget_service_ping');
+ }
+
// Initialize performance test onLoad.
gadgets.util.registerOnLoadHandler(initPerfTest);
</script>
<div>gadgets.rpc Performance: "Gadget" page</div><hr/>
<script>
- document.write("<div>"Parent relay: " + gadgets.rpc.getRelayUrl('..') +
"</div><hr/>");
+ document.write("<div>Parent relay: " + gadgets.rpc.getRelayUrl('..') +
"</div><hr/>");
</script>
<div>Test<br/>
<ul>
@@ -72,7 +99,8 @@
Time elapsed for test run: <span id="results_time_used"></span><br/>
Messages/second: <span id="results_msgs_per_sec"></span><br/>
Bytes/second: <span id="results_bytes_per_sec"></span>
- </div>
+ </div><hr/>
+ <div id="childgadgetdiv"><input type="button" value="Child Gadget Tests"
onclick="appendChildGadget();"/></div>
]]>
</Content>
</Module>