2007-07-30 15:59:41 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla Community QA Extension
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is the Mozilla Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Zach Lipton <zach@zachlipton.com>
|
2007-09-10 15:01:06 -07:00
|
|
|
* Ben Hsieh <bhsieh@mozilla.com>
|
2007-07-30 15:59:41 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2007-07-25 15:51:02 -07:00
|
|
|
|
2007-07-18 13:11:14 -07:00
|
|
|
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
var litmus = {
|
2007-09-10 15:01:06 -07:00
|
|
|
baseURL : qaPref.getPref(qaPref.prefBase+".litmus.url", "char"),
|
|
|
|
userStats : '',
|
|
|
|
|
|
|
|
getTestcase : function(testcase_id, callback) {
|
2007-07-25 15:51:02 -07:00
|
|
|
litmus.getLitmusJson(testcase_id, callback, "testcase_id=");
|
2007-09-10 15:01:06 -07:00
|
|
|
},
|
|
|
|
getSubgroup : function(subgroupID, callback) {
|
2007-07-25 15:51:02 -07:00
|
|
|
litmus.getLitmusJson(subgroupID, callback, "subgroup_id=");
|
|
|
|
},
|
|
|
|
getTestgroup : function(testgroupID, callback) {
|
|
|
|
litmus.getLitmusJson(testgroupID, callback, "testgroup_id=");
|
|
|
|
},
|
|
|
|
getTestrun : function(testrunID, callback) {
|
|
|
|
litmus.getLitmusJson(testrunID, callback, "test_run_id=");
|
|
|
|
},
|
|
|
|
getTestruns : function(callback) {
|
2007-09-10 15:01:06 -07:00
|
|
|
var s = new Sysconfig();
|
2007-07-25 15:51:02 -07:00
|
|
|
var branch = encodeURIComponent(s.branch);
|
|
|
|
litmus.getLitmusJson("&product_name=Firefox&branch_name=" + branch,
|
|
|
|
callback, "test_runs_by_branch_product_name=1");
|
|
|
|
},
|
|
|
|
getLitmusJson : function(ID, callback, prefix) {
|
|
|
|
var url = litmus.baseURL+'json.cgi?' + prefix + ID;
|
2007-07-19 15:55:03 -07:00
|
|
|
var d = loadJSONDoc(url);
|
2007-09-10 15:01:06 -07:00
|
|
|
d.addBoth(function (res) {
|
|
|
|
d.deferred = null;
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
d.addCallback(callback);
|
|
|
|
d.addErrback(function (err) {
|
|
|
|
if (err instanceof CancelledError) {
|
|
|
|
return;
|
2007-07-19 15:55:03 -07:00
|
|
|
}
|
2007-09-10 15:01:06 -07:00
|
|
|
dump(err);
|
2007-07-25 15:51:02 -07:00
|
|
|
});
|
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
lastTestRunSummary : "",
|
|
|
|
lastTestGroupSummary : "",
|
|
|
|
lastSubgroupObject: null, // these have to be objects to avoid the async call later.
|
|
|
|
lastTestcaseObject: null, // they are saved every time a subgroup or testcase is written to screen
|
|
|
|
lastTestcaseIndex: null,
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
preDialogSubgroupObject: null, // saved to be restored in case of Cancel()
|
|
|
|
preDialogTestcaseObject: null,
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
dialogActive: false, // we want to keep controls disabled, even if the selection changes.
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
storeSubgroup : function(subgroup) {
|
|
|
|
litmus.lastSubgroupObject = subgroup;
|
|
|
|
},
|
|
|
|
storeTestcase : function(testcase) {
|
|
|
|
litmus.lastTestcaseObject = testcase;
|
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-25 15:51:02 -07:00
|
|
|
handleDialog : function() {
|
2008-02-01 17:02:53 -08:00
|
|
|
if ($("qa-testrun-label").label != "") {
|
|
|
|
litmus.lastTestRunSummary = $("qa-testrun-label").label;
|
2007-07-27 16:21:32 -07:00
|
|
|
litmus.lastTestGroupSummary = $("qa-testgroup-label").value;
|
|
|
|
lastTestcaseIndex = $("testlist").selectedIndex;
|
|
|
|
}
|
|
|
|
litmus.preDialogueSubgroupObject = litmus.lastSubgroupObject;
|
|
|
|
litmus.preDialogTestcaseObject = litmus.lastTestcaseObject;
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.disableAll();
|
|
|
|
litmus.dialogActive = true;
|
2007-07-27 16:21:32 -07:00
|
|
|
var newWindow = window.openDialog('chrome://qa/content/tabs/selecttests.xul', '_blank', 'chrome,all,dialog=yes',
|
2007-08-24 17:36:35 -07:00
|
|
|
litmus.readStateFromPref, litmus.handleDialogCancel, litmus.handleDialogOK);
|
2007-07-27 16:21:32 -07:00
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
handleDialogCancel : function() {
|
|
|
|
if (litmus.lastTestRunSummary == "") return;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
// this code is v. similar to readStateFromPref, but without an async call.
|
2008-02-01 17:02:53 -08:00
|
|
|
$("qa-testrun-label").label = litmus.lastTestRunSummary;
|
2007-07-27 16:21:32 -07:00
|
|
|
$("qa-testgroup-label").value = litmus.lastTestGroupSummary;
|
|
|
|
litmus.lastSubgroupObject = litmus.preDialogueSubgroupObject;
|
|
|
|
litmus.lastTestcaseObject = litmus.preDialogTestcaseObject;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
if (litmus.lastSubgroupObject != null)
|
|
|
|
litmus.populatePreviewBox(litmus.lastSubgroupObject.testcases);
|
|
|
|
if (litmus.lastTestcaseObject != null) {
|
|
|
|
litmus.populateTestcase(litmus.lastTestcaseObject);
|
|
|
|
}
|
|
|
|
// set the selection without firing an event, which would cause async call
|
|
|
|
$("testlist").setAttribute("suppressonselect", "true");
|
|
|
|
$("testlist").selectedIndex = lastTestcaseIndex;
|
|
|
|
$("testlist").setAttribute("suppressonselect", "false");
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
// rewrite the prefs
|
|
|
|
litmus.writeStateToPref(litmus.lastTestRunSummary, litmus.lastTestGroupSummary,
|
|
|
|
litmus.lastSubgroupObject.subgroup_id, lastTestcaseIndex);
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.dialogActive = false;
|
|
|
|
litmus.undisableAll();
|
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
handleDialogOK : function() {
|
|
|
|
litmus.dialogActive = false;
|
|
|
|
litmus.undisableAll();
|
2007-07-25 15:51:02 -07:00
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
|
|
|
validateLogin : function(uname, passwd, callback) {
|
|
|
|
var qs = queryString({
|
|
|
|
validate_login: 1,
|
|
|
|
username: uname,
|
|
|
|
password: passwd
|
|
|
|
});
|
|
|
|
qaTools.httpPostRequest(litmus.baseURL+'json.cgi', qs, callback);
|
|
|
|
},
|
|
|
|
postResultXML : function(xml, callback, errback) {
|
|
|
|
var qs = queryString({ data: xml});
|
|
|
|
var fake_callback = function(resp) {
|
|
|
|
// only call callback() if we really had a sucuess. XML
|
|
|
|
// processing errors should result in a call to errback()
|
|
|
|
if ((/^ok/i).exec(resp.responseText)) {
|
|
|
|
callback(resp);
|
|
|
|
} else {
|
|
|
|
errback(resp);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
qaTools.httpPostRequest(litmus.baseURL+'process_test.cgi',
|
|
|
|
qs, fake_callback, errback);
|
|
|
|
},
|
|
|
|
|
|
|
|
currentSubgroupID: null,
|
|
|
|
|
2007-07-26 23:07:19 -07:00
|
|
|
writeStateToPref : function(testrunSummary, testgroupSummary, subgroupID, index) {
|
|
|
|
qaPref.setPref(qaPref.prefBase + ".currentTestcase.testrunSummary", testrunSummary, "char");
|
|
|
|
qaPref.setPref(qaPref.prefBase + ".currentTestcase.testgroupSummary", testgroupSummary, "char");
|
2007-07-25 15:51:02 -07:00
|
|
|
qaPref.setPref(qaPref.prefBase + ".currentTestcase.subgroupId", subgroupID, "int");
|
|
|
|
qaPref.setPref(qaPref.prefBase + ".currentTestcase.testcaseIndex", index, "int");
|
|
|
|
},
|
|
|
|
readStateFromPref : function() {
|
2008-02-01 17:02:53 -08:00
|
|
|
$("qa-testrun-label").label = qaPref.getPref(qaPref.prefBase + ".currentTestcase.testrunSummary", "char");
|
2007-07-26 23:07:19 -07:00
|
|
|
$("qa-testgroup-label").value = qaPref.getPref(qaPref.prefBase + ".currentTestcase.testgroupSummary", "char");
|
2007-07-25 15:51:02 -07:00
|
|
|
litmus.currentSubgroupID = qaPref.getPref(qaPref.prefBase + ".currentTestcase.subgroupId", "int");
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.disableAll();
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-26 23:07:19 -07:00
|
|
|
if (litmus.currentSubgroupID != 0)
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.getSubgroup(litmus.currentSubgroupID, function(subgroup) {litmus.statePopulateFields(subgroup); litmus.undisableAll();});
|
2007-07-25 15:51:02 -07:00
|
|
|
},
|
2007-08-15 13:26:27 -07:00
|
|
|
loadStats : function() {
|
2007-09-10 15:01:06 -07:00
|
|
|
// pull new user statistics from litmus
|
|
|
|
var url = litmus.baseURL+'json.cgi?' + 'user_stats=' + qaPref.litmus.getUsername();
|
|
|
|
var req = loadJSONDoc(url);
|
|
|
|
req.addCallback(function(data) {
|
|
|
|
litmus.userStats = data;
|
|
|
|
litmus.displayStats();
|
|
|
|
});
|
2007-08-15 13:26:27 -07:00
|
|
|
},
|
|
|
|
displayStats : function() {
|
2007-09-10 15:01:06 -07:00
|
|
|
var statbox = $('qa-litmus-stats');
|
|
|
|
if (litmus.userStats != '') {
|
|
|
|
var statline = qaMain.bundle.getFormattedString('qa.extension.litmus.stats',
|
|
|
|
[litmus.userStats.week, litmus.userStats.month, litmus.userStats.alltime]);
|
|
|
|
statbox.value = statline;
|
|
|
|
}
|
2007-08-15 13:26:27 -07:00
|
|
|
},
|
2007-07-19 15:55:03 -07:00
|
|
|
checkRadioButtons : function() {
|
|
|
|
var menu = document.getElementById('testlist');
|
2007-07-25 15:51:02 -07:00
|
|
|
if (menu.selectedIndex == -1) return;
|
2007-07-19 15:55:03 -07:00
|
|
|
var disable = menu.selectedItem.firstChild.getAttribute("checked");
|
|
|
|
document.getElementById("qa-testcase-result").disabled = disable;
|
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
prevButton : function() {
|
2007-07-27 16:21:32 -07:00
|
|
|
$("testlist").selectedIndex--;
|
2007-07-19 15:55:03 -07:00
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
nextButton: function() {
|
|
|
|
// if they selected a result, then submit the result
|
|
|
|
if ($('qa-testcase-result').selectedItem) {
|
|
|
|
litmus.submitResult();
|
|
|
|
}
|
2007-07-27 16:21:32 -07:00
|
|
|
$("testlist").selectedIndex++;
|
2007-09-10 15:01:06 -07:00
|
|
|
},
|
2007-07-19 15:55:03 -07:00
|
|
|
handleSelect : function() {
|
2007-07-27 16:21:32 -07:00
|
|
|
if ($("testlist").selectedIndex == -1)
|
|
|
|
return;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.disableAll();
|
2007-08-01 10:49:41 -07:00
|
|
|
litmus.getTestcase($("testlist").selectedItem.value, function(testcase) {
|
2007-09-10 15:01:06 -07:00
|
|
|
litmus.populateTestcase(testcase);
|
2008-02-01 17:02:53 -08:00
|
|
|
$('qa-testcase-progress').label =
|
2007-09-10 15:01:06 -07:00
|
|
|
qaMain.bundle.getFormattedString('qa.extension.litmus.progress',
|
|
|
|
[$("testlist").selectedIndex+1, $("testlist").getRowCount()]);
|
2007-08-14 09:54:14 -07:00
|
|
|
litmus.undisableAll();
|
2007-08-01 10:49:41 -07:00
|
|
|
});
|
2007-07-19 15:55:03 -07:00
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
populatePreviewBox : function(testcases) {
|
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
var menu = document.getElementById('testlist');
|
|
|
|
if (!menu) return;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
while (menu.firstChild) { // clear menu
|
|
|
|
menu.removeChild(menu.firstChild);
|
|
|
|
};
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-26 23:07:19 -07:00
|
|
|
for (var i = 0; i < testcases.length; i++) {
|
2008-02-01 17:02:53 -08:00
|
|
|
var row = document.createElement("richlistitem");
|
2007-07-26 23:07:19 -07:00
|
|
|
row.value = testcases[i].testcase_id;
|
2008-02-01 17:02:53 -08:00
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
var checkbox = document.createElement("listcell");
|
|
|
|
checkbox.setAttribute("label", "");
|
|
|
|
checkbox.setAttribute("type", "checkbox");
|
|
|
|
checkbox.setAttribute("disabled", "true");
|
2008-02-01 17:02:53 -08:00
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
var name = document.createElement("listcell");
|
2007-08-01 10:49:41 -07:00
|
|
|
name.setAttribute("label", (i+1) + " -- " + testcases[i].summary);
|
2007-07-19 15:55:03 -07:00
|
|
|
name.setAttribute("crop", "end");
|
2008-02-01 17:02:53 -08:00
|
|
|
name.setAttribute("flex", "1");
|
|
|
|
|
2007-07-19 15:55:03 -07:00
|
|
|
row.appendChild(checkbox);
|
|
|
|
row.appendChild(name);
|
2007-07-26 23:07:19 -07:00
|
|
|
menu.appendChild(row);
|
2008-02-01 17:02:53 -08:00
|
|
|
}
|
|
|
|
|
2007-07-25 15:51:02 -07:00
|
|
|
},
|
2007-07-19 15:55:03 -07:00
|
|
|
populateTestcase : function(testcase) {
|
2007-07-27 16:21:32 -07:00
|
|
|
litmus.lastTestcaseObject = testcase;
|
2007-07-25 15:51:02 -07:00
|
|
|
if (testcase == undefined) {
|
|
|
|
return;
|
|
|
|
}
|
2008-02-01 17:02:53 -08:00
|
|
|
document.getElementById('qa-testcase-id').value = "(" +
|
|
|
|
qaMain.bundle.getString("qa.extension.testcase.head")+testcase.testcase_id + ")";
|
|
|
|
document.getElementById('qa-testcase-summary').value = testcase.summary;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-25 15:51:02 -07:00
|
|
|
qaTools.writeSafeHTML('qa-testcase-steps', testcase.steps_formatted);
|
|
|
|
qaTools.writeSafeHTML('qa-testcase-expected', testcase.expected_results_formatted);
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-08 14:54:31 -07:00
|
|
|
qaTools.assignLinkHandlers($('qa-testcase-steps'));
|
|
|
|
qaTools.assignLinkHandlers($('qa-testcase-expected'));
|
2007-09-10 15:01:06 -07:00
|
|
|
|
|
|
|
if (testcase.regression_bug_id) {
|
|
|
|
bugzilla.loadBug(testcase.regression_bug_id);
|
|
|
|
} else {
|
|
|
|
var bugarray = bugzilla.findBugzillaLinks($("qa-testcase-expected"));
|
|
|
|
if (bugarray.length) {
|
|
|
|
bugzilla.loadBug(bugarray[0]);
|
|
|
|
for (var i = 1; i < bugarray.length; i++) {
|
|
|
|
bugzilla.loadBug(bugarray[i], true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-25 15:51:02 -07:00
|
|
|
litmus.checkRadioButtons();
|
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
populateFields : function(subgroup) {
|
2007-07-27 16:21:32 -07:00
|
|
|
litmus.lastSubgroupObject = subgroup;
|
2007-09-10 15:01:06 -07:00
|
|
|
litmus.populatePreviewBox(subgroup.testcases);
|
|
|
|
$('qa-subgroup-label').value = subgroup.name;
|
2007-07-27 16:21:32 -07:00
|
|
|
$("testlist").selectedIndex = 0;
|
2007-08-14 09:54:14 -07:00
|
|
|
},
|
2007-07-25 15:51:02 -07:00
|
|
|
statePopulateFields : function(subgroup) { //TODO: there's gotta be a better way to do this...
|
2007-07-27 16:21:32 -07:00
|
|
|
litmus.lastSubgroupObject = subgroup;
|
2007-07-26 23:07:19 -07:00
|
|
|
litmus.populatePreviewBox(subgroup.testcases);
|
2007-08-01 10:49:41 -07:00
|
|
|
$('qa-subgroup-label').value = subgroup.name;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-27 16:21:32 -07:00
|
|
|
$("testlist").selectedIndex = qaPref.getPref(qaPref.prefBase + ".currentTestcase.testcaseIndex", "int");
|
2007-08-14 09:54:14 -07:00
|
|
|
},
|
|
|
|
disableAll : function() { //
|
|
|
|
$("testlist").disabled = true;
|
|
|
|
$("qa-testcase-result").disabled = true;
|
|
|
|
$("qa-mainwindow-previousButton").disabled = true;
|
|
|
|
$("qa-mainwindow-nextButton").disabled = true;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
},
|
|
|
|
undisableAll : function() {
|
|
|
|
if(litmus.dialogActive) return; // ignore all requests while there is a dialog open
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-08-14 09:54:14 -07:00
|
|
|
$("testlist").disabled = false;
|
|
|
|
$("qa-testcase-result").disabled = false;
|
|
|
|
$("qa-mainwindow-previousButton").disabled = false;
|
|
|
|
$("qa-mainwindow-nextButton").disabled = false;
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-25 15:51:02 -07:00
|
|
|
},
|
2007-09-10 15:01:06 -07:00
|
|
|
submitResult : function() {
|
|
|
|
var rs;
|
|
|
|
var item = $('qa-testcase-result').selectedItem;
|
|
|
|
if (item.id == "qa-testcase-pass") {
|
|
|
|
rs = 'Pass';
|
|
|
|
} else if (item.id == "qa-testcase-fail") {
|
|
|
|
rs = 'Fail';
|
|
|
|
} else if (item.id == "qa-testcase-unclearBroken") {
|
|
|
|
rs = 'Test unclear/broken';
|
|
|
|
} else {
|
|
|
|
// no result selected, so don't submit anything for thes test:
|
|
|
|
return false;
|
|
|
|
}
|
2007-07-19 15:55:03 -07:00
|
|
|
|
2007-07-26 23:07:19 -07:00
|
|
|
var menu = document.getElementById('testlist');
|
2007-09-10 15:01:06 -07:00
|
|
|
|
|
|
|
var l = new LitmusResults({username: qaPref.litmus.getUsername(),
|
|
|
|
password: qaPref.litmus.getPassword(),
|
|
|
|
server: litmus.baseURL});
|
|
|
|
l.sysconfig(new Sysconfig());
|
|
|
|
|
|
|
|
l.addResult(new Result({
|
|
|
|
testid: menu.selectedItem.value,
|
|
|
|
resultstatus: rs,
|
|
|
|
exitstatus: 'Exited Normally',
|
|
|
|
duration: 0,
|
|
|
|
comment: $('qa-testcase-comment').value,
|
|
|
|
isAutomatedResult: 0
|
|
|
|
}));
|
|
|
|
|
|
|
|
var callback = function(resp) {
|
|
|
|
// increment the stat counters:
|
|
|
|
for (var i in litmus.userStats) {
|
|
|
|
litmus.userStats[i]++;
|
|
|
|
}
|
|
|
|
litmus.displayStats();
|
|
|
|
};
|
|
|
|
|
|
|
|
var errback = function(resp) {
|
|
|
|
dump(resp.responseText);
|
|
|
|
};
|
|
|
|
|
|
|
|
litmus.postResultXML(l.toXML(), callback, errback);
|
2007-07-19 15:55:03 -07:00
|
|
|
var item = menu.selectedItem;
|
|
|
|
item.firstChild.setAttribute("checked", "true");
|
|
|
|
return false; // ?? Got rid of strict warning...
|
2007-09-10 15:01:06 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// any missing fields will be autodetected
|
|
|
|
function Sysconfig(aProduct, aPlatform, aOpsys, aBranch, aBuildid, aLocale) {
|
|
|
|
this._load('product', aProduct);
|
|
|
|
this._load('platform', aPlatform);
|
|
|
|
this._load('opsys', aOpsys);
|
|
|
|
this._load('branch', aBranch);
|
|
|
|
this._load('buildid', aBuildid);
|
|
|
|
this._load('locale', aLocale);
|
|
|
|
this.populate();
|
|
|
|
}
|
|
|
|
|
|
|
|
Sysconfig.prototype = {
|
|
|
|
product: null,
|
|
|
|
platform: null,
|
|
|
|
opsys: null,
|
|
|
|
branch: null,
|
|
|
|
buildid: null,
|
|
|
|
locale: null,
|
|
|
|
|
|
|
|
// set a field according to the following priorities:
|
|
|
|
// 1. 'setting'
|
|
|
|
// 2. qa.extension.sysconfig.fieldname
|
|
|
|
// 3. null
|
|
|
|
_load: function(fieldname, setting) {
|
|
|
|
if (this[fieldname]) { return }
|
|
|
|
if (setting) {
|
|
|
|
this[fieldname] = setting;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var pref = qaPref.getPref(qaPref.prefBase+'.sysconfig.'+fieldname, 'char');
|
|
|
|
if (pref) {
|
|
|
|
this[fieldname] = pref;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// if something cannot be autodetected, an exception is thrown
|
|
|
|
// with the name of the missing field
|
|
|
|
populate: function() {
|
|
|
|
var appinfo = Components.classes["@mozilla.org/xre/app-info;1"]
|
2007-07-18 13:11:14 -07:00
|
|
|
.getService(Components.interfaces.nsIXULAppInfo);
|
2007-09-10 15:01:06 -07:00
|
|
|
|
|
|
|
// build id:
|
|
|
|
this.buildid = appinfo.appBuildID;
|
|
|
|
if (! this.buildid) { throw "buildid" }
|
|
|
|
|
2007-07-18 13:11:14 -07:00
|
|
|
// product:
|
|
|
|
if (! this.product) {
|
2007-09-10 15:01:06 -07:00
|
|
|
if (appinfo.ID == FIREFOX_ID) {
|
|
|
|
this.product = 'Firefox';
|
|
|
|
}
|
|
|
|
if (! this.product) { throw "product" }
|
2007-07-18 13:11:14 -07:00
|
|
|
}
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-18 13:11:14 -07:00
|
|
|
// branch:
|
2007-09-10 15:01:06 -07:00
|
|
|
// people switch branches, so we detect this even though it might
|
2007-07-18 13:11:14 -07:00
|
|
|
// already be set in a pref
|
2007-09-10 15:01:06 -07:00
|
|
|
if ((/^3\.0/).exec(appinfo.version)) {
|
|
|
|
this.branch = '3.0 Branch';
|
|
|
|
} else if ((/^2\.0/).exec(appinfo.version)) {
|
|
|
|
this.branch = '2.0 Branch';
|
|
|
|
} else if ((/^1\.5\./).exec(appinfo.version)) {
|
|
|
|
this.branch = '1.5 Branch';
|
|
|
|
}
|
|
|
|
if (! this.branch) { throw "branch" }
|
|
|
|
|
2007-07-18 13:11:14 -07:00
|
|
|
// platform:
|
|
|
|
if (! this.platform) {
|
2007-09-10 15:01:06 -07:00
|
|
|
if ((/^MacPPC/).exec(navigator.platform)) {
|
|
|
|
this.platform = 'Mac (PPC)';
|
|
|
|
} else if ((/^MacIntel/).exec(navigator.platform)) {
|
|
|
|
this.platform = 'Mac (Intel)';
|
|
|
|
} else if ((/^Win/).exec(navigator.platform)) {
|
|
|
|
this.platform = 'Windows';
|
|
|
|
} else if ((/^Linux/).exec(navigator.platform)) {
|
|
|
|
this.platform = 'Linux';
|
|
|
|
} else if ((/^Solaris/).exec(navigator.platform)) {
|
|
|
|
this.platform = 'Solaris';
|
|
|
|
}
|
|
|
|
if (! this.platform) { throw "platform" }
|
2007-07-18 13:11:14 -07:00
|
|
|
}
|
|
|
|
// opsys
|
|
|
|
if (this.platform == 'Windows') {
|
2007-09-10 15:01:06 -07:00
|
|
|
switch (navigator.oscpu) {
|
|
|
|
case 'Windows NT 5.1':
|
|
|
|
this.opsys = 'Windows XP';
|
|
|
|
break;
|
|
|
|
case 'Windows NT 5.2':
|
|
|
|
this.opsys = 'Windows XP';
|
|
|
|
break;
|
|
|
|
case 'Windows NT 6.0':
|
|
|
|
this.opsys = 'Windows Vista';
|
|
|
|
break;
|
|
|
|
case 'Windows NT 5.0':
|
|
|
|
this.opsys = 'Windows 2000';
|
|
|
|
break;
|
|
|
|
case 'Win 9x 4.90':
|
|
|
|
this.opsys = 'Windows ME';
|
|
|
|
break;
|
|
|
|
case 'Win98':
|
|
|
|
this.opsys = 'Windows 98';
|
|
|
|
break;
|
|
|
|
}
|
2007-07-18 13:11:14 -07:00
|
|
|
} else if (this.platform == 'Linux') {
|
2007-09-10 15:01:06 -07:00
|
|
|
this.opsys = 'Linux';
|
2007-08-15 13:26:27 -07:00
|
|
|
} else if (this.platform == 'Mac (PPC)' || this.platform == 'Mac (Intel)') {
|
2007-09-10 15:01:06 -07:00
|
|
|
// no way to detect the OS on mac, so just assume
|
|
|
|
// it's 10.4. The user can provide the real OS in setup
|
|
|
|
this.opsys = 'Mac OS 10.4';
|
2007-07-18 13:11:14 -07:00
|
|
|
}
|
|
|
|
if (! this.opsys) {throw "opsys" }
|
2007-09-10 15:01:06 -07:00
|
|
|
|
2007-07-18 13:11:14 -07:00
|
|
|
// locale
|
2007-09-10 15:01:06 -07:00
|
|
|
this.locale = navigator.language;
|
|
|
|
if (!this.locale) { throw "locale" }
|
|
|
|
}
|
2007-07-18 13:11:14 -07:00
|
|
|
};
|