mirror of https://github.com/tc39/test262.git
Propagated changes from website\resources\scripts\global over to test\harness\*. In the future, the
website needs to be generated based on the contents of test\harness\*, not the other way around.
This commit is contained in:
parent
c26f761a9f
commit
62cde7819a
|
@ -1,32 +1,164 @@
|
|||
//constants
|
||||
var XML_TARGETTESTSUITENAME = 'ECMAScript Test262 Site';
|
||||
var XML_TARGETTESTSUITEVERSION = '';
|
||||
var XML_TARGETTESTSUITEDATE = '';
|
||||
|
||||
(function() {
|
||||
$(function () {
|
||||
pageHelper.init();
|
||||
$('.content-home').show();
|
||||
// Adding attribute to the tabs (e.g. Home, Run etc.) and attaching the click event on buttons (e.g. Reset, Start etc.)
|
||||
$('.nav-link').each(function (index) {
|
||||
//Adding "targetDiv" attribute to the header tab and on that basis the div related to header tabs are displayed
|
||||
if (index === 0) {
|
||||
$(this).attr('targetDiv', '.content-home');
|
||||
} else if (index === 1) {
|
||||
$(this).attr('targetDiv', '.content-tests');
|
||||
} else if (index === 2) {
|
||||
$(this).attr('targetDiv', '.content-results');
|
||||
$(this).attr('testRunning', 'false');
|
||||
} else if (index === 3) {
|
||||
$(this).attr('targetDiv', '.content-dev');
|
||||
}
|
||||
else {
|
||||
$(this).attr('targetDiv', '.content-browsers');
|
||||
}
|
||||
|
||||
window.PageHelper = {};
|
||||
//Attaching the click event to the header tab that shows the respective div of header
|
||||
$(this).click(function () {
|
||||
var target = $(this).attr('targetDiv');
|
||||
//If clicked tab is Result, it generates the results.
|
||||
if ($(target).hasClass('content-results')) {
|
||||
if ($(this).attr('testRunning') === 'true') { return; }
|
||||
pageHelper.generateReportTable();
|
||||
}
|
||||
$('#contentContainer > div:visible').hide();
|
||||
$('.navBar .selected').toggleClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$(target).show();
|
||||
//If clicked tab is Browsers Report, it shows the reports
|
||||
if (target === '.content-browsers') {
|
||||
$("body").addClass("busy");
|
||||
setTimeout(function () {
|
||||
buildTable();
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
window.TestConstants = {
|
||||
PAUSED: 'PAUSED',
|
||||
RUNNING: 'RUNNING',
|
||||
STOPPED: 'STOPPED',
|
||||
RESET: 'RESET',
|
||||
RESUME: 'RESUME'
|
||||
//Attach the click event to the start button. It starts, stops and pauses the tests
|
||||
$('.button-start').click(function () {
|
||||
$('#testsToRun').text(ES5Harness.getTotalTestsToRun());
|
||||
$('#totalCounter').text(0);
|
||||
$('#Pass').text(0);
|
||||
$('#Fail').text(0);
|
||||
$('#totalFailedCounter').text(0);
|
||||
$('#failedToLoadCounter1').text(0);
|
||||
$('#failedToLoadCounter').text(0);
|
||||
//It stores the state of the test case in the data of button, whether running, paused or stopped. That is used later to get the present state
|
||||
var testStatus = $(this).data('testStatus');
|
||||
|
||||
switch (testStatus) {
|
||||
case undefined:
|
||||
case "stopped":
|
||||
ES5Harness.stop("stopped");
|
||||
pageHelper.logger.find('tr').remove();
|
||||
if (!ES5Harness.setChapter(pageHelper.update)) {
|
||||
return false;
|
||||
}
|
||||
$(this).data('testStatus', "running");
|
||||
ES5Harness.startTesting(pageHelper.update, "reset");
|
||||
$(this).attr('src', 'resources/images/pause.png');
|
||||
pageHelper.configureReportLink(true);
|
||||
break;
|
||||
case "running":
|
||||
$(this).data('testStatus', "paused");
|
||||
ES5Harness.stop("paused");
|
||||
$(this).attr('src', 'resources/images/resume.png');
|
||||
pageHelper.configureReportLink(false);
|
||||
break;
|
||||
case "paused":
|
||||
$(this).data('testStatus', "running");
|
||||
$(this).attr('src', 'resources/images/pause.png');
|
||||
ES5Harness.startTesting(pageHelper.update, "resume");
|
||||
pageHelper.configureReportLink(true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//Attach the click event to the reset button. It reset all the test to zero
|
||||
$('.button-reset').click(
|
||||
/*function () {
|
||||
pageHelper.configureReportLink(false);
|
||||
$('.button-start').data('testStatus', "stopped").attr('src', 'resources/images/start.png');
|
||||
pageHelper.logger.find('tr').remove();
|
||||
ES5Harness.stop("reset");
|
||||
ES5Harness.resetSections();
|
||||
$('#failedToLoadCounter1').text(0);
|
||||
$('#failedToLoadCounter').text(0);
|
||||
$('#totalFailedCounter').text(0);
|
||||
pageHelper.failedToLoad = 0;
|
||||
resetResults();
|
||||
$('#nextActivity').text("");
|
||||
} */
|
||||
function () {
|
||||
location.replace(location.protocol + '//' + location.host + '/default.html?run');
|
||||
}
|
||||
);
|
||||
|
||||
//Attaching the click event to the "Download results as XML" link
|
||||
$('#ancGenXMLReport').click(function (e) {
|
||||
pageHelper.generateReportXml();
|
||||
return false;
|
||||
});
|
||||
|
||||
var logger = null;
|
||||
var loggerParent = null;
|
||||
var progressBar = null;
|
||||
var failedToLoad = 0;
|
||||
//load xml testcase path list when page loads
|
||||
ES5Harness && ES5Harness.loadTestList();
|
||||
pageHelper.selectTab();
|
||||
});
|
||||
|
||||
var pageHelper = {
|
||||
|
||||
function getDomain() {
|
||||
return window.location.protocol + '//' + document.domain + '/';
|
||||
}
|
||||
//constants
|
||||
XML_TARGETTESTSUITENAME: 'ECMAScript Test262 Site',
|
||||
XML_TARGETTESTSUITEVERSION: '',
|
||||
XML_TARGETTESTSUITEDATE: '',
|
||||
RED_LIMIT: 50,
|
||||
YELLOW_LIMIT: 75,
|
||||
GREEN_LIMIT: 99.9,
|
||||
|
||||
function configureReportLink(executing) {
|
||||
logger: undefined,
|
||||
loggerParent: undefined,
|
||||
progressBar: undefined,
|
||||
failedToLoad: 0,
|
||||
|
||||
init: function () {
|
||||
this.logger = $('#tableLogger');
|
||||
this.loggerParent = this.logger.parent();
|
||||
this.progressBar = $('#progressbar');
|
||||
this.failedToLoad = 0;
|
||||
},
|
||||
|
||||
//It sets the tab on the basis of url e.g. if URL is <domain name>\default.html?result, Result tab will be selected
|
||||
selectTab: function () {
|
||||
var queryStr = location.search.toLowerCase();
|
||||
if (queryStr.indexOf("run") > 0) {
|
||||
$("#run").click();
|
||||
}
|
||||
else if (queryStr.indexOf("result") > 0) {
|
||||
$("#results").click();
|
||||
}
|
||||
else if (queryStr.indexOf("development") > 0) {
|
||||
$("#development").click();
|
||||
}
|
||||
else if (queryStr.indexOf("browser") > 0) {
|
||||
$("#browsers").click();
|
||||
}
|
||||
},
|
||||
|
||||
setVersionAndDate: function () {
|
||||
//Set the version and date
|
||||
$(".targetTestSuiteVersion").text(pageHelper.XML_TARGETTESTSUITEVERSION);
|
||||
$(".targetTestSuiteDate").text(pageHelper.XML_TARGETTESTSUITEDATE);
|
||||
},
|
||||
|
||||
//It sets title to the Results tab when tests are running
|
||||
configureReportLink: function (executing) {
|
||||
var reportLink = $('.test-report-link');
|
||||
if (executing) {
|
||||
reportLink.attr('testRunning', 'true');
|
||||
|
@ -35,134 +167,29 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
reportLink.parent().attr('title', '');
|
||||
reportLink.attr('testRunning', 'false');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
function init() {
|
||||
$('.content-home').show();
|
||||
|
||||
logger = $('#tableLogger');
|
||||
loggerParent = logger.parent();
|
||||
progressBar = $('#progressbar');
|
||||
failedToLoad = 0;
|
||||
|
||||
$('.nav-link').each(function(index) {
|
||||
if (index === 0) {
|
||||
$(this).attr('targetDiv', '.content-home');
|
||||
} else if (index === 1) {
|
||||
$(this).attr('targetDiv', '.content-tests');
|
||||
} else if (index === 2) {
|
||||
$(this).attr('targetDiv', '.content-results');
|
||||
$(this).attr('testRunning', 'false');
|
||||
} else if (index === 3) {
|
||||
$(this).attr('targetDiv', '.content-dev');
|
||||
}
|
||||
else {
|
||||
$(this).attr('targetDiv', '.content-browsers');
|
||||
}
|
||||
|
||||
$(this).click(function() {
|
||||
var target = $(this).attr('targetDiv');
|
||||
//Report page call here
|
||||
if ($(target).hasClass('content-results')) {
|
||||
if ($(this).attr('testRunning') === 'true') { return; }
|
||||
generateReportTable();
|
||||
}
|
||||
$('#contentContainer > div:visible').hide();
|
||||
$('.navBar .selected').toggleClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$(target).show();
|
||||
|
||||
if (target === '.content-browsers') {
|
||||
$("body").addClass("busy");
|
||||
setTimeout(function() {
|
||||
buildTable();
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//attach the start button event
|
||||
$('.button-start').click(function() {
|
||||
$('#testsToRun').text(ES5Harness.getTotalTestsToRun());
|
||||
$('#totalCounter').text(0);
|
||||
$('#Pass').text(0);
|
||||
$('#Fail').text(0);
|
||||
$('#totalFailedCounter').text(0);
|
||||
$('#failedToLoadCounter1').text(0);
|
||||
$('#failedToLoadCounter').text(0);
|
||||
|
||||
var testStatus = $(this).data('testStatus');
|
||||
|
||||
switch (testStatus) {
|
||||
case undefined:
|
||||
case TestConstants.STOPPED:
|
||||
ES5Harness.stop(TestConstants.STOPPED);
|
||||
logger.find('tr').remove();
|
||||
$(this).data('testStatus', TestConstants.RUNNING);
|
||||
ES5Harness.startTesting(update, TestConstants.RESET);
|
||||
$(this).attr('src', 'resources/images/pause.png');
|
||||
configureReportLink(true);
|
||||
break;
|
||||
case TestConstants.RUNNING:
|
||||
$(this).data('testStatus', TestConstants.PAUSED);
|
||||
ES5Harness.stop(TestConstants.PAUSED);
|
||||
$(this).attr('src', 'resources/images/resume.png');
|
||||
configureReportLink(false);
|
||||
break;
|
||||
case TestConstants.PAUSED:
|
||||
$(this).data('testStatus', TestConstants.RUNNING);
|
||||
$(this).attr('src', 'resources/images/pause.png');
|
||||
ES5Harness.startTesting(update, TestConstants.RESUME);
|
||||
configureReportLink(true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//attach the start button event
|
||||
$('.button-reset').click(function() {
|
||||
configureReportLink(false);
|
||||
$('.button-start').data('testStatus', TestConstants.STOPPED).attr('src', 'resources/images/start.png'); ;
|
||||
logger.find('tr').remove();
|
||||
ES5Harness.stop(TestConstants.RESET);
|
||||
$('#failedToLoadCounter1').text(0);
|
||||
$('#failedToLoadCounter').text(0);
|
||||
$('#totalFailedCounter').text(0);
|
||||
failedToLoad = 0;
|
||||
});
|
||||
|
||||
$('#ancGenXMLReport').click(function(e) {
|
||||
//e.preventDefault();
|
||||
generateReportXml();
|
||||
return false;
|
||||
});
|
||||
|
||||
//delete all the below lines later
|
||||
//$('#btnSetTimerValue').click(function(){
|
||||
// ES5Harness.TIMER_PERIOD = parseInt($('#txtTimerValue').val());
|
||||
//})
|
||||
|
||||
//load xml testcase path list
|
||||
ES5Harness && ES5Harness.loadTestList();
|
||||
}
|
||||
|
||||
function update(detailsObj) {
|
||||
//This is used as callback function for passing in sth.js
|
||||
update: function (detailsObj) {
|
||||
$('#testsToRun').text(detailsObj.totalTestsToRun);
|
||||
if (!isNaN(detailsObj.totalTestsRun)) {
|
||||
$('#totalCounter').text(detailsObj.totalTestsRun);
|
||||
}
|
||||
if (detailsObj.completed) {
|
||||
var btnStart = $('#btnStart').attr('src', 'resources/images/start.png');
|
||||
btnStart.data('testStatus', TestConstants.STOPPED);
|
||||
$('#totalFailedCounter').text(failedToLoad);
|
||||
configureReportLink(false);
|
||||
}
|
||||
|
||||
$('#Pass').text(detailsObj.totalTestsPassed);
|
||||
$('#Fail').text(detailsObj.totalTestsFailed);
|
||||
$('#failedToLoadCounter1').text(failedToLoad);
|
||||
$('#failedToLoadCounter').text(failedToLoad);
|
||||
$('#failedToLoadCounter1').text(pageHelper.failedToLoad);
|
||||
$('#failedToLoadCounter').text(pageHelper.failedToLoad);
|
||||
$('#nextActivity').text(detailsObj.nextActivity);
|
||||
if (detailsObj.completed) {
|
||||
var btnStart = $('#btnStart').attr('src', 'resources/images/start.png');
|
||||
btnStart.data('testStatus', "stopped");
|
||||
$('#totalFailedCounter').text(pageHelper.failedToLoad);
|
||||
pageHelper.configureReportLink(false);
|
||||
$('#nextActivity').text("");
|
||||
}
|
||||
|
||||
var altStyle = (logger.children().length % 2) === 0 ? ' ' : 'alternate';
|
||||
var altStyle = (pageHelper.logger.children().length % 2) === 0 ? ' ' : 'alternate';
|
||||
var appendStr = '';
|
||||
var length = 0;
|
||||
if (detailsObj.failedTestCases && detailsObj.failedTestCases.length > 0) {
|
||||
|
@ -173,7 +200,7 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
testObj = detailsObj.failedTestCases.shift();
|
||||
appendStr += '<tbody><tr class=\"' + altStyle + '\"><td width=\"20%\">' + testObj.id + '</td><td>' + testObj.description + '</td><td align="right"><span class=\"Fail\">Fail</span></td></tr></tbody>';
|
||||
}
|
||||
logger.append(appendStr);
|
||||
pageHelper.logger.append(appendStr);
|
||||
}
|
||||
|
||||
var testCasesPaths = this.ES5Harness.getFailToLoad();
|
||||
|
@ -184,20 +211,20 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
testObj = testCasesPaths.shift();
|
||||
altStyle = (altStyle !== ' ') ? ' ' : 'alternate';
|
||||
appendStr += '<tbody><tr class=\"' + altStyle + '\"><td width=\"20%\">' + testObj + '</td><td>' + '' + '</td><td align="right"><span class=\"Fail\">Not Loaded</span></td></tr></tbody>';
|
||||
failedToLoad++;
|
||||
pageHelper.failedToLoad++;
|
||||
}
|
||||
logger.append(appendStr);
|
||||
pageHelper.logger.append(appendStr);
|
||||
}
|
||||
loggerParent.attr("scrollTop", loggerParent.attr("scrollHeight"));
|
||||
progressBar.reportprogress(detailsObj.totalTestsRun, detailsObj.totalTestCasesForProgressBar);
|
||||
}
|
||||
pageHelper.loggerParent.attr("scrollTop", pageHelper.loggerParent.attr("scrollHeight"));
|
||||
pageHelper.progressBar.reportprogress(detailsObj.totalTestsRun, detailsObj.totalTestCasesForProgressBar);
|
||||
},
|
||||
|
||||
function generateReportXml() {
|
||||
|
||||
var reportWindow, //window that will output the xml data
|
||||
xmlData, //array instead of string concatenation
|
||||
dateNow,
|
||||
xml; // stop condition of for loop stored in a local variable to improve performance
|
||||
//This is used to generate the xml for the results
|
||||
generateReportXml: function () {
|
||||
var reportWindow; //window that will output the xml data
|
||||
var xmlData; //array instead of string concatenation
|
||||
var dateNow;
|
||||
var xml; // stop condition of for loop stored in a local variable to improve performance
|
||||
|
||||
dateNow = new Date();
|
||||
|
||||
|
@ -213,39 +240,45 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
|
||||
reportWindow = window.open();
|
||||
reportWindow.document.writeln("<title>ECMAScript Test262 XML</title>");
|
||||
reportWindow.document.writeln("<div>Instructions: Update the BROWSERNAME value and submit to Hg. Send email to the <a href='mailto:body@ecmascript.org' >list</a> for assistance.</div>");
|
||||
reportWindow.document.write("<textarea id='results' style='width: 100%; height: 800px;'>");
|
||||
reportWindow.document.write(xml);
|
||||
xml = "";
|
||||
function parseSection(section) {
|
||||
xml += "<section id='" + section.id + "' name='" + section.name + "'>\r\n";
|
||||
for (var i = 0; i < section.testCaseArray.length; i++) {
|
||||
xml += '<test>\r\n' +
|
||||
if (ES5Harness.getTotalTestsRun() !== parseInt(ES5Harness.getTotalTestsToRun())) {
|
||||
reportWindow.document.writeln("<div><b>Test Results file cannot be generated because execution is not completed</b></div>");
|
||||
|
||||
}
|
||||
else {
|
||||
reportWindow.document.writeln("<div><br/></div>");
|
||||
reportWindow.document.write("<textarea id='results' style='width: 100%; height: 800px;'>");
|
||||
reportWindow.document.write(xml);
|
||||
xml = "";
|
||||
function parseSection(section) {
|
||||
xml += "<section id='" + section.id + "' name='" + section.name + "'>\r\n";
|
||||
for (var i = 0; i < section.testCaseArray.length; i++) {
|
||||
xml += '<test>\r\n' +
|
||||
' <testId>' + section.testCaseArray[i].id + '</testId>\r\n' +
|
||||
' <res>' + section.testCaseArray[i].res + '</res>\r\n' +
|
||||
'</test>\r\n';
|
||||
}
|
||||
if (section.subSections !== undefined) {
|
||||
for (var i = 0; i < section.subSections.length; i++) {
|
||||
parseSection(section.subSections[i]);
|
||||
xml += '</section>\r\n';
|
||||
}
|
||||
if (section.subSections !== undefined) {
|
||||
for (var i = 0; i < section.subSections.length; i++) {
|
||||
parseSection(section.subSections[i]);
|
||||
xml += '</section>\r\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var index = 0; index < sections.length; index++) {
|
||||
parseSection(sections[index]);
|
||||
xml += '</section>\r\n';
|
||||
}
|
||||
reportWindow.document.write(xml);
|
||||
reportWindow.document.write('</Tests>\r\n</testRun>\r\n</textarea>\r\n');
|
||||
reportWindow.document.close();
|
||||
}
|
||||
for (var index = 0; index < sections.length; index++) {
|
||||
parseSection(sections[index]);
|
||||
xml += '</section>\r\n';
|
||||
}
|
||||
reportWindow.document.write(xml);
|
||||
reportWindow.document.write('</Tests>\r\n</testRun>\r\n</textarea>\r\n');
|
||||
reportWindow.document.close();
|
||||
}
|
||||
},
|
||||
|
||||
function htmlEscape(str) {
|
||||
htmlEscape: function (str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
},
|
||||
|
||||
function numTests(section) {
|
||||
numTests: function (section) {
|
||||
nTest = 0;
|
||||
for (var subSectionIndex = 0; subSectionIndex < section.subSections.length; subSectionIndex++) {
|
||||
if (section.subSections[subSectionIndex].total !== 0) {
|
||||
|
@ -253,13 +286,10 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
}
|
||||
}
|
||||
return nTest;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
var RED_LIMIT = 50;
|
||||
var YELLOW_LIMIT = 75;
|
||||
var GREEN_LIMIT = 99.9;
|
||||
function generateReportTable() {
|
||||
//It generates the report that is displayed in results tab
|
||||
generateReportTable: function () {
|
||||
var bResultsdisplayed = false;
|
||||
|
||||
$('#backlinkDiv').hide();
|
||||
|
@ -267,119 +297,167 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
var sections = window.sections;
|
||||
var dataTable = $('.results-data-table');
|
||||
$('.results-data-table').find("tr").remove();
|
||||
|
||||
//set the total, pass and fail count
|
||||
$('.totalCases').text(ES5Harness.getTotalTestsRun());
|
||||
$('.passedCases').text(ES5Harness.getTotalTestsPassed());
|
||||
$('.failedCases').text(ES5Harness.getTotalTestsFailed());
|
||||
$('#failedToLoadCounterDetails').text(failedToLoad);
|
||||
$('.crumbs #link1').remove();
|
||||
$('.crumbs #link2').remove();
|
||||
$('.crumbs #link3').remove();
|
||||
$('#failedToLoadCounterDetails').text(pageHelper.failedToLoad);
|
||||
try {
|
||||
$('.crumbs #link1').remove();
|
||||
$('.crumbs #link2').remove();
|
||||
$('.crumbs #link3').remove();
|
||||
}
|
||||
catch (e) {
|
||||
$('.crumbs #link1').text("");
|
||||
$('.crumbs #link2').text("");
|
||||
$('.crumbs #link3').text("");
|
||||
}
|
||||
|
||||
//set the navigation bar
|
||||
var anc1 = $('<a id="link1">Test Report ></a>');
|
||||
anc1.attr('href', 'javascript:PageHelper.generateReportTable();');
|
||||
anc1.attr('href', 'javascript:pageHelper.generateReportTable();');
|
||||
$('.crumbs').append(anc1);
|
||||
$('.crumbs #link1').removeClass().addClass("setBlack");
|
||||
|
||||
var totalSubSectionPassed = 0;
|
||||
for (var sectionIndex = 0; sectionIndex < sections.length; sectionIndex++) {
|
||||
if (numTests(sections[sectionIndex]) !== 0) {
|
||||
if (pageHelper.numTests(sections[sectionIndex]) !== 0) {
|
||||
bResultsdisplayed = true;
|
||||
dataTable.append('<tbody><tr><td class="tblHeader" colspan="2">' + 'Chapter ' + sections[sectionIndex].id + '- ' + sections[sectionIndex].name + '</td></tr></tbody>');
|
||||
var mainSectionPercentageStyle = "reportRed";
|
||||
// if there are any cases directly inside the chapter instead of in subsections
|
||||
if (sections[sectionIndex].testCaseArray.length > 0) {
|
||||
|
||||
for (var index = 0; index < sections[sectionIndex].subSections.length; index++) {
|
||||
totalSubSectionPassed = totalSubSectionPassed + sections[sectionIndex].subSections[index].passed;
|
||||
}
|
||||
|
||||
var calculatedLimit = (sections[sectionIndex].passed - totalSubSectionPassed) / sections[sectionIndex].testCaseArray.length * 100;
|
||||
if (calculatedLimit >= GREEN_LIMIT) {
|
||||
if (calculatedLimit >= pageHelper.GREEN_LIMIT) {
|
||||
mainSectionPercentageStyle = "reportGreen";
|
||||
}
|
||||
else if (Math.round(calculatedLimit) >= YELLOW_LIMIT) {
|
||||
else if (Math.round(calculatedLimit) >= pageHelper.YELLOW_LIMIT) {
|
||||
mainSectionPercentageStyle = "reportLightGreen";
|
||||
}
|
||||
else if (Math.round(calculatedLimit) >= RED_LIMIT) {
|
||||
else if (Math.round(calculatedLimit) >= pageHelper.RED_LIMIT) {
|
||||
mainSectionPercentageStyle = "reportYellow";
|
||||
}
|
||||
else {
|
||||
mainSectionPercentageStyle = "reportRed";
|
||||
}
|
||||
|
||||
dataTable.append('<tbody><tr><td><a href="javascript:PageHelper.generateDetailedReportTable(' + sectionIndex + ',-1);">' + "In Chapter " + sections[sectionIndex].id + '</a></td><td class="' + mainSectionPercentageStyle + '">' + (Math.round(calculatedLimit)) + '%' + '</td></tr></tbody>');
|
||||
dataTable.append('<tbody><tr><td><a href="javascript:pageHelper.generateDetailedReportTable(' + sectionIndex + ',-1);">' + "In Chapter " + sections[sectionIndex].id + '</a></td><td class="' + mainSectionPercentageStyle + '">' + (Math.round(calculatedLimit)) + '%' + '</td></tr></tbody>');
|
||||
}
|
||||
}
|
||||
|
||||
for (var subSectionIndex = 0; subSectionIndex < sections[sectionIndex].subSections.length; subSectionIndex++) {
|
||||
var styleClass;
|
||||
if (sections[sectionIndex].subSections[subSectionIndex].total !== 0) {
|
||||
var passedPercentage = sections[sectionIndex].subSections[subSectionIndex].getPassPercentage();
|
||||
if (passedPercentage >= GREEN_LIMIT) {
|
||||
|
||||
var passedPercentage = 0;
|
||||
//If there are subsections in subsection along with direct test cases, calculation is done like below
|
||||
if (sections[sectionIndex].subSections[subSectionIndex].subSections) {
|
||||
var totalPassedSubSections = sections[sectionIndex].subSections[subSectionIndex].passed;
|
||||
var totalSubSections = sections[sectionIndex].subSections[subSectionIndex].total;
|
||||
for (var subSubSectionIndex = 0; subSubSectionIndex < sections[sectionIndex].subSections[subSectionIndex].subSections.length; subSubSectionIndex++) {
|
||||
totalPassedSubSections = totalPassedSubSections + sections[sectionIndex].subSections[subSectionIndex].subSections[subSubSectionIndex].passed;
|
||||
totalSubSections = totalSubSections + sections[sectionIndex].subSections[subSectionIndex].subSections[subSubSectionIndex].total;
|
||||
}
|
||||
|
||||
passedPercentage = totalPassedSubSections / totalSubSections * 100;
|
||||
}
|
||||
else {
|
||||
passedPercentage = sections[sectionIndex].subSections[subSectionIndex].getPassPercentage();
|
||||
}
|
||||
if (passedPercentage >= pageHelper.GREEN_LIMIT) {
|
||||
styleClass = "reportGreen";
|
||||
}
|
||||
else if (passedPercentage >= YELLOW_LIMIT) {
|
||||
else if (passedPercentage >= pageHelper.YELLOW_LIMIT) {
|
||||
styleClass = "reportLightGreen";
|
||||
}
|
||||
else if (passedPercentage >= RED_LIMIT) {
|
||||
else if (passedPercentage >= pageHelper.RED_LIMIT) {
|
||||
styleClass = "reportYellow";
|
||||
}
|
||||
else {
|
||||
styleClass = "reportRed";
|
||||
}
|
||||
|
||||
dataTable.append('<tbody><tr><td class="sectionName"><a href="javascript:PageHelper.generateSubSectionReportTable(' + sectionIndex + ',' + subSectionIndex + ');">' + sections[sectionIndex].subSections[subSectionIndex].name + '</a></td><td class="' + styleClass + '">' + (Math.round(passedPercentage)) + '%' + '</td></tr></tbody>');
|
||||
dataTable.append('<tbody><tr><td class="sectionName"><a href="javascript:pageHelper.generateSubSectionReportTable(' + sectionIndex + ',' + subSectionIndex + ');">' + sections[sectionIndex].subSections[subSectionIndex].name + '</a></td><td class="' + styleClass + '">' + (Math.round(passedPercentage)) + '%' + '</td></tr></tbody>');
|
||||
bResultsdisplayed = true;
|
||||
}
|
||||
}
|
||||
|
||||
totalSubSectionPassed = 0;
|
||||
|
||||
}
|
||||
|
||||
// append the legend if results have been displayed
|
||||
if (bResultsdisplayed) {
|
||||
$('#legend').show();
|
||||
}
|
||||
}
|
||||
|
||||
function generateSubSectionReportTable(sectionIndex, subSectionIndex) {
|
||||
//Disappear the note if there are records in the result
|
||||
if ($.trim(dataTable.text()) !== "")
|
||||
$("#resultMessage").hide();
|
||||
else
|
||||
$("#resultMessage").show();
|
||||
},
|
||||
|
||||
//It shows the sub section of the results
|
||||
generateSubSectionReportTable: function (sectionIndex, subSectionIndex) {
|
||||
var sections = window.sections;
|
||||
var dataTable = $('.results-data-table');
|
||||
$('.results-data-table').find("tr").remove();
|
||||
|
||||
var styleClass;
|
||||
var totalSubSectionPassed = 0;
|
||||
|
||||
var totalSubSectionFailed = 0;
|
||||
|
||||
// if there is no subsections under a section(say 7.1) then directly display the detailed test report
|
||||
if (!sections[sectionIndex].subSections[subSectionIndex].subSections) {
|
||||
generateDetailedReportTable(sectionIndex, subSectionIndex);
|
||||
pageHelper.generateDetailedReportTable(sectionIndex, subSectionIndex);
|
||||
}
|
||||
else {
|
||||
|
||||
$('.crumbs #link2').remove();
|
||||
var anc2 = $('<a id="link2">' + " Chapter " + sections[sectionIndex].id + ": " + sections[sectionIndex].name + ": " + sections[sectionIndex].subSections[subSectionIndex].name + " > " + '</a>');
|
||||
anc2.attr('href', 'javascript:PageHelper.generateSubSectionReportTable(' + sectionIndex + ',' + subSectionIndex + ');');
|
||||
try {
|
||||
$('.crumbs #link2').remove();
|
||||
}
|
||||
catch (e) {
|
||||
$('.crumbs #link2').text("");
|
||||
}
|
||||
var anc2 = $("<a id='link2'>" + " Chapter " + sections[sectionIndex].id.toString() + ": " + sections[sectionIndex].name + ": " + sections[sectionIndex].subSections[subSectionIndex].name + " > " + "</a>");
|
||||
anc2.attr('href', 'javascript:pageHelper.generateSubSectionReportTable(' + sectionIndex + ',' + subSectionIndex + ');');
|
||||
$('.crumbs').append(anc2);
|
||||
|
||||
$('.crumbs #link2').removeClass().addClass("setBlack");
|
||||
$('.crumbs #link1').removeClass().addClass("setBlue");
|
||||
|
||||
var anc = $('.crumbs').find('a');
|
||||
anc.click(function() {
|
||||
anc.click(function () {
|
||||
$(this).next('a').remove();
|
||||
|
||||
});
|
||||
$('.crumbs #link3').remove();
|
||||
try {
|
||||
$('.crumbs #link3').remove();
|
||||
}
|
||||
catch (e) {
|
||||
$('.crumbs #link3').text("");
|
||||
}
|
||||
|
||||
for (var index = 0; index < sections[sectionIndex].subSections[subSectionIndex].subSections.length; index++) {
|
||||
totalSubSectionPassed = totalSubSectionPassed + sections[sectionIndex].subSections[subSectionIndex].subSections[index].passed;
|
||||
totalSubSectionFailed = totalSubSectionFailed + sections[sectionIndex].subSections[subSectionIndex].subSections[index].failed;
|
||||
}
|
||||
|
||||
var totalCasesInSection = sections[sectionIndex].subSections[subSectionIndex].total - totalSubSectionPassed - totalSubSectionFailed;
|
||||
var totalPassedCasesInSection = sections[sectionIndex].subSections[subSectionIndex].passed - totalSubSectionPassed;
|
||||
var totalFailedCasesInSection = sections[sectionIndex].subSections[subSectionIndex].failed - totalSubSectionFailed;
|
||||
$('.totalCases').text(sections[sectionIndex].subSections[subSectionIndex].total);
|
||||
$('.passedCases').text(sections[sectionIndex].subSections[subSectionIndex].passed);
|
||||
$('.failedCases').text(sections[sectionIndex].subSections[subSectionIndex].failed);
|
||||
|
||||
for (var index = 0; index < sections[sectionIndex].subSections[subSectionIndex].subSections.length; index++) {
|
||||
totalSubSectionPassed = totalSubSectionPassed + sections[sectionIndex].subSections[subSectionIndex].subSections[index].passed;
|
||||
}
|
||||
|
||||
if (sections[sectionIndex].subSections[subSectionIndex].testCaseArray.length > 0) {
|
||||
var calculatedLimit = Math.round((sections[sectionIndex].subSections[subSectionIndex].passed - totalSubSectionPassed) / sections[sectionIndex].subSections[subSectionIndex].testCaseArray.length * 100);
|
||||
|
||||
// var calculatedLimit = Math.round((sections[sectionIndex].subSections[subSectionIndex].passed) / sections[sectionIndex].subSections[subSectionIndex].testCaseArray.length * 100);
|
||||
var calculatedLimit = Math.round((totalPassedCasesInSection / totalCasesInSection) * 100);
|
||||
if (calculatedLimit >= 75) {
|
||||
styleClass = "reportGreen";
|
||||
}
|
||||
|
@ -390,41 +468,33 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
styleClass = "reportRed";
|
||||
}
|
||||
|
||||
dataTable.append('<tr><td class="tblSectionHeader"><a href="javascript:PageHelper.generateDetailedReportTable(' + sectionIndex + ',' + subSectionIndex + ');">' + "Section: " + sections[sectionIndex].subSections[subSectionIndex].id + " cases" + '</a></td><td class="' + styleClass + '">' + calculatedLimit + '%' + '</td></tr>');
|
||||
dataTable.append('<tbody><tr><td class="tblSectionHeader"><a href="javascript:pageHelper.generateDetailedReportTable(' + sectionIndex + ',' + subSectionIndex + ');">' + "Section: " + sections[sectionIndex].subSections[subSectionIndex].id + " cases" + '</a></td><td class="' + styleClass + '">' + calculatedLimit + '%' + '</td></tr></tbody>');
|
||||
}
|
||||
|
||||
if (sections[sectionIndex].subSections[subSectionIndex].subSections) {
|
||||
|
||||
for (var objIndex = 0; objIndex < sections[sectionIndex].subSections[subSectionIndex].subSections.length; objIndex++) {
|
||||
if (sections[sectionIndex].subSections[subSectionIndex].subSections[objIndex].total !== 0) {
|
||||
|
||||
var passedPercentage = sections[sectionIndex].subSections[subSectionIndex].subSections[objIndex].getPassPercentage();
|
||||
if (passedPercentage >= YELLOW_LIMIT) {
|
||||
if (passedPercentage >= pageHelper.YELLOW_LIMIT) {
|
||||
styleClass = "reportGreen";
|
||||
}
|
||||
else if (passedPercentage >= RED_LIMIT) {
|
||||
else if (passedPercentage >= pageHelper.RED_LIMIT) {
|
||||
styleClass = "reportYellow";
|
||||
}
|
||||
else {
|
||||
styleClass = "reportRed";
|
||||
}
|
||||
dataTable.append('<tbody><tr><td class="tblSectionHeader"><a href="javascript:pageHelper.generateDetailedReportTable(' + sectionIndex + ',' + subSectionIndex + ',' + objIndex + ');">' + sections[sectionIndex].subSections[subSectionIndex].subSections[objIndex].name + '</a></td><td class="' + styleClass + '">' + (Math.round(passedPercentage)) + '%' + '</td></tr></tbody>');
|
||||
|
||||
dataTable.append('<tr><td class="tblSectionHeader"><a href="javascript:PageHelper.generateDetailedReportTable(' + sectionIndex + ',' + subSectionIndex + ',' + objIndex + ');">' + sections[sectionIndex].subSections[subSectionIndex].subSections[objIndex].name + '</a></td><td class="' + styleClass + '">' + (Math.round(passedPercentage)) + '%' + '</td></tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pageHelper.doBackButtonTasks();
|
||||
},
|
||||
|
||||
doBackButtonTasks();
|
||||
}
|
||||
|
||||
function doBackButtonTasks() {
|
||||
$('#backlinkDiv').show();
|
||||
var anchors = $('.crumbs a');
|
||||
var contextAnchor = anchors[anchors.length - 2];
|
||||
$('#backlinkDiv').attr('href', contextAnchor.href);
|
||||
}
|
||||
|
||||
function generateDetailedReportTable(sectionIndex, subSectionIndex, subInnerSectionIndex) {
|
||||
generateDetailedReportTable: function (sectionIndex, subSectionIndex, subInnerSectionIndex) {
|
||||
var sections = window.sections;
|
||||
var dataTable = $('.results-data-table');
|
||||
|
||||
|
@ -460,19 +530,11 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
// cases directly under subsections example: 7.1
|
||||
else if (sections[sectionIndex].subSections[subSectionIndex].testCaseArray.length > 0) {
|
||||
subSectionObj = sections[sectionIndex].subSections[subSectionIndex];
|
||||
for (var index = 0; index < sections[sectionIndex].subSections[subSectionIndex].subSections.length; index++) {
|
||||
subSectionPassed = subSectionPassed + sections[sectionIndex].subSections[subSectionIndex].subSections[index].passed;
|
||||
subSectionfailed = subSectionfailed + sections[sectionIndex].subSections[subSectionIndex].subSections[index].failed;
|
||||
}
|
||||
|
||||
$('.totalCases').text(subSectionObj.testCaseArray.length);
|
||||
$('.passedCases').text(subSectionObj.passed - subSectionPassed);
|
||||
$('.failedCases').text(subSectionObj.failed - subSectionfailed);
|
||||
$('.totalCases').text(subSectionObj.total);
|
||||
$('.passedCases').text(subSectionObj.passed);
|
||||
$('.failedCases').text(subSectionObj.failed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $('#backlinkDiv').remove();
|
||||
var anc3 = $('<a id="link3">' + " Section: " + subSectionObj.id + " " + subSectionObj.name + '</a>');
|
||||
$('.crumbs').append(anc3);
|
||||
$('.crumbs #link3').removeClass().addClass("setBlack");
|
||||
|
@ -491,7 +553,6 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
dataTable.append('<tbody><tr><td>' + subSectionObj.testCaseArray[objIndex].id + '</td><td>' + subSectionObj.testCaseArray[objIndex].description + '</td><td class="' + resultStyle + '">' + subSectionObj.testCaseArray[objIndex].res + '</td><td><a href="javascript:ES5Harness.openSourceWindow(' + subSectionObj.testCaseArray[objIndex].registrationIndex + ');">[source]</a></td></tr></tbody>');
|
||||
}
|
||||
}
|
||||
|
||||
// testcases directly under a chapter when there are no sections in a chapter
|
||||
else {
|
||||
anc3 = $('<a id="link3">' + " Chapter: " + sections[sectionIndex].id + ": " + sections[sectionIndex].name + '</a>');
|
||||
|
@ -502,11 +563,12 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
$('.crumbs #link1').removeClass().addClass("setBlue");
|
||||
|
||||
$('.sectionId').text("section: " + sections[sectionIndex].id);
|
||||
for (subSectionIndex = 0; subSectionIndex < sections[sectionIndex].subSections.length; subSectionIndex++) {
|
||||
|
||||
for (var subSectionIndex = 0; subSectionIndex < sections[sectionIndex].subSections.length; subSectionIndex++) {
|
||||
mainSectionPassed = mainSectionPassed + sections[sectionIndex].subSections[subSectionIndex].passed;
|
||||
mainSectionfailed = mainSectionfailed + sections[sectionIndex].subSections[subSectionIndex].failed;
|
||||
}
|
||||
$('.totalCases').text(sections[sectionIndex].testCaseArray.length);
|
||||
$('.totalCases').text(sections[sectionIndex].total - mainSectionPassed - mainSectionfailed);
|
||||
$('.passedCases').text(sections[sectionIndex].passed - mainSectionPassed);
|
||||
$('.failedCases').text(sections[sectionIndex].failed - mainSectionfailed);
|
||||
|
||||
|
@ -523,39 +585,43 @@ var XML_TARGETTESTSUITEDATE = '';
|
|||
}
|
||||
}
|
||||
|
||||
doBackButtonTasks();
|
||||
pageHelper.doBackButtonTasks();
|
||||
},
|
||||
|
||||
//It shows the back link
|
||||
doBackButtonTasks: function () {
|
||||
$('#backlinkDiv').show();
|
||||
//The below logic is applied because .remove() is giving object error in the function "generateReportTable" that I could not find the reason.
|
||||
//That is why I am keeping the links (#link1, #link2 and #link3) blank if any error .
|
||||
var anchors = [];
|
||||
$('.crumbs a').each(function (index, anchor) {
|
||||
if ($(anchor).text() !== "") {
|
||||
anchors[anchors.length] = anchor;
|
||||
}
|
||||
});
|
||||
var contextAnchor = anchors[anchors.length - 2];
|
||||
$('#backlinkDiv').attr('href', contextAnchor.href);
|
||||
}
|
||||
|
||||
//Register the variables in the namespce
|
||||
window.PageHelper.init = init;
|
||||
// window.$ERROR = $ERROR;
|
||||
window.PageHelper.generateReportXml = generateReportXml;
|
||||
window.PageHelper.generateDetailedReportTable = generateDetailedReportTable;
|
||||
//window.PageHelper.logger = this.logger;
|
||||
//window.PageHelper.loggerParent = this.loggerParent;
|
||||
window.PageHelper.generateSubSectionReportTable = generateSubSectionReportTable;
|
||||
window.PageHelper.generateReportTable = generateReportTable;
|
||||
window.PageHelper.progressBar = this.progressBar;
|
||||
})()
|
||||
|
||||
|
||||
$(window).ready(function() {
|
||||
PageHelper.init();
|
||||
});
|
||||
};
|
||||
|
||||
//Extend the array type
|
||||
Array.prototype.getCloneOfObject = function(oldObject) {
|
||||
getArrayCloneOfObject = function (oldObject)
|
||||
{
|
||||
var tempClone = {};
|
||||
|
||||
if (typeof (oldObject) === "object") {
|
||||
for (prop in oldObject) {
|
||||
if ((typeof (oldObject[prop]) === "object") && (oldObject[prop]).__isArray) {
|
||||
tempClone[prop] = this.getCloneOfArray(oldObject[prop]);
|
||||
if (typeof (oldObject) === "object")
|
||||
{
|
||||
for (prop in oldObject)
|
||||
{
|
||||
if ((typeof (oldObject[prop]) === "object") && (oldObject[prop]).__isArray)
|
||||
{
|
||||
tempClone[prop] = getArrayCloneOfObject(oldObject[prop]);
|
||||
}
|
||||
else if (typeof (oldObject[prop]) === "object") {
|
||||
tempClone[prop] = this.getCloneOfObject(oldObject[prop]);
|
||||
else if (typeof (oldObject[prop]) === "object")
|
||||
{
|
||||
tempClone[prop] = getArrayCloneOfObject(oldObject[prop]);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
tempClone[prop] = oldObject[prop];
|
||||
}
|
||||
}
|
||||
|
@ -563,16 +629,18 @@ Array.prototype.getCloneOfObject = function(oldObject) {
|
|||
return tempClone;
|
||||
}
|
||||
|
||||
Array.prototype.clone = function() {
|
||||
CloneArray = function (arrayObj)
|
||||
{
|
||||
var tempClone = [];
|
||||
|
||||
for (var arrIndex = 0; arrIndex <= this.length; arrIndex++) {
|
||||
if (typeof (this[arrIndex]) === "object") {
|
||||
tempClone.push(this.getCloneOfObject(this[arrIndex]));
|
||||
} else {
|
||||
tempClone.push(this[arrIndex]);
|
||||
for (var arrIndex = 0; arrIndex <= arrayObj.length; arrIndex++)
|
||||
{
|
||||
if (typeof (arrayObj[arrIndex]) === "object")
|
||||
{
|
||||
tempClone.push(getArrayCloneOfObject(arrayObj[arrIndex]));
|
||||
} else
|
||||
{
|
||||
tempClone.push(arrayObj[arrIndex]);
|
||||
}
|
||||
}
|
||||
return tempClone;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,142 @@
|
|||
|
||||
/**
|
||||
* jQuery BASE64 functions
|
||||
*
|
||||
* <code>
|
||||
* Encodes the given data with base64.
|
||||
* String $.base64Encode ( String str )
|
||||
* <br />
|
||||
* Decodes a base64 encoded data.
|
||||
* String $.base64Decode ( String str )
|
||||
* </code>
|
||||
*
|
||||
* Encodes and Decodes the given data in base64.
|
||||
* This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
|
||||
* Base64-encoded data takes about 33% more space than the original data.
|
||||
* This javascript code is used to encode / decode data using base64 (this encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean). Script is fully compatible with UTF-8 encoding. You can use base64 encoded data as simple encryption mechanism.
|
||||
* If you plan using UTF-8 encoding in your project don't forget to set the page encoding to UTF-8 (Content-Type meta tag).
|
||||
* This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
|
||||
*
|
||||
* Example
|
||||
* Code
|
||||
* <code>
|
||||
* $.base64Encode("I'm Persian.");
|
||||
* </code>
|
||||
* Result
|
||||
* <code>
|
||||
* "SSdtIFBlcnNpYW4u"
|
||||
* </code>
|
||||
* Code
|
||||
* <code>
|
||||
* $.base64Decode("SSdtIFBlcnNpYW4u");
|
||||
* </code>
|
||||
* Result
|
||||
* <code>
|
||||
* "I'm Persian."
|
||||
* </code>
|
||||
*
|
||||
* @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
|
||||
* @link http://www.semnanweb.com/jquery-plugin/base64.html
|
||||
* @see http://www.webtoolkit.info/
|
||||
* @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
|
||||
* @param {jQuery} {base64Encode:function(input))
|
||||
* @param {jQuery} {base64Decode:function(input))
|
||||
* @return string
|
||||
*/
|
||||
|
||||
(function($){
|
||||
|
||||
var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
var uTF8Encode = function(string) {
|
||||
string = string.replace(/\x0d\x0a/g, "\x0a");
|
||||
var output = "";
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
var c = string.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
output += String.fromCharCode(c);
|
||||
} else if ((c > 127) && (c < 2048)) {
|
||||
output += String.fromCharCode((c >> 6) | 192);
|
||||
output += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
output += String.fromCharCode((c >> 12) | 224);
|
||||
output += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
output += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
var uTF8Decode = function(input) {
|
||||
var string = "";
|
||||
var i = 0;
|
||||
var c = c1 = c2 = 0;
|
||||
while ( i < input.length ) {
|
||||
c = input.charCodeAt(i);
|
||||
if (c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
} else if ((c > 191) && (c < 224)) {
|
||||
c2 = input.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
} else {
|
||||
c2 = input.charCodeAt(i+1);
|
||||
c3 = input.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
$.extend({
|
||||
base64Encode: function(input) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
input = uTF8Encode(input);
|
||||
while (i < input.length) {
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
} else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
output = output + keyString.charAt(enc1) + keyString.charAt(enc2) + keyString.charAt(enc3) + keyString.charAt(enc4);
|
||||
}
|
||||
return output;
|
||||
},
|
||||
base64Decode: function(input) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
while (i < input.length) {
|
||||
enc1 = keyString.indexOf(input.charAt(i++));
|
||||
enc2 = keyString.indexOf(input.charAt(i++));
|
||||
enc3 = keyString.indexOf(input.charAt(i++));
|
||||
enc4 = keyString.indexOf(input.charAt(i++));
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
output = output + String.fromCharCode(chr1);
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
}
|
||||
output = uTF8Decode(output);
|
||||
return output;
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
|
@ -29,26 +29,24 @@
|
|||
* Version: Alpha 2
|
||||
* Release: 2007-02-26
|
||||
*/
|
||||
(function($) {
|
||||
//Main Method
|
||||
$.fn.reportprogress = function(val,maxVal) {
|
||||
var max=100;
|
||||
if(maxVal)
|
||||
max=maxVal;
|
||||
return this.each(
|
||||
function(){
|
||||
var div=$(this);
|
||||
var innerdiv=div.find(".progress");
|
||||
|
||||
if(innerdiv.length!=1){
|
||||
|
||||
innerdiv=$("<div class='progress'><span class='text'> </span></div>");
|
||||
// $("<span class='text'> </span>").css("width",div.width()).appendTo(innerdiv);
|
||||
div.append(innerdiv);
|
||||
}
|
||||
var width=Math.round(val/max*100);
|
||||
innerdiv.css("width",width+"%");
|
||||
div.find(".text").html(width+" %");
|
||||
(function($) {
|
||||
//Main Method
|
||||
$.fn.reportprogress = function(val, maxVal) {
|
||||
var max = 100;
|
||||
if (maxVal) {
|
||||
max = maxVal;
|
||||
}
|
||||
return this.each(
|
||||
function() {
|
||||
var div = $(this);
|
||||
var innerdiv = div.find(".progress");
|
||||
if (innerdiv.length !== 1) {
|
||||
innerdiv = $("<div class='progress'><span class='text'> </span></div>");
|
||||
div.append(innerdiv);
|
||||
}
|
||||
var width = Math.round(val / max * 100);
|
||||
innerdiv.css("width", width + "%");
|
||||
div.find(".text").html(width + " %");
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ var fileList = [];
|
|||
var xslReportDetails = loadXMLDoc(TEST_REPORT_DETAILS_TABLE_XSL);
|
||||
var xslTestList = loadXMLDoc(TEST_REPORT_INDIV_TESTS_TABLE_XSL);
|
||||
|
||||
// Populate fileList array by reading all xml files in "enginereports/testresults" directory on server
|
||||
// Populate fileList array by reading all xml files in "/enginereports/testresults" directory on server
|
||||
function loadTestResultList() {
|
||||
if (fileList.length === 0) {
|
||||
var httpRequest = new XMLHttpRequest();
|
||||
|
@ -25,7 +25,7 @@ function loadTestResultList() {
|
|||
var linkElements = tempDiv.getElementsByTagName("a");
|
||||
for (var i = 0; i < linkElements.length; i++) {
|
||||
if (linkElements[i].pathname.match(".xml$")) {
|
||||
fileList.push(linkElements[i].pathname);
|
||||
fileList.push(TEST_RESULT_PATH + linkElements[i].innerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,27 @@ function Section(id, name, subSections) {
|
|||
this.subSections = subSections;
|
||||
this.testCaseArray = [];
|
||||
this.getPassPercentage = function () {
|
||||
if (this.total > 0)
|
||||
if (this.total > 0) {
|
||||
return (this.passed / this.total) * 100;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function resetResults() {
|
||||
|
||||
for (var secInd = 0; secInd < sections.length; secInd++) {
|
||||
for (var subSecInd = 0; subSecInd < sections[secInd].subSections.length; subSecInd++) {
|
||||
sections[secInd].subSections[subSecInd].total = 0;
|
||||
sections[secInd].subSections[subSecInd].passed = 0;
|
||||
sections[secInd].subSections[subSecInd].failed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//array to hold the sections data
|
||||
var sections = [];
|
||||
|
||||
|
@ -28,7 +42,7 @@ function addSection(node, nodeSections) {
|
|||
var tocSubSections = [];
|
||||
var nodes = node.childNodes;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "sec") {
|
||||
if (nodes[i].nodeName === "sec") {
|
||||
addSection(nodes[i], tocSubSections);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +58,7 @@ function addSection(node, nodeSections) {
|
|||
// Load all sections from TOC xml
|
||||
function loadSections() {
|
||||
// Constant for TOC file path
|
||||
var TOCFILEPATH = "resources/scripts/global/ECMA-262-TOC.XML";
|
||||
var TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml";
|
||||
|
||||
// Load TOC from xml
|
||||
var sectionsLoader = new XMLHttpRequest();
|
||||
|
@ -53,58 +67,65 @@ function loadSections() {
|
|||
var xmlDoc = sectionsLoader.responseXML;
|
||||
var nodes = xmlDoc.documentElement.childNodes;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "sec") {
|
||||
if (nodes[i].nodeName === "sec") {
|
||||
addSection(nodes[i], sections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function existsSection(section) {
|
||||
var retValue = false;
|
||||
|
||||
|
||||
holdArray = section.split(".");
|
||||
//subtract SECTION_TOC_OFFSET, since sections start from SECTION_TOC_OFFSET and section array from 0
|
||||
chapterId = holdArray[0] - SECTION_TOC_OFFSET;
|
||||
if (holdArray.length > 0) {
|
||||
retValue = sections[chapterId] != undefined ? true : false;
|
||||
}
|
||||
retValue = sections[chapterId] !== undefined ? true : false;
|
||||
}
|
||||
if (retValue && (holdArray.length > 1)) {
|
||||
retValue = ((sections[chapterId].subSections != undefined) && (sections[chapterId].subSections[holdArray[1] - 1] != undefined)) ? true : false;
|
||||
}
|
||||
retValue = ((sections[chapterId].subSections !== undefined) && (sections[chapterId].subSections[holdArray[1] - 1] !== undefined)) ? true : false;
|
||||
}
|
||||
if (retValue && (holdArray.length > 2)) {
|
||||
retValue = ((sections[chapterId].subSections[holdArray[1] - 1].subSections != undefined ) && (sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1] != undefined)) ? true : false;
|
||||
retValue = ((sections[chapterId].subSections !== undefined) && (sections[chapterId].subSections[holdArray[1] - 1].subSections !== undefined) && (sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1] !== undefined)) ? true : false;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
function addCountToSection(section,type) {
|
||||
function addCountToSection(section, type) {
|
||||
holdArray = section.split(".");
|
||||
//subtract SECTION_TOC_OFFSET, since sections start from SECTION_TOC_OFFSET and section array from 0
|
||||
chapterId = holdArray[0] - SECTION_TOC_OFFSET;
|
||||
switch (type) {
|
||||
case 'total':
|
||||
sections[chapterId].total++;
|
||||
if (holdArray.length == 2 & existsSection(section))
|
||||
if (holdArray.length === 2 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].total++;
|
||||
}
|
||||
if (holdArray.length === 3 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].total++;
|
||||
if (holdArray.length == 3 & existsSection(section))
|
||||
sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1].total++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'passed':
|
||||
sections[chapterId].passed++;
|
||||
if (holdArray.length == 2 & existsSection(section))
|
||||
if (holdArray.length === 2 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].passed++;
|
||||
}
|
||||
if (holdArray.length === 3 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].passed++;
|
||||
if (holdArray.length == 3 & existsSection(section))
|
||||
sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1].passed++;
|
||||
}
|
||||
break;
|
||||
case 'failed':
|
||||
sections[chapterId].failed++;
|
||||
if (holdArray.length == 2 & existsSection(section))
|
||||
if (holdArray.length === 2 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].failed++;
|
||||
}
|
||||
if (holdArray.length === 3 & existsSection(section)) {
|
||||
sections[chapterId].subSections[holdArray[1] - 1].failed++;
|
||||
if (holdArray.length == 3 & existsSection(section))
|
||||
sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1].failed++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ function SputnikError(message) {
|
|||
}
|
||||
|
||||
SputnikError.prototype.toString = function () {
|
||||
return "SputnikError: " + this.message;
|
||||
return "Test262 Error: " + this.message;
|
||||
};
|
||||
|
||||
function testFailed(message) {
|
||||
|
@ -21,10 +21,11 @@ function testPrint(message) {
|
|||
|
||||
|
||||
//adaptors for Test262 framework
|
||||
function $Print(message) {
|
||||
function $PRINT(message) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function $INCLUDE(message) { }
|
||||
function $ERROR(message) {
|
||||
testFailed(message);
|
||||
}
|
||||
|
@ -120,6 +121,18 @@ var date_2000_start = 946684800000;
|
|||
var date_2099_end = 4102444799999;
|
||||
var date_2100_start = 4102444800000;
|
||||
|
||||
//the following values are normally generated by the sputnik.py driver
|
||||
// for now, we'll just use 0 for everything
|
||||
var $LocalTZ = 0;
|
||||
var $DST_start_month = 0;
|
||||
var $DST_start_sunday = 0;
|
||||
var $DST_start_hour = 0;
|
||||
var $DST_start_minutes = 0;
|
||||
var $DST_end_month = 0;
|
||||
var $DST_end_sunday = 0;
|
||||
var $DST_end_hour = 0;
|
||||
var $DST_end_minutes = 0;
|
||||
|
||||
|
||||
//Date.library.js
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
|
@ -450,17 +463,6 @@ function ConstructDate(year, month, date, hours, minutes, seconds, ms){
|
|||
}
|
||||
|
||||
|
||||
//the following values are normally generated by the sputnik.py driver
|
||||
// for now, we'll just use 0 for everything
|
||||
var $LocalTZ=0;
|
||||
var $DST_start_month=0;
|
||||
var $DST_start_sunday=0;
|
||||
var $DST_start_hour=0;
|
||||
var $DST_start_minutes=0;
|
||||
var $DST_end_month=0;
|
||||
var $DST_end_sunday=0;
|
||||
var $DST_end_hour=0;
|
||||
var $DST_end_minutes=0;
|
||||
|
||||
/**** Python code for initialize the above constants
|
||||
// We may want to replicate the following in JavaScript.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
/*
|
||||
sth: Simple Test Harness
|
||||
*/
|
||||
sth.prototype.matchTestPath = function(filePath) {
|
||||
sth.prototype.matchTestPath = function (filePath) {
|
||||
var cannonicalPath = filePath.slice(filePath.indexOf('TestCases'));
|
||||
var possibleMatch = this.testsByPath[cannonicalPath];
|
||||
if (possibleMatch) return possibleMatch;
|
||||
|
@ -31,99 +31,190 @@ sth.prototype.matchTestPath = function(filePath) {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
function sth(globalObj) {
|
||||
//private variables of this object/class
|
||||
var callback,
|
||||
scriptLoadTimer,
|
||||
testRunTimer,
|
||||
stopCommand,
|
||||
tests,
|
||||
buffer,
|
||||
cachedGlobal,
|
||||
globalState,
|
||||
totalTestsRun,
|
||||
totalTestsPassed,
|
||||
totalTestsFailed,
|
||||
failedTestCases,
|
||||
allScriptTagsInjected,
|
||||
testCasePaths,
|
||||
possibleTestScripts,
|
||||
totalTestCases,
|
||||
executionCount,
|
||||
failedToLoad,
|
||||
loaderIframe,
|
||||
xmlListLoaded,
|
||||
xmlTestsLoaded,
|
||||
aryTestCasePaths,
|
||||
aryTestGroups,
|
||||
failToLoadTests,
|
||||
toublesomeTest,
|
||||
requestPending;
|
||||
|
||||
//constants
|
||||
var LOAD_TIMER_PERIOD = 20,
|
||||
RUN_TIMER_PERIOD = 20,
|
||||
DEFER_STOP_COUNT = 10,
|
||||
DEFER_CHECK_TIMER_PERIOD = 50,
|
||||
TESTLISTPATH = "resources/scripts/testcases/testcaseslist.xml";
|
||||
RUN_TIMER_PERIOD = 20,
|
||||
DEFER_STOP_COUNT = 10,
|
||||
DEFER_CHECK_TIMER_PERIOD = 50,
|
||||
TEST_LIST_PATH = "resources/scripts/testcases/testcaseslist.xml";
|
||||
|
||||
//private variables of this object/class
|
||||
var callback,
|
||||
scriptLoadTimer,
|
||||
testRunTimer,
|
||||
toublesomeTest,
|
||||
requestPending,
|
||||
globalState;
|
||||
var stopCommand = false;
|
||||
//It is an array that stores all the chapters' test cases when registerTest function is called.
|
||||
//It is used later to retrieve the count of total test cases.
|
||||
var tests = [];
|
||||
//It is an array that stores all the chapters' test cases when registerTest function is called.
|
||||
//It is used later to retrieve the test case to run unit test on it.
|
||||
var buffer = [];
|
||||
var cachedGlobal = globalObj;
|
||||
var totalTestsRun = 0;
|
||||
var totalTestsPassed = 0;
|
||||
var totalTestsFailed = 0;
|
||||
var failedTestCases = [];
|
||||
var allScriptTagsInjected = false;
|
||||
var testCasePaths = [];
|
||||
var possibleTestScripts = 0;
|
||||
var totalTestCases = 0;
|
||||
var executionCount = 0;
|
||||
var failedToLoad = 0;
|
||||
var loaderIframe = null;
|
||||
var xmlListLoaded = false;
|
||||
var xmlTestsLoaded = false;
|
||||
var aryTestCasePaths = [];
|
||||
//It stores all the main xml path
|
||||
var aryTestGroups = [];
|
||||
//It also stores all the main xml path for buffer
|
||||
var aryTestGroupsBuffer = [];
|
||||
var failToLoadTests = [];
|
||||
|
||||
var cachedProperties = [
|
||||
'undefined',
|
||||
'NaN',
|
||||
'Infinity',
|
||||
'Object',
|
||||
'Object.prototype',
|
||||
'Object.prototype.toString',
|
||||
'Array',
|
||||
'Array.prototype',
|
||||
'Array.prototype.toString',
|
||||
'Function',
|
||||
'Function.prototype',
|
||||
'Function.prototype.toString',
|
||||
'String',
|
||||
'String.prototype',
|
||||
'String.prototype.toString',
|
||||
'String.fromCharCode',
|
||||
'Number',
|
||||
'Number.prototype.toString',
|
||||
'Boolean',
|
||||
'Boolean.prototype.toString',
|
||||
'RegExp',
|
||||
'RegExp.prototype',
|
||||
'RegExp.prototype.toString',
|
||||
'Math',
|
||||
'Error',
|
||||
'Error.prototype',
|
||||
'Error.prototype.toString',
|
||||
'eval',
|
||||
'parseInt',
|
||||
'parseFloat',
|
||||
'isNaN',
|
||||
'isFinite',
|
||||
'EvalError',
|
||||
'RangeError',
|
||||
'ReferenceError',
|
||||
'SyntaxError',
|
||||
'TypeError',
|
||||
'URIError',
|
||||
'Date',
|
||||
'Date.prototype',
|
||||
'Date.UTC',
|
||||
'Date.parse',
|
||||
'Date.prototype.toLocaleTimeString',
|
||||
'Date.prototype.toTimeString',
|
||||
'Date.prototype.toTimeString',
|
||||
'Date.prototype.valueOf',
|
||||
'Date.prototype.toString',
|
||||
'Date.prototype.toLocaleString',
|
||||
'Date.prototype.toDateString',
|
||||
'Date.prototype.constructor',
|
||||
'Date.prototype.getFullYear',
|
||||
'Date.prototype.getUTCFullYear',
|
||||
'Date.prototype.getMonth',
|
||||
'Date.prototype.getUTCMonth',
|
||||
'Date.prototype.getTime',
|
||||
'Date.prototype.getDate',
|
||||
'Date.prototype.getUTCDate',
|
||||
'Date.prototype.getUTCDay',
|
||||
'Date.prototype.getDay',
|
||||
'Date.prototype.getUTCHours',
|
||||
'Date.prototype.getHours',
|
||||
'Date.prototype.getMinutes',
|
||||
'Date.prototype.getUTCMinutes',
|
||||
'Date.prototype.getSeconds',
|
||||
'Date.prototype.getUTCSeconds',
|
||||
'Date.prototype.getMilliseconds',
|
||||
'Date.prototype.getUTCMilliseconds',
|
||||
'Date.prototype.getTimezoneOffset',
|
||||
'Date.prototype.setFullYear',
|
||||
'Date.prototype.setUTCFullYear',
|
||||
'Date.prototype.setMonth',
|
||||
'Date.prototype.setUTCMonth',
|
||||
'Date.prototype.setTime',
|
||||
'Date.prototype.setDate',
|
||||
'Date.prototype.setUTCDate',
|
||||
'Date.prototype.setUTCDay',
|
||||
'Date.prototype.setDay',
|
||||
'Date.prototype.setUTCHours',
|
||||
'Date.prototype.setHours',
|
||||
'Date.prototype.setMinutes',
|
||||
'Date.prototype.setUTCMinutes',
|
||||
'Date.prototype.setSeconds',
|
||||
'Date.prototype.setUTCSeconds',
|
||||
'Date.prototype.setMilliseconds',
|
||||
'Date.prototype.setUTCMilliseconds',
|
||||
'Date.prototype.toUTCString',
|
||||
'Date.prototype.toISOString',
|
||||
'Date.prototype.toJSON',
|
||||
'Date.prototype.toLocaleDateString'
|
||||
]
|
||||
|
||||
aryTestCasePaths = [];
|
||||
aryTestGroups = [];
|
||||
failToLoadTests = [];
|
||||
stopCommand = false;
|
||||
xmlListLoaded = false;
|
||||
xmlTestsLoaded = false;
|
||||
tests = [];
|
||||
buffer = [];
|
||||
totalTestsRun = 0;
|
||||
totalTestsPassed = 0;
|
||||
totalTestsFailed = 0;
|
||||
failedTestCases = [];
|
||||
allScriptTagsInjected = false;
|
||||
testCasePaths = []; ;
|
||||
possibleTestScripts = 0;
|
||||
totalTestCases = 0;
|
||||
executionCount = 0;
|
||||
loaderIframe = null;
|
||||
cachedGlobal = globalObj;
|
||||
failedToLoad = 0;
|
||||
globalState = {};
|
||||
|
||||
globalState = {
|
||||
undefined: cachedGlobal.undefined,
|
||||
NaN: cachedGlobal.NaN,
|
||||
Infinity: cachedGlobal.Infinity,
|
||||
Object: cachedGlobal.Object,
|
||||
Array: cachedGlobal.Array,
|
||||
Function: cachedGlobal.Function,
|
||||
String: cachedGlobal.String,
|
||||
Number: cachedGlobal.Number,
|
||||
Boolean: cachedGlobal.Boolean,
|
||||
RegExp: cachedGlobal.RegExp,
|
||||
Math: cachedGlobal.Math,
|
||||
Error: cachedGlobal.Error,
|
||||
eval: cachedGlobal.eval,
|
||||
parseInt: cachedGlobal.parseInt,
|
||||
parseFloat: cachedGlobal.parseFloat,
|
||||
isNaN: cachedGlobal.isNaN,
|
||||
isFinite: cachedGlobal.isFinite,
|
||||
EvalError: cachedGlobal.EvalError,
|
||||
RangeError: cachedGlobal.RangeError,
|
||||
ReferenceError: cachedGlobal.ReferenceError,
|
||||
SyntaxError: cachedGlobal.SyntaxError,
|
||||
TypeError: cachedGlobal.TypeError,
|
||||
URIError: cachedGlobal.URIError
|
||||
var tokens;
|
||||
var base;
|
||||
var prop;
|
||||
|
||||
for (var i = 0; i < cachedProperties.length; i++) {
|
||||
tokens = cachedProperties[i].split(".");
|
||||
base = cachedGlobal;
|
||||
|
||||
while (tokens.length > 1)
|
||||
base = base[tokens.shift()];
|
||||
|
||||
prop = tokens.shift();
|
||||
|
||||
globalState[cachedProperties[i]] = base[prop];
|
||||
}
|
||||
|
||||
//private methods
|
||||
function clearTimers() {
|
||||
window.clearTimeout(scriptLoadTimer);
|
||||
window.clearTimeout(testRunTimer);
|
||||
}
|
||||
|
||||
|
||||
var currentTestId;
|
||||
|
||||
function restoreGlobals() {
|
||||
for (var prop in globalState)
|
||||
if (cachedGlobal[prop] !== globalState[prop]) cachedGlobal[prop] = globalState[prop];
|
||||
var tokens;
|
||||
var base;
|
||||
var prop;
|
||||
|
||||
for (var key in globalState) {
|
||||
tokens = key.split(".");
|
||||
base = cachedGlobal;
|
||||
|
||||
while (tokens.length > 1) {
|
||||
prop = tokens.shift();
|
||||
base = base[prop];
|
||||
}
|
||||
|
||||
prop = tokens.shift();
|
||||
|
||||
if (base[prop] === base[prop] && base[prop] !== globalState[key])
|
||||
{
|
||||
base[prop] = globalState[key];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function htmlEscape(str) {
|
||||
|
@ -152,27 +243,95 @@ function sth(globalObj) {
|
|||
var t = new sth_test(to);
|
||||
t.registrationIndex = tests.length;
|
||||
tests.push(t);
|
||||
buffer.push(t);
|
||||
buffer.push(t);
|
||||
}
|
||||
|
||||
this.run = function() {
|
||||
//If user enters chapter index, it sets the aryTestGroups, tests, buffer and initialize the subsections
|
||||
//If user enters nothing, it executes all the test cases
|
||||
this.setChapter = function () {
|
||||
aryTestGroups = CloneArray(aryTestGroupsBuffer);
|
||||
aryTestGroups.numTests = aryTestGroupsBuffer.numTests;
|
||||
var userInputChapterIndex = $.trim($("#chapterId").val());
|
||||
|
||||
tests = [];
|
||||
buffer = [];
|
||||
|
||||
//Initialize the subSections
|
||||
for (var secInd = 0; secInd < sections.length; secInd++) {
|
||||
for (var subSecInd = 0; subSecInd < sections[secInd].subSections.length; subSecInd++) {
|
||||
sections[secInd].subSections[subSecInd].total = 0;
|
||||
sections[secInd].subSections[subSecInd].passed = 0;
|
||||
sections[secInd].subSections[subSecInd].failed = 0;
|
||||
}
|
||||
}
|
||||
$(".results-data-table").html("");
|
||||
stopCommand = false;
|
||||
|
||||
if (callback) {
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{
|
||||
totalTestsRun: 0,
|
||||
totalTestsFailed: 0,
|
||||
totalTestsPassed: 0,
|
||||
totalTestsToRun: 0,
|
||||
failedTestCases: 0,
|
||||
totalTestsLoaded: 0,
|
||||
failedToLoad: 0,
|
||||
totalTestCasesForProgressBar: 0,
|
||||
nextActivity: ""
|
||||
});
|
||||
}
|
||||
|
||||
if (userInputChapterIndex !== "") {
|
||||
var mapedChapterIndex = null;
|
||||
for (var chapterIndex = 0; chapterIndex < aryTestGroups.length; chapterIndex++) {
|
||||
if (chapterIndex === parseInt(userInputChapterIndex)) {
|
||||
mapedChapterIndex = chapterIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapedChapterIndex !== null) {
|
||||
aryTestGroups = [];
|
||||
aryTestGroups[0] = aryTestGroupsBuffer[mapedChapterIndex];
|
||||
aryTestGroups.numTests = aryTestGroupsBuffer.numTests;
|
||||
}
|
||||
else {
|
||||
$("#resultMessage").show();
|
||||
alert("Chapter index is not valid. Please keep blank for execution of all the test cases or enter correct index");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this.run = function ()
|
||||
{
|
||||
var ut = undefined; // a particular unittest
|
||||
var res = false; // the result of running the unittest
|
||||
var prereq = undefined; // any prerequisite specified by the unittest
|
||||
var pres = true; // the result of running that prerequite
|
||||
var regEx2 = /^[sS]?[0-9]{1,2}([.]?[0-9]{1,2}){0,2}/gi;
|
||||
var alphaNumericWithDot = /^[sS]?[0-9]{1,2}([.]?[0-9]{1,2}){0,2}/gi;
|
||||
var holdArray;
|
||||
var subsectionId;
|
||||
var chapterId;
|
||||
|
||||
ut = buffer.shift();
|
||||
if (!ut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
executionCount++;
|
||||
//this.currentTest = ut;
|
||||
|
||||
|
||||
if (callback) callback(
|
||||
if (callback)
|
||||
{
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{ totalTestsRun: totalTestsRun, //Total run
|
||||
//totalRun : sth.tests.length,
|
||||
totalTestsFailed: totalTestsFailed,
|
||||
|
@ -184,70 +343,86 @@ function sth(globalObj) {
|
|||
totalTestCasesForProgressBar: ((totalTestsRun / totalTestCases) * 100) < 99 ? totalTestCases : tests.length,
|
||||
nextActivity: "executing ... " + ut.id
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// if the test specifies a prereq, run that.
|
||||
pre = ut.pre;
|
||||
pres = true;
|
||||
if (pre !== undefined) {
|
||||
try {
|
||||
currentTestId = ut.id;
|
||||
if (pre !== undefined)
|
||||
{
|
||||
try
|
||||
{
|
||||
pres = pre.call(ut);
|
||||
restoreGlobals();
|
||||
if (pres !== true) {
|
||||
if (pres !== true)
|
||||
{
|
||||
ut.res = 'Precondition failed';
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e)
|
||||
{
|
||||
restoreGlobals();
|
||||
pres = false;
|
||||
ut.res = 'Precondition failed with exception: ' + e.description;
|
||||
var errDes = (e.message) ? e.message : e.description;
|
||||
ut.res = 'Precondition failed with exception: ' + errDes;
|
||||
}
|
||||
}
|
||||
|
||||
//read the chapter id and sub section id by spliting the testcase id
|
||||
match2 = ut.id.match(regEx2);
|
||||
match2 = ut.id.match(alphaNumericWithDot);
|
||||
subsectionId = match2[0];
|
||||
if (match2[0].toLowerCase().indexOf('s') != -1) {
|
||||
if (match2[0].toLowerCase().indexOf('s') != -1)
|
||||
{
|
||||
subsectionId = subsectionId.substring(1);
|
||||
}
|
||||
holdArray = subsectionId.split(".");
|
||||
chapterId = holdArray[0] - SECTION_TOC_OFFSET;
|
||||
addCountToSection(subsectionId, "total");
|
||||
// if the prereq is met, run the testcase now.
|
||||
if (pres === true) {
|
||||
try {
|
||||
if (pres === true)
|
||||
{
|
||||
try
|
||||
{
|
||||
res = ut.theTestcase.call(ut.testObj);
|
||||
restoreGlobals();
|
||||
if (res === true || res === undefined) {
|
||||
if (res === true || res === undefined)
|
||||
{
|
||||
ut.res = 'pass';
|
||||
totalTestsPassed++;
|
||||
addCountToSection(subsectionId, "passed");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ut.res = 'fail';
|
||||
totalTestsFailed++;
|
||||
failedTestCases[failedTestCases.length] = ut;
|
||||
addCountToSection(subsectionId, "failed");
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
catch (e)
|
||||
{
|
||||
restoreGlobals();
|
||||
ut.res = 'failed with exception: ' + e.description;
|
||||
var errDes = (e.message) ? e.message : e.description;
|
||||
ut.res = 'failed with exception: ' + errDes;
|
||||
totalTestsFailed++;
|
||||
failedTestCases[failedTestCases.length] = ut;
|
||||
addCountToSection(subsectionId, "failed");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
totalTestsFailed++;
|
||||
failedTestCases[failedTestCases.length] = ut;
|
||||
addCountToSection(subsectionId, "failed");
|
||||
}
|
||||
if (holdArray.length > 1) {
|
||||
if (holdArray.length == 3 & existsSection(subsectionId)) {
|
||||
if (holdArray.length > 1)
|
||||
{
|
||||
if (holdArray.length === 3 & existsSection(subsectionId))
|
||||
{
|
||||
sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1].testCaseArray[sections[chapterId].subSections[holdArray[1] - 1].subSections[holdArray[2] - 1].testCaseArray.length] = ut;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sections[chapterId].subSections[holdArray[1] - 1].testCaseArray[sections[chapterId].subSections[holdArray[1] - 1].testCaseArray.length] = ut;
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +433,7 @@ function sth(globalObj) {
|
|||
}
|
||||
|
||||
|
||||
this.startTesting = function(pageCallback, command) {
|
||||
this.startTesting = function (pageCallback, command) {
|
||||
if (!xmlListLoaded) {
|
||||
this.loadTestList();
|
||||
return;
|
||||
|
@ -273,9 +448,12 @@ function sth(globalObj) {
|
|||
scriptLoader = null;
|
||||
}
|
||||
else {
|
||||
scriptLoader.onreadystatechange = function() {
|
||||
scriptLoader.onreadystatechange = function () {
|
||||
if (scriptLoader.readyState == 4) {
|
||||
if (callback) callback(
|
||||
if (callback) {
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{ totalTestsRun: totalTestsRun, //Total run
|
||||
totalTestsFailed: totalTestsFailed,
|
||||
totalTestsPassed: totalTestsPassed,
|
||||
|
@ -286,14 +464,14 @@ function sth(globalObj) {
|
|||
totalTestCasesForProgressBar: ((totalTestsRun / totalTestCases) * 100) < 99 ? totalTestCases : tests.length,
|
||||
nextActivity: "loading... " + scriptLoader.responseXML.getElementsByTagName("section")[0].getAttribute("name")
|
||||
});
|
||||
|
||||
}
|
||||
try {
|
||||
var j = aryTestCasePaths.length;
|
||||
var newTests = scriptLoader.responseXML.getElementsByTagName("test");
|
||||
|
||||
for (var i = 0; i < newTests.length; i++) {
|
||||
var scriptCode = (newTests[i].firstChild.text != undefined) ? newTests[i].firstChild.text : newTests[i].firstChild.textContent;
|
||||
loaderIframe.append('<script>' + $.base64.decode(scriptCode) + '</script>');
|
||||
loaderIframe.append('<script>' + $.base64Decode(scriptCode) + '</script>');
|
||||
aryTestCasePaths[j++] = newTests[i].getAttribute("id");
|
||||
if (tests[tests.length - 1].id != newTests[i].getAttribute("id")) {
|
||||
failToLoadTests[failToLoadTests.length] = newTests[i].getAttribute("id");
|
||||
|
@ -316,12 +494,12 @@ function sth(globalObj) {
|
|||
totalTestCases = possibleTestScripts = aryTestGroups.numTests;
|
||||
|
||||
switch (command) {
|
||||
case TestConstants.RUNNING:
|
||||
case TestConstants.RESET:
|
||||
case "running":
|
||||
case "reset":
|
||||
if (!testCasePaths.length > 0 && !allScriptTagsInjected) {
|
||||
testCasePaths = aryTestCasePaths.slice(0, aryTestCasePaths.length);
|
||||
} else {
|
||||
buffer = tests.clone();
|
||||
buffer = CloneArray(tests);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -332,8 +510,6 @@ function sth(globalObj) {
|
|||
loaderIframe = $('head'),
|
||||
testPath;
|
||||
|
||||
|
||||
|
||||
function runNextTest() {
|
||||
if (!xmlTestsLoaded) {
|
||||
testRunTimer = setTimeout(runNextTest, RUN_TIMER_PERIOD);
|
||||
|
@ -344,7 +520,11 @@ function sth(globalObj) {
|
|||
testRunTimer = setTimeout(runNextTest, RUN_TIMER_PERIOD);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($("#chapterId").val() !== "") {
|
||||
totalTestCases = tests.length;
|
||||
}
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{ totalTestsRun: totalTestsRun, //Total run
|
||||
//totalRun : sth.tests.length,
|
||||
|
@ -369,18 +549,20 @@ function sth(globalObj) {
|
|||
testRunTimer = setTimeout(runNextTest, DEFER_CHECK_TIMER_PERIOD);
|
||||
return;
|
||||
}
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{ totalTestsRun: totalTestsRun,
|
||||
//totalRun : sth.tests.length,
|
||||
totalTestsFailed: totalTestsFailed,
|
||||
totalTestsPassed: totalTestsPassed,
|
||||
totalTestsToRun: totalTestCases,
|
||||
failedTestCases: failedTestCases,
|
||||
completed: true,
|
||||
failedToLoad: failedToLoad,
|
||||
totalTestCasesForProgressBar: tests.length,
|
||||
totalTestsLoaded: tests.length
|
||||
});
|
||||
{ totalTestsRun: totalTestsRun,
|
||||
//totalRun : sth.tests.length,
|
||||
totalTestsFailed: totalTestsFailed,
|
||||
totalTestsPassed: totalTestsPassed,
|
||||
totalTestsToRun: totalTestCases,
|
||||
failedTestCases: failedTestCases,
|
||||
completed: true,
|
||||
failedToLoad: failedToLoad,
|
||||
totalTestCasesForProgressBar: tests.length,
|
||||
totalTestsLoaded: tests.length
|
||||
});
|
||||
sth.stop();
|
||||
}
|
||||
else if (!stopCommand) {
|
||||
|
@ -391,13 +573,14 @@ function sth(globalObj) {
|
|||
testRunTimer = setTimeout(runNextTest, 0);
|
||||
}
|
||||
|
||||
//This function stops, resets and pauses on the basis of parameter passed to it.
|
||||
this.stop = function(testStatus) {
|
||||
clearTimers();
|
||||
stopCommand = true;
|
||||
var totalTestCasesForProgressBar = tests.length;
|
||||
|
||||
switch (testStatus) {
|
||||
case TestConstants.PAUSED:
|
||||
case "paused":
|
||||
totalTestsRun = totalTestsRun; //Total run
|
||||
totalTestsFailed = totalTestsFailed;
|
||||
totalTestsPassed = totalTestsPassed;
|
||||
|
@ -406,7 +589,7 @@ function sth(globalObj) {
|
|||
totalTestsLoaded = tests.length;
|
||||
totalTestCasesForProgressBar = ((totalTestsRun / totalTestCases) * 100) < 99 ? totalTestCases : tests.length;
|
||||
break;
|
||||
case TestConstants.RESET:
|
||||
case "reset":
|
||||
totalTestsRun = 0; //Total run
|
||||
totalTestsFailed = 0;
|
||||
totalTestsPassed = 0;
|
||||
|
@ -416,7 +599,7 @@ function sth(globalObj) {
|
|||
possibleTestScripts = totalTestCases;
|
||||
loadSections();
|
||||
break;
|
||||
case TestConstants.STOPPED:
|
||||
case "stopped":
|
||||
totalTestsRun = 0;
|
||||
totalTestsPassed = 0;
|
||||
totalTestsFailed = 0;
|
||||
|
@ -425,6 +608,8 @@ function sth(globalObj) {
|
|||
}
|
||||
|
||||
if (typeof callback !== 'undefined' && callback !== null) {
|
||||
//It executes a callback function with an object that contains all the information like total test cases to run, left test cases to run etc.
|
||||
//That updates the information on the UI
|
||||
callback(
|
||||
{ totalTestsRun: totalTestsRun, //Total run
|
||||
totalTestsFailed: totalTestsFailed,
|
||||
|
@ -441,21 +626,25 @@ function sth(globalObj) {
|
|||
this.getAllTests = function() {
|
||||
return tests;
|
||||
}
|
||||
|
||||
this.getFailToLoad = function() {
|
||||
return failToLoadTests;
|
||||
}
|
||||
|
||||
this.decrementTotalScriptCount = function() {
|
||||
failedToLoad++;
|
||||
}
|
||||
|
||||
//It opens the source code for the test case that is run
|
||||
this.openSourceWindow = function(idx) {
|
||||
var ut = tests[idx];
|
||||
var popWnd = window.open("", "", "scrollbars=1, resizable=1");
|
||||
var innerHTML = '';
|
||||
|
||||
innerHTML += '<b>Test </b>';
|
||||
if (ut.id)
|
||||
if (ut.id) {
|
||||
innerHTML += '<b>' + ut.id + '</b> <br /><br />';
|
||||
}
|
||||
|
||||
if (ut.description) {
|
||||
innerHTML += '<b>Description</b>';
|
||||
|
@ -475,6 +664,7 @@ function sth(globalObj) {
|
|||
popWnd.document.write(innerHTML);
|
||||
}
|
||||
|
||||
//It loads all the chapters' xml that contains the informations of test cases
|
||||
this.loadTestList = function(startTest) {
|
||||
var testsListLoader = new XMLHttpRequest();
|
||||
var sth = this;
|
||||
|
@ -482,18 +672,20 @@ function sth(globalObj) {
|
|||
if (testsListLoader.readyState == 4) {
|
||||
oTests = testsListLoader.responseXML.getElementsByTagName('testGroup');
|
||||
var testSuite = testsListLoader.responseXML.getElementsByTagName('testSuite');
|
||||
XML_TARGETTESTSUITEVERSION = testSuite[0].getAttribute("version");
|
||||
XML_TARGETTESTSUITEDATE = testSuite[0].getAttribute("date");
|
||||
|
||||
pageHelper.XML_TARGETTESTSUITEVERSION = testSuite[0].getAttribute("version");
|
||||
pageHelper.XML_TARGETTESTSUITEDATE = testSuite[0].getAttribute("date");
|
||||
//It sets version and date in Run and Result tab. It is called from here so that if user goes directly to Run or Results tab, version and date should reflect.
|
||||
pageHelper.setVersionAndDate();
|
||||
for (var i = 0; i < oTests.length; i++) {
|
||||
aryTestGroups[i] = (oTests[i].text != undefined) ? oTests[i].text : oTests[i].textContent;
|
||||
aryTestGroupsBuffer[i] = (oTests[i].text != undefined) ? oTests[i].text : oTests[i].textContent;
|
||||
}
|
||||
xmlListLoaded = true;
|
||||
aryTestGroups.numTests = testsListLoader.responseXML.getElementsByTagName('testSuite')[0].getAttribute("numTests");
|
||||
aryTestGroupsBuffer.numTests = aryTestGroups.numTests = testsListLoader.responseXML.getElementsByTagName('testSuite')[0].getAttribute("numTests");
|
||||
startTest && sth.startTesting();
|
||||
}
|
||||
};
|
||||
testsListLoader.open("GET", TESTLISTPATH, true);
|
||||
testsListLoader.open("GET", TEST_LIST_PATH, true);
|
||||
testsListLoader.send(null);
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +693,7 @@ function sth(globalObj) {
|
|||
|
||||
|
||||
function sth_test(to, path) {
|
||||
//Create a sth_test from a test definition object, and path
|
||||
//Stores information in sth_test from a test definition object, and path
|
||||
//TODO: Update sth framework to work more directly with test definitiion objects.
|
||||
//this.testObj = to;
|
||||
this.id = to.id;
|
||||
|
@ -518,27 +710,41 @@ activeSth = new sth(window);
|
|||
ES5Harness = activeSth;
|
||||
loadSections();
|
||||
|
||||
function arrayContains(arr, expected) {
|
||||
var found;
|
||||
function compareArray(aExpected, aActual) {
|
||||
if (aActual.length != aExpected.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
found = false;
|
||||
aExpected.sort();
|
||||
aActual.sort();
|
||||
|
||||
for (var j = 0; j < arr.length; j++)
|
||||
if (expected[i] === arr[j]) {
|
||||
found = true;
|
||||
break;
|
||||
var s;
|
||||
for (var i = 0; i < aExpected.length; i++) {
|
||||
if (aActual[i] != aExpected[i]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
return false
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function arrayContains(arr, expected) {
|
||||
var found;
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
found = false;
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
if (expected[i] === arr[j]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var supportsArrayIndexGettersOnArrays = undefined;
|
||||
function fnSupportsArrayIndexGettersOnArrays() {
|
||||
|
@ -562,9 +768,6 @@ function fnSupportsArrayIndexGettersOnArrays() {
|
|||
return supportsArrayIndexGettersOnArrays;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var supportsArrayIndexGettersOnObjects = undefined;
|
||||
function fnSupportsArrayIndexGettersOnObjects() {
|
||||
if (typeof supportsArrayIndexGettersOnObjects !== "undefined")
|
||||
|
@ -604,11 +807,20 @@ function fnExists(f) {
|
|||
var supportsStrict = undefined;
|
||||
function fnSupportsStrict() {
|
||||
"use strict";
|
||||
if (supportsStrict !== undefined) return supportsStrict;
|
||||
try { eval('with ({}) {}'); supportsStrict = false; } catch (e) { supportsStrict = true; };
|
||||
if (supportsStrict !== undefined) {
|
||||
return supportsStrict;
|
||||
}
|
||||
|
||||
try {
|
||||
eval('with ({}) {}');
|
||||
supportsStrict = false;
|
||||
} catch (e) {
|
||||
supportsStrict = true;
|
||||
}
|
||||
return supportsStrict;
|
||||
}
|
||||
|
||||
function fnGlobalObject() {
|
||||
return (function() { return this }).call(null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue