diff options
author | Mark Miller <erights@gmail.com> | 2011-09-13 01:08:50 -0700 |
---|---|---|
committer | Mark Miller <erights@gmail.com> | 2011-09-13 01:08:50 -0700 |
commit | bba34a262ebb3405dacbee9b48cd096c46ccef7c (patch) | |
tree | d2aec21a00394799b063b8ae96350f6285dc277a /test/harness/helper.js | |
parent | 68d44bb52a11ba7a9a2f08ad2ea45e23f0224a7a (diff) |
Reformatted to 80 columns. Inserted missing semicolons. Removed one
bogus semicolon. Except for the bogud semicolon, nothing should have
changed the meaning of the programs.
Diffstat (limited to 'test/harness/helper.js')
-rw-r--r-- | test/harness/helper.js | 106 |
1 files changed, 64 insertions, 42 deletions
diff --git a/test/harness/helper.js b/test/harness/helper.js index a37be4d3f..1e8e5b429 100644 --- a/test/harness/helper.js +++ b/test/harness/helper.js @@ -1,14 +1,14 @@ -/// Copyright (c) 2009 Microsoft Corporation
-///
+/// Copyright (c) 2009 Microsoft Corporation
+///
/// Redistribution and use in source and binary forms, with or without modification, are permitted provided
-/// that the following conditions are met:
+/// that the following conditions are met:
/// * Redistributions of source code must retain the above copyright notice, this list of conditions and
-/// the following disclaimer.
-/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
-/// the following disclaimer in the documentation and/or other materials provided with the distribution.
+/// the following disclaimer.
+/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+/// the following disclaimer in the documentation and/or other materials provided with the distribution.
/// * Neither the name of Microsoft nor the names of its contributors may be used to
/// endorse or promote products derived from this software without specific prior written permission.
-///
+///
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
/// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
/// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
@@ -16,7 +16,7 @@ /// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
/// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Handles updating the page with information from the runner. */
function Presenter() {
@@ -31,11 +31,12 @@ function Presenter() { globalSection = new Section(null, "0", "ECMA-262"),
currentSection = globalSection,
tests = {},
- totalTests = 0;
+ totalTests = 0,
+
+ TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml",
+ activityBar;
- TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml";
-
/* Load the table of contents xml to populate the sections. */
function loadSections() {
var sectionsLoader = new XMLHttpRequest();
@@ -54,8 +55,11 @@ function Presenter() { for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeName === "sec") {
- subsection = new Section(parentSection, nodes[i].getAttribute('id'), nodes[i].getAttribute('name'));
- parentSection.subsections[subsection.id.match(/\d+$/)] = subsection;
+ subsection = new Section(parentSection,
+ nodes[i].getAttribute('id'),
+ nodes[i].getAttribute('name'));
+ parentSection.subsections[subsection.id.match(/\d+$/)] =
+ subsection;
addSectionsFromXML(nodes[i].childNodes, subsection);
}
}
@@ -93,7 +97,8 @@ function Presenter() { var current = currentSection;
// Walk backwards until we reach the global section.
- while(current !== globalSection && current.parentSection !== globalSection) {
+ while(current !== globalSection &&
+ current.parentSection !== globalSection) {
sectionChain.push(current);
current = current.parentSection;
}
@@ -106,12 +111,14 @@ function Presenter() { // Static first link to go back to the root.
var link = $("<a href='#0' class='setBlack'>Test Sections > </a>");
- link.bind('click', {sectionId: 0}, sectionSelected)
+ link.bind('click', {sectionId: 0}, sectionSelected);
container.append(link);
for(var i = 0; i < sectionChain.length;i++) {
- link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" + sectionChain[i].id + ": " + sectionChain[i].name + " > </a>");
- link.bind('click', sectionSelected)
+ link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" +
+ sectionChain[i].id + ": " + sectionChain[i].name +
+ " > </a>");
+ link.bind('click', sectionSelected);
container.append(link);
}
@@ -134,7 +141,9 @@ function Presenter() { if (test.description) {
innerHTML += '<b>Description</b>';
- innerHTML += '<pre>' + test.description.replace(/</g, '<').replace(/>/g, '>'); +' </pre>';
+ innerHTML += '<pre>' +
+ test.description.replace(/</g, '<').replace(/>/g, '>') +
+ ' </pre>';
}
innerHTML += '<br /><br /><br /><b>Testcase</b>';
@@ -150,30 +159,34 @@ function Presenter() { popWnd.document.write(innerHTML);
}
-
+
/* Pops up a window with an xml dump of the results of a test. */
function createXMLReportWindow() {
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
+ var xml; // stop condition of for loop stored in a local
+ // variable to improve performance
dateNow = new Date();
xml = '<testRun>\r\n' +
'<userAgent>' + window.navigator.userAgent + '</userAgent>\r\n' +
- '<Date>' + dateNow.toDateString() + '</Date>\r\n' +
- '<targetTestSuiteName>ECMAScript Test262 Site</targetTestSuiteName>\r\n' +
- '<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' +
- '<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' +
- ' <Tests>\r\n\r\n';
+ '<Date>' + dateNow.toDateString() + '</Date>\r\n' +
+ '<targetTestSuiteName>ECMAScript Test262 Site' +
+ '</targetTestSuiteName>\r\n' +
+ '<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' +
+ '<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' +
+ ' <Tests>\r\n\r\n';
reportWindow = window.open();
reportWindow.document.writeln("<title>ECMAScript Test262 XML</title>");
- reportWindow.document.write("<textarea id='results' style='width: 100%; height: 800px;'>");
+ reportWindow.document.write(
+ "<textarea id='results' style='width: 100%; height: 800px;'>");
reportWindow.document.write(xml);
reportWindow.document.write(globalSection.toXML());
- reportWindow.document.write('</Tests>\r\n</testRun>\r\n</textarea>\r\n');
+ reportWindow.document.write(
+ '</Tests>\r\n</testRun>\r\n</textarea>\r\n');
reportWindow.document.close();
}
@@ -194,7 +207,8 @@ function Presenter() { currentSection = currentSection.parentSection;
- // Since users click directly on sub-chapters of the main chapters, don't go back to main
+ // Since users click directly on sub-chapters of the main
+ // chapters, don't go back to main
// chapters.
if(currentSection.parentSection === globalSection)
currentSection = globalSection;
@@ -202,7 +216,9 @@ function Presenter() { renderCurrentSection();
}
- /* Returns the section object for the specified section id (eg. "7.1" or "15.4.4.12"). */
+ /* Returns the section object for the specified section id
+ * (eg. "7.1" or "15.4.4.12").
+ */
function getSectionById(id) {
if(id == 0)
return globalSection;
@@ -235,7 +251,11 @@ function Presenter() { /* Append a result to the run page's result log. */
function logResult(test) {
altStyle = (altStyle !== ' ') ? ' ' : 'alternate';
- var appendStr = '<tbody><tr class=\"' + altStyle + '\"><td width=\"20%\">' + "<a class='showSource' href='#" + test.id + "'>" + test.id + "</a>" + '</td><td>' + test.description + '</td><td align="right"><span class=\"Fail\">' + test.result + '</span></td></tr></tbody>';
+ var appendStr = '<tbody><tr class=\"' + altStyle +
+ '\"><td width=\"20%\">' + "<a class='showSource' href='#" +
+ test.id + "'>" + test.id + "</a>" + '</td><td>' +
+ test.description + '</td><td align="right"><span class=\"Fail\">' +
+ test.result + '</span></td></tr></tbody>';
logger.append(appendStr);
logger.parent().attr("scrollTop", logger.parent().attr("scrollHeight"));
}
@@ -246,19 +266,21 @@ function Presenter() { this.setTotalTests = function(tests) {
totalTests = tests;
$('#testsToRun').text(tests);
- }
+ };
this.setVersion = function(v) {
version = v;
$(".targetTestSuiteVersion").text(v);
- }
+ };
this.setDate = function(d) {
date = d;
$(".targetTestSuiteDate").text(d);
- }
+ };
- /* Updates progress with the given test, which should have its results in it as well. */
+ /* Updates progress with the given test, which should have its
+ * results in it as well.
+ */
this.addTestResult = function(test) {
tests[test.id] = test;
getSectionById(test.id).addTest(test);
@@ -268,15 +290,15 @@ function Presenter() { if(test.result === 'fail')
logResult(test);
- }
+ };
this.started = function () {
$('.button-start').attr('src', 'resources/images/pause.png');
- }
+ };
this.paused = function () {
$('.button-start').attr('src', 'resources/images/resume.png');
- }
+ };
this.reset = function() {
globalSection.reset();
@@ -285,7 +307,7 @@ function Presenter() { currentSection = globalSection;
renderCurrentSection();
- }
+ };
this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png');
@@ -294,17 +316,17 @@ function Presenter() { } else {
activityBar.text('');
}
- }
+ };
/* Refresh display of the report */
this.refresh = function() {
renderCurrentSection();
- }
+ };
/* Write status to the activity bar. */
this.updateStatus = function(str) {
activityBar.text(str);
- }
+ };
/* Do some setup tasks. */
this.setup = function() {
@@ -316,7 +338,7 @@ function Presenter() { activityBar = $('#nextActivity');
$('a.showSource', logger).live("click", openSourceWindow);
$('#ancGenXMLReport').click(createXMLReportWindow);
- }
+ };
}
var presenter = new Presenter();
|