1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 2<html> 3 <head> 4 <title>Test</title> 5 <script type='text/javascript' language="javascript" src='jquery.js'></script> 6 <script type='text/javascript' language="javascript"> 7 <!-- 8 9 function mbox() { 10 alert('Javascript OK'); 11 } 12 13 14 var totalCount = 10; 15 var pendingCount = 0; 16 var errorCount = 0; 17 var pushCount = 0; 18 var allErrorCount = 0; 19 var autoTest = false; 20 var testType = "cgi"; 21 22 function NextTestType() { 23 if (testType == "cgi") testType = "lp"; 24 else if (testType == "lp") testType = "lua"; 25 else testType = "cgi"; 26 } 27 28 function runTest(method, isAsync) { 29 30 ++pushCount; 31 document.getElementById('start').innerHTML = 'Test: ' + pushCount; 32 document.getElementById('resTotal').innerHTML = 'running'; 33 34 for (var i = 1; i <= totalCount; ++i) { 35 document.getElementById('res'+i).innerHTML = "ready"; 36 } 37 38 errorCount = 0; 39 pendingCount = totalCount; 40 41 for (var i = 1; i <= totalCount; ++i) { 42 43 fetch(i, method, isAsync); 44 } 45 } 46 47 function runAutoTest() { 48 if (autoTest) { 49 runTest("POST", true) 50 setTimeout("runAutoTest()", 250) 51 } 52 } 53 54 55 function fetch(id, method, isAsync) { 56 57 document.getElementById('res'+id).innerHTML = "pending"; 58 59 $.ajax({ 60 async: isAsync, 61 url: 'echo.' + testType + '?id=' + id, 62 type: method, 63 timeout: 2000, 64 data: { 'id' : id , 65 'longText1' : "adfsdfasdklkjlgasfdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 66 'longText2' : "bsdfsdfasdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 67 'longText3' : "sdfsadagsdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 68 'longText4' : "q34sdfas3fhbkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 69 'longText5' : "askj2kjcvxychklgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 70 'longText6' : "asdfjklhlkjhv8öajsdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui", 71 'async' : isAsync 72 }, 73 dataType: 'json', 74 succes: function(data) { 75 }, 76 error: function() { 77 ++errorCount; 78 }, 79 complete: function(jqXHR, textStatus) { 80 81 --pendingCount; 82 83 document.getElementById('res'+id).innerHTML = textStatus; 84 console.log('id: ' + id + ' (' + pendingCount + '/' + totalCount + '), status: ' + textStatus); 85 86 if (pendingCount == 0) { 87 document.getElementById('resTotal').innerHTML = 'done'; 88 console.log('complete, error count: ' + errorCount); 89 allErrorCount = allErrorCount + errorCount; 90 document.getElementById('resSAll').innerHTML = 'total errors: ' + allErrorCount + "/" + (pushCount*totalCount); 91 } 92 } 93 }); 94 95 } 96 97 98 //--> 99 </script> 100 101 </head> 102 <body> 103 <p> 104 <div id="start">Test not started.</div> 105 </p> 106 <p> 107 <table> 108 <tr> 109 <td> 110 <input id="testButton1" type="button" onclick="javascript:runTest('GET', false)" value="sync GET"></input> 111 </td> 112 <td> 113 <input id="testButton2" type="button" onclick="javascript:runTest('POST', false)" value="sync POST"></input> 114 </td> 115 </tr> 116 <tr> 117 <td> 118 <input id="testButton3" type="button" onclick="javascript:runTest('GET', true)" value="async GET"></input> 119 </td> 120 <td> 121 <input id="testButton4" type="button" onclick="javascript:runTest('POST', true)" value="async POST"></input> 122 </td> 123 </tr> 124 <tr> 125 <td> 126 <input id="testButton5" type="button" onclick="autoTest=!autoTest; javascript:runAutoTest()" value="automatic test"></input> 127 </td> 128 <td> 129 <input id="testButton6" type="button" onclick="NextTestType(); this.value=testType" value='cgi'></input> 130 </td> 131 </tr> 132 133 <tr> 134 <td> 135 <input id="testButtonReset" type="button" onclick="autoTest=false; javascript:location.reload(true)" value="reset"></input> 136 </td> 137 <td> 138 <input id="testButtonBack" type="button" onclick="history.back()" value="back"></input> 139 </td> 140 </tr> 141 <tr> 142 <td> 143 <input id="testButtonBox" type="button" onclick="javascript:mbox()" value="MsgBox"></input> 144 </td> 145 <td> 146 </td> 147 </tr> 148 </table> 149 </p> 150 <p> 151 <table border="1"> 152 <tr><th>Test</th><th>Result</th></tr> 153 <tr><td>1</td><td><div id="res1">not started</div></td></tr> 154 <tr><td>2</td><td><div id="res2">not started</div></td></tr> 155 <tr><td>3</td><td><div id="res3">not started</div></td></tr> 156 <tr><td>4</td><td><div id="res4">not started</div></td></tr> 157 <tr><td>5</td><td><div id="res5">not started</div></td></tr> 158 <tr><td>6</td><td><div id="res6">not started</div></td></tr> 159 <tr><td>7</td><td><div id="res7">not started</div></td></tr> 160 <tr><td>8</td><td><div id="res8">not started</div></td></tr> 161 <tr><td>9</td><td><div id="res9">not started</div></td></tr> 162 <tr><td>10</td><td><div id="res10">not started</div></td></tr> 163 </table> 164 <div id="resTotal">Push [Test] to start.</div> 165 <div id="resSAll"></div> 166 </p> 167 </body> 168</html> 169