Send a http post request for validating login (bug 390815)
authorzach@zachlipton.com
Fri, 03 Aug 2007 10:40:33 -0700
changeset 4242 ae44dc46ca513c034583f3655e14eb656fecb475
parent 4241 ded91f1d1f0bc8fb383c91aef655a057d2cc5a82
child 4243 1518341b8a0415c7e98f4344073e9e49da005e99
push idunknown
push userunknown
push dateunknown
bugs390815
milestone1.9a8pre
Send a http post request for validating login (bug 390815)
testing/extensions/community/chrome/content/common.js
testing/extensions/community/chrome/content/litmus.js
--- a/testing/extensions/community/chrome/content/common.js
+++ b/testing/extensions/community/chrome/content/common.js
@@ -102,16 +102,27 @@ var qaTools = {
 		httpRequest.open("GET", url, true);
 		try {
 			httpRequest.onload = infoReceived;
 			httpRequest.send(null);
 		} catch(e) {
 			alert(e);
 		}
 	},
+	httpPostRequest : function (url, data, callback, errback) {
+		// do a xmlhttprequest sending data with the post method
+		var req = getXMLHttpRequest();
+		req.open("POST", url, true);
+	    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+	    req.setRequestHeader("Content-length", data.length);
+	    req.setRequestHeader("Connection", "close");
+	    req = sendXMLHttpRequest(req, data);
+	    req.addErrback(errback);
+	    req.addCallback(callback);
+	},
 	showHideLoadingMessage : function(box, bool) {
 		if (bool == true) { // show
 			var loading = document.createElementNS("http://www.w3.org/1999/xhtml", "p");
 			loading.textContent = qaMain.bundle.getString("qa.extension.loading");
 			loading.setAttributeNS("http://www.w3.org/1999/xhtml", "class", "loading_message");
 			box.appendChild(loading);
 		} else { // hide
 			var elements = box.childNodes;
--- a/testing/extensions/community/chrome/content/litmus.js
+++ b/testing/extensions/community/chrome/content/litmus.js
@@ -125,23 +125,22 @@
         $("testlist").setAttribute("suppressonselect", "false");
         
         // rewrite the prefs
         litmus.writeStateToPref(litmus.lastTestRunSummary, litmus.lastTestGroupSummary,
                                 litmus.lastSubgroupObject.subgroup_id, lastTestcaseIndex);
     },
     
 	validateLogin : function(uname, passwd, callback) {
-	    var req = doSimpleXMLHttpRequest(litmus.baseURL+'json.cgi', {
-	       validate_login: 1,
-	       username: uname,
-	       password: passwd
+		var qs = queryString({ 
+		    validate_login: 1,
+	        username: uname,
+	        password: passwd
 	    });
-	    req.addErrback(callback);
-	    req.addCallback(callback);
+	    qaTools.httpPostRequest(litmus.baseURL+'json.cgi', qs, callback);
 	},
 	createAccount : function() {
 	    alert("XXX: not implemented");
 	},
 	postResultXML : function(xml, callback, errback) {
 		var req = doSimpleXMLHttpRequest(litmus.baseURL+'process_test.cgi', 
 										    { data: xml });
 		req.addErrback(errback);