зеркало из https://github.com/mozilla/gecko-dev.git
Manual testfile for XML-RPC, not part of build. See README for usage.
This commit is contained in:
Родитель
c049f96de1
Коммит
9d033fe555
|
@ -0,0 +1,7 @@
|
|||
Create a chrome/test/comtent directory and place xml-rpc.xul in that dir. Then
|
||||
fire up Mozilla with -chrome chrome://test/content/xml-rpc.xul.
|
||||
|
||||
Fill in a number between 1 and 50, and click the button. A XML-RPC server,
|
||||
courtesy of Userland software, will tell you what US state it thinks goes with
|
||||
that number.
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<window title="XML-RPC test"
|
||||
style="margins: 5 5 5 5"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script language="javascript"><![CDATA[
|
||||
function getClient() {
|
||||
return Components.classes['mozilla.xml-rpc.client.1']
|
||||
.createInstance(Components.interfaces.nsIXmlRpcClient);
|
||||
}
|
||||
|
||||
var xmlRpcClient;
|
||||
function getXmlRpc() {
|
||||
if (!xmlRpcClient) xmlRpcClient = getClient();
|
||||
return xmlRpcClient;
|
||||
}
|
||||
|
||||
function callAsync() {
|
||||
dump('Call Async\n');
|
||||
var xmlRpc = getXmlRpc();
|
||||
xmlRpc.init('http://betty.userland.com/RPC2');
|
||||
var stateCode = xmlRpc.createType(xmlRpc.INT);
|
||||
stateCode.data = document.getElementById('statecode').value;
|
||||
|
||||
xmlRpc.asyncCall(Listener, null, 'examples.getStateName', stateCode);
|
||||
}
|
||||
|
||||
var Listener = {
|
||||
onResult: function(client, ctxt, result) {
|
||||
document.getElementById('statename').setAttribute('value', result.data);
|
||||
},
|
||||
|
||||
onFault: function(client, ctxt, fault) {
|
||||
dump('Fault! ' + fault + '\n');
|
||||
},
|
||||
|
||||
onError: function(client, ctxt, status, errorMsg) {
|
||||
dump('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
|
||||
}
|
||||
};
|
||||
]]></script>
|
||||
|
||||
<box orient="vertical" flex="1">
|
||||
<spring flex="1"/>
|
||||
<text value="Enter a state code:"/>
|
||||
<textfield id="statecode"/>
|
||||
<text value="Statename:"/>
|
||||
<text id="statename" value=" "/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
|
||||
<box orient="vertical">
|
||||
<spring flex="1"/>
|
||||
<button value="Call Async." onclick="callAsync()"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче