зеркало из https://github.com/mozilla/pjs.git
Fix result submission, mac platform detection (intel vs ppc), and add statistics display to litmus tab
This commit is contained in:
Родитель
687367db24
Коммит
f4da02b624
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
var litmus = {
|
var litmus = {
|
||||||
baseURL : qaPref.getPref(qaPref.prefBase+".litmus.url", "char"),
|
baseURL : qaPref.getPref(qaPref.prefBase+".litmus.url", "char"),
|
||||||
|
userStats : '',
|
||||||
|
|
||||||
getTestcase : function(testcase_id, callback) {
|
getTestcase : function(testcase_id, callback) {
|
||||||
litmus.getLitmusJson(testcase_id, callback, "testcase_id=");
|
litmus.getLitmusJson(testcase_id, callback, "testcase_id=");
|
||||||
|
@ -152,18 +153,18 @@
|
||||||
alert("XXX: not implemented");
|
alert("XXX: not implemented");
|
||||||
},
|
},
|
||||||
postResultXML : function(xml, callback, errback) {
|
postResultXML : function(xml, callback, errback) {
|
||||||
var req = doSimpleXMLHttpRequest(litmus.baseURL+'process_test.cgi',
|
var qs = queryString({ data: xml});
|
||||||
{ data: xml });
|
var fake_callback = function(resp) {
|
||||||
req.addErrback(errback);
|
|
||||||
req.addCallback(function(resp) {
|
|
||||||
// only call callback() if we really had a sucuess. XML
|
// only call callback() if we really had a sucuess. XML
|
||||||
// processing errors should result in a call to errback()
|
// processing errors should result in a call to errback()
|
||||||
if ((/ok/i).exec(resp.responseText)) {
|
if ((/^ok/i).exec(resp.responseText)) {
|
||||||
callback(resp);
|
callback(resp);
|
||||||
} else {
|
} else {
|
||||||
errback(resp);
|
errback(resp);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
qaTools.httpPostRequest(litmus.baseURL+'process_test.cgi',
|
||||||
|
qs, fake_callback, errback);
|
||||||
},
|
},
|
||||||
|
|
||||||
currentSubgroupID: null,
|
currentSubgroupID: null,
|
||||||
|
@ -183,6 +184,23 @@
|
||||||
if (litmus.currentSubgroupID != 0)
|
if (litmus.currentSubgroupID != 0)
|
||||||
litmus.getSubgroup(litmus.currentSubgroupID, function(subgroup) {litmus.statePopulateFields(subgroup); litmus.undisableAll();});
|
litmus.getSubgroup(litmus.currentSubgroupID, function(subgroup) {litmus.statePopulateFields(subgroup); litmus.undisableAll();});
|
||||||
},
|
},
|
||||||
|
loadStats : function() {
|
||||||
|
// 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();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
displayStats : function() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
checkRadioButtons : function() {
|
checkRadioButtons : function() {
|
||||||
var menu = document.getElementById('testlist');
|
var menu = document.getElementById('testlist');
|
||||||
if (menu.selectedIndex == -1) return;
|
if (menu.selectedIndex == -1) return;
|
||||||
|
@ -315,7 +333,11 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var callback = function(resp) {
|
var callback = function(resp) {
|
||||||
|
// increment the stat counters:
|
||||||
|
for (var i in litmus.userStats) {
|
||||||
|
litmus.userStats[i]++;
|
||||||
|
}
|
||||||
|
litmus.displayStats();
|
||||||
};
|
};
|
||||||
|
|
||||||
var errback = function(resp) {
|
var errback = function(resp) {
|
||||||
|
@ -397,8 +419,10 @@ Sysconfig.prototype = {
|
||||||
|
|
||||||
// platform:
|
// platform:
|
||||||
if (! this.platform) {
|
if (! this.platform) {
|
||||||
if ((/^Mac/).exec(navigator.platform)) {
|
if ((/^MacPPC/).exec(navigator.platform)) {
|
||||||
this.platform = 'Mac';
|
this.platform = 'Mac (PPC)';
|
||||||
|
} else if ((/^MacIntel/).exec(navigator.platform)) {
|
||||||
|
this.platform = 'Mac (Intel)';
|
||||||
} else if ((/^Win/).exec(navigator.platform)) {
|
} else if ((/^Win/).exec(navigator.platform)) {
|
||||||
this.platform = 'Windows';
|
this.platform = 'Windows';
|
||||||
} else if ((/^Linux/).exec(navigator.platform)) {
|
} else if ((/^Linux/).exec(navigator.platform)) {
|
||||||
|
@ -432,7 +456,7 @@ Sysconfig.prototype = {
|
||||||
}
|
}
|
||||||
} else if (this.platform == 'Linux') {
|
} else if (this.platform == 'Linux') {
|
||||||
this.opsys = 'Linux';
|
this.opsys = 'Linux';
|
||||||
} else if (this.platform == 'Mac') {
|
} else if (this.platform == 'Mac (PPC)' || this.platform == 'Mac (Intel)') {
|
||||||
// no way to detect the OS on mac, so just assume
|
// no way to detect the OS on mac, so just assume
|
||||||
// it's 10.4. The user can provide the real OS in setup
|
// it's 10.4. The user can provide the real OS in setup
|
||||||
this.opsys = 'Mac OS 10.4';
|
this.opsys = 'Mac OS 10.4';
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
]>
|
]>
|
||||||
|
|
||||||
<overlay id="qa-litmus-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
<overlay id="qa-litmus-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
<tabpanel id="qa-tab-litmus" onload="litmus.readStateFromPref()">
|
<tabpanel id="qa-tab-litmus" onload="litmus.readStateFromPref();">
|
||||||
|
|
||||||
<vbox align="start" pack="start">
|
<vbox align="start" pack="start">
|
||||||
<hbox align="start" pack="start">
|
<hbox align="start" pack="start">
|
||||||
|
@ -108,6 +108,10 @@
|
||||||
<button id="qa-mainwindow-previousButton" label="Previous" oncommand="litmus.prevButton()"/>
|
<button id="qa-mainwindow-previousButton" label="Previous" oncommand="litmus.prevButton()"/>
|
||||||
<button id="qa-mainwindow-nextButton" label="Next (Submit)" oncommand="litmus.nextButton()"/>
|
<button id="qa-mainwindow-nextButton" label="Next (Submit)" oncommand="litmus.nextButton()"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
<label id="qa-litmus-stats" value="" />
|
||||||
|
<script type="application/x-javascript">
|
||||||
|
this.addEventListener('load', litmus.loadStats, false);
|
||||||
|
</script>
|
||||||
</vbox>
|
</vbox>
|
||||||
</tabpanel>
|
</tabpanel>
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,5 @@ qa.extension.prefs.savedMsg = Your settings have been saved
|
||||||
qa.extension.sysconfig.loadingMsg = Loading menu options...
|
qa.extension.sysconfig.loadingMsg = Loading menu options...
|
||||||
qa.extension.loading = Loading...
|
qa.extension.loading = Loading...
|
||||||
|
|
||||||
qa.extension.litmus.progress = Test %1$S of %2$S
|
qa.extension.litmus.progress = Test %1$S of %2$S
|
||||||
|
qa.extension.litmus.stats = My tests run - week: %1$S, month: %2$S, all time: %3$S
|
Загрузка…
Ссылка в новой задаче