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.
This commit is contained in:
Mark Miller 2011-09-13 01:08:50 -07:00
parent 68d44bb52a
commit bba34a262e
5 changed files with 295 additions and 136 deletions

View File

@ -31,9 +31,10 @@ function Presenter() {
globalSection = new Section(null, "0", "ECMA-262"), globalSection = new Section(null, "0", "ECMA-262"),
currentSection = globalSection, currentSection = globalSection,
tests = {}, tests = {},
totalTests = 0; totalTests = 0,
TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml"; TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml",
activityBar;
/* Load the table of contents xml to populate the sections. */ /* Load the table of contents xml to populate the sections. */
@ -54,8 +55,11 @@ function Presenter() {
for (var i = 0; i < nodes.length; i++) { for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeName === "sec") { if (nodes[i].nodeName === "sec") {
subsection = new Section(parentSection, nodes[i].getAttribute('id'), nodes[i].getAttribute('name')); subsection = new Section(parentSection,
parentSection.subsections[subsection.id.match(/\d+$/)] = subsection; nodes[i].getAttribute('id'),
nodes[i].getAttribute('name'));
parentSection.subsections[subsection.id.match(/\d+$/)] =
subsection;
addSectionsFromXML(nodes[i].childNodes, subsection); addSectionsFromXML(nodes[i].childNodes, subsection);
} }
} }
@ -93,7 +97,8 @@ function Presenter() {
var current = currentSection; var current = currentSection;
// Walk backwards until we reach the global section. // Walk backwards until we reach the global section.
while(current !== globalSection && current.parentSection !== globalSection) { while(current !== globalSection &&
current.parentSection !== globalSection) {
sectionChain.push(current); sectionChain.push(current);
current = current.parentSection; current = current.parentSection;
} }
@ -106,12 +111,14 @@ function Presenter() {
// Static first link to go back to the root. // Static first link to go back to the root.
var link = $("<a href='#0' class='setBlack'>Test Sections &gt; </a>"); var link = $("<a href='#0' class='setBlack'>Test Sections &gt; </a>");
link.bind('click', {sectionId: 0}, sectionSelected) link.bind('click', {sectionId: 0}, sectionSelected);
container.append(link); container.append(link);
for(var i = 0; i < sectionChain.length;i++) { for(var i = 0; i < sectionChain.length;i++) {
link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" + sectionChain[i].id + ": " + sectionChain[i].name + " &gt; </a>"); link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" +
link.bind('click', sectionSelected) sectionChain[i].id + ": " + sectionChain[i].name +
" &gt; </a>");
link.bind('click', sectionSelected);
container.append(link); container.append(link);
} }
@ -134,7 +141,9 @@ function Presenter() {
if (test.description) { if (test.description) {
innerHTML += '<b>Description</b>'; innerHTML += '<b>Description</b>';
innerHTML += '<pre>' + test.description.replace(/</g, '&lt;').replace(/>/g, '&gt;'); +' </pre>'; innerHTML += '<pre>' +
test.description.replace(/</g, '&lt;').replace(/>/g, '&gt;') +
' </pre>';
} }
innerHTML += '<br /><br /><br /><b>Testcase</b>'; innerHTML += '<br /><br /><br /><b>Testcase</b>';
@ -156,24 +165,28 @@ function Presenter() {
var reportWindow; //window that will output the xml data var reportWindow; //window that will output the xml data
var xmlData; //array instead of string concatenation var xmlData; //array instead of string concatenation
var dateNow; 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(); dateNow = new Date();
xml = '<testRun>\r\n' + xml = '<testRun>\r\n' +
'<userAgent>' + window.navigator.userAgent + '</userAgent>\r\n' + '<userAgent>' + window.navigator.userAgent + '</userAgent>\r\n' +
'<Date>' + dateNow.toDateString() + '</Date>\r\n' + '<Date>' + dateNow.toDateString() + '</Date>\r\n' +
'<targetTestSuiteName>ECMAScript Test262 Site</targetTestSuiteName>\r\n' + '<targetTestSuiteName>ECMAScript Test262 Site' +
'<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' + '</targetTestSuiteName>\r\n' +
'<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' + '<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' +
' <Tests>\r\n\r\n'; '<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' +
' <Tests>\r\n\r\n';
reportWindow = window.open(); reportWindow = window.open();
reportWindow.document.writeln("<title>ECMAScript Test262 XML</title>"); 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(xml);
reportWindow.document.write(globalSection.toXML()); 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(); reportWindow.document.close();
} }
@ -194,7 +207,8 @@ function Presenter() {
currentSection = currentSection.parentSection; 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. // chapters.
if(currentSection.parentSection === globalSection) if(currentSection.parentSection === globalSection)
currentSection = globalSection; currentSection = globalSection;
@ -202,7 +216,9 @@ function Presenter() {
renderCurrentSection(); 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) { function getSectionById(id) {
if(id == 0) if(id == 0)
return globalSection; return globalSection;
@ -235,7 +251,11 @@ function Presenter() {
/* Append a result to the run page's result log. */ /* Append a result to the run page's result log. */
function logResult(test) { function logResult(test) {
altStyle = (altStyle !== ' ') ? ' ' : 'alternate'; 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.append(appendStr);
logger.parent().attr("scrollTop", logger.parent().attr("scrollHeight")); logger.parent().attr("scrollTop", logger.parent().attr("scrollHeight"));
} }
@ -246,19 +266,21 @@ function Presenter() {
this.setTotalTests = function(tests) { this.setTotalTests = function(tests) {
totalTests = tests; totalTests = tests;
$('#testsToRun').text(tests); $('#testsToRun').text(tests);
} };
this.setVersion = function(v) { this.setVersion = function(v) {
version = v; version = v;
$(".targetTestSuiteVersion").text(v); $(".targetTestSuiteVersion").text(v);
} };
this.setDate = function(d) { this.setDate = function(d) {
date = d; date = d;
$(".targetTestSuiteDate").text(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) { this.addTestResult = function(test) {
tests[test.id] = test; tests[test.id] = test;
getSectionById(test.id).addTest(test); getSectionById(test.id).addTest(test);
@ -268,15 +290,15 @@ function Presenter() {
if(test.result === 'fail') if(test.result === 'fail')
logResult(test); logResult(test);
} };
this.started = function () { this.started = function () {
$('.button-start').attr('src', 'resources/images/pause.png'); $('.button-start').attr('src', 'resources/images/pause.png');
} };
this.paused = function () { this.paused = function () {
$('.button-start').attr('src', 'resources/images/resume.png'); $('.button-start').attr('src', 'resources/images/resume.png');
} };
this.reset = function() { this.reset = function() {
globalSection.reset(); globalSection.reset();
@ -285,7 +307,7 @@ function Presenter() {
currentSection = globalSection; currentSection = globalSection;
renderCurrentSection(); renderCurrentSection();
} };
this.finished = function(elapsed) { this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png'); $('.button-start').attr('src', 'resources/images/start.png');
@ -294,17 +316,17 @@ function Presenter() {
} else { } else {
activityBar.text(''); activityBar.text('');
} }
} };
/* Refresh display of the report */ /* Refresh display of the report */
this.refresh = function() { this.refresh = function() {
renderCurrentSection(); renderCurrentSection();
} };
/* Write status to the activity bar. */ /* Write status to the activity bar. */
this.updateStatus = function(str) { this.updateStatus = function(str) {
activityBar.text(str); activityBar.text(str);
} };
/* Do some setup tasks. */ /* Do some setup tasks. */
this.setup = function() { this.setup = function() {
@ -316,7 +338,7 @@ function Presenter() {
activityBar = $('#nextActivity'); activityBar = $('#nextActivity');
$('a.showSource', logger).live("click", openSourceWindow); $('a.showSource', logger).live("click", openSourceWindow);
$('#ancGenXMLReport').click(createXMLReportWindow); $('#ancGenXMLReport').click(createXMLReportWindow);
} };
} }
var presenter = new Presenter(); var presenter = new Presenter();

View File

@ -57,16 +57,20 @@ function Section(parentSection, id, name) {
} }
return Math.round((this.totalPassed / this.totalTests) * 100); return Math.round((this.totalPassed / this.totalTests) * 100);
} };
/* Add a test result to this section. Pushes the result to the test array and passes the result to addTestResult to /* Add a test result to this section. Pushes the result to the
* tabulate pass/fail numbers*/ * test array and passes the result to addTestResult to tabulate
* pass/fail numbers
*/
this.addTest = function(test) { this.addTest = function(test) {
this.tests.push(test); this.tests.push(test);
this.addTestResult(test); this.addTestResult(test);
} };
/* Increments the various rollup counters for this section and all parent sections */ /* Increments the various rollup counters for this section and all
* parent sections
*/
this.addTestResult = function(test) { this.addTestResult = function(test) {
this.totalTests++; this.totalTests++;
@ -80,7 +84,7 @@ function Section(parentSection, id, name) {
if(this.parentSection !== null) if(this.parentSection !== null)
this.parentSection.addTestResult(test); this.parentSection.addTestResult(test);
} };
/* Renders this section as HTML. Used for the report page.*/ /* Renders this section as HTML. Used for the report page.*/
this.toHTML = function(options) { this.toHTML = function(options) {
@ -103,8 +107,10 @@ function Section(parentSection, id, name) {
test = this.tests[i]; test = this.tests[i];
html += "<tr><td>" + test.id + "</td>" + html += "<tr><td>" + test.id + "</td>" +
"<td>" + test.description + "</td>" + "<td>" + test.description + "</td>" +
"<td><a class='showSource' href='#" + test.id + "'>[source]</a></td>" + "<td><a class='showSource' href='#" + test.id +
"<td class='" + test.result + "'>" + test.result + "</td></tr>" "'>[source]</a></td>" +
"<td class='" + test.result + "'>" + test.result +
"</td></tr>";
} }
for(var sectionId in this.subsections) { for(var sectionId in this.subsections) {
@ -112,22 +118,29 @@ function Section(parentSection, id, name) {
if(section.totalTests > 0) { if(section.totalTests > 0) {
if(options.renderSubsections) { if(options.renderSubsections) {
html += section.toHTML({header: true, renderSubsections: false}) html += section.toHTML({
header: true,
renderSubsections: false});
} else { } else {
html += "<tr><td colspan='3'><a class='section' href='#" + section.id + "'>Chapter " + section.id + " - " + section.name + "</a></td>" + html += "<tr><td colspan='3'><a class='section' href='#" +
"<td class='" + rollupCellClass(section.passPercent()) + "'>" + section.passPercent() + "%</td></tr>"; section.id + "'>Chapter " + section.id + " - " +
section.name + "</a></td>" +
"<td class='" +
rollupCellClass(section.passPercent()) + "'>" +
section.passPercent() + "%</td></tr>";
} }
} }
} }
return html + "</tbody>"; return html + "</tbody>";
} };
/* Render this section as XML. Used for the report page. */ /* Render this section as XML. Used for the report page. */
this.toXML = function() { this.toXML = function() {
var xml = ""; var xml = "";
if(this.id != 0) { if(this.id != 0) {
xml += "<section id='" + this.id + "' name='" + this.name + "'>\r\n"; xml += "<section id='" + this.id + "' name='" + this.name +
"'>\r\n";
for (var i = 0; i < this.tests.length; i++) { for (var i = 0; i < this.tests.length; i++) {
xml += '<test>\r\n' + xml += '<test>\r\n' +
@ -146,7 +159,7 @@ function Section(parentSection, id, name) {
} }
return xml; return xml;
} };
/* Reset counts and remove tests. */ /* Reset counts and remove tests. */
this.reset = function() { this.reset = function() {
@ -159,5 +172,5 @@ function Section(parentSection, id, name) {
for(var subsection in this.subsections) { for(var subsection in this.subsections) {
this.subsections[subsection].reset(); this.subsections[subsection].reset();
} }
} };
} }

View File

@ -37,7 +37,8 @@ function $FAIL(message) {
//Sputnik library definitions //Sputnik library definitions
//Ultimately these should be namespaced some how and only made available to tests that explicitly include them. //Ultimately these should be namespaced some how and only made
//available to tests that explicitly include them.
//For now, we just define the globally //For now, we just define the globally
//math_precision.js //math_precision.js
@ -435,12 +436,14 @@ function ConstructDate(year, month, date, hours, minutes, seconds, ms){
* 5. If minutes is supplied use ToNumber(minutes); else use 0 * 5. If minutes is supplied use ToNumber(minutes); else use 0
* 6. If seconds is supplied use ToNumber(seconds); else use 0 * 6. If seconds is supplied use ToNumber(seconds); else use 0
* 7. If ms is supplied use ToNumber(ms); else use 0 * 7. If ms is supplied use ToNumber(ms); else use 0
* 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is * 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99,
* 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) * Result(8) is 1900+ToInteger(Result(1));
* otherwise, Result(8) is Result(1)
* 9. Compute MakeDay(Result(8), Result(2), Result(3)) * 9. Compute MakeDay(Result(8), Result(2), Result(3))
* 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) * 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7))
* 11. Compute MakeDate(Result(9), Result(10)) * 11. Compute MakeDate(Result(9), Result(10))
* 12. Set the [[Value]] property of the newly constructed object to TimeClip(UTC(Result(11))) * 12. Set the [[Value]] property of the newly constructed object to
* TimeClip(UTC(Result(11)))
*/ */
var r1 = Number(year); var r1 = Number(year);
var r2 = Number(month); var r2 = Number(month);

View File

@ -158,13 +158,22 @@ function fnSupportsStrict() {
SimpleTestAPIs.push(fnSupportsStrict); SimpleTestAPIs.push(fnSupportsStrict);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//Verify all attributes specified data property of given object: value, writable, enumerable, configurable //Verify all attributes specified data property of given object:
//value, writable, enumerable, configurable
//If all attribute values are expected, return true, otherwise, return false //If all attribute values are expected, return true, otherwise, return false
function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable, configurable) { function dataPropertyAttributesAreCorrect(obj,
name,
value,
writable,
enumerable,
configurable) {
var attributesCorrect = true; var attributesCorrect = true;
if (obj[name] !== value) { if (obj[name] !== value) {
if (typeof obj[name] === "number" && isNaN(obj[name]) && typeof value === "number" && isNaN(value)) { if (typeof obj[name] === "number" &&
isNaN(obj[name]) &&
typeof value === "number" &&
isNaN(value)) {
// keep empty // keep empty
} else { } else {
attributesCorrect = false; attributesCorrect = false;
@ -182,7 +191,10 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
var overwrited = false; var overwrited = false;
if (obj[name] !== value) { if (obj[name] !== value) {
if (typeof obj[name] === "number" && isNaN(obj[name]) && typeof value === "number" && isNaN(value)) { if (typeof obj[name] === "number" &&
isNaN(obj[name]) &&
typeof value === "number" &&
isNaN(value)) {
// keep empty // keep empty
} else { } else {
overwrited = true; overwrited = true;
@ -222,14 +234,24 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
SimpleTestAPIs.push(dataPropertyAttributesAreCorrect); SimpleTestAPIs.push(dataPropertyAttributesAreCorrect);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//Verify all attributes specified accessor property of given object: get, set, enumerable, configurable //Verify all attributes specified accessor property of given object:
//get, set, enumerable, configurable
//If all attribute values are expected, return true, otherwise, return false //If all attribute values are expected, return true, otherwise, return false
function accessorPropertyAttributesAreCorrect(obj, name, get, set, setVerifyHelpProp, enumerable, configurable) { function accessorPropertyAttributesAreCorrect(obj,
name,
get,
set,
setVerifyHelpProp,
enumerable,
configurable) {
var attributesCorrect = true; var attributesCorrect = true;
if (get !== undefined) { if (get !== undefined) {
if (obj[name] !== get()) { if (obj[name] !== get()) {
if (typeof obj[name] === "number" && isNaN(obj[name]) && typeof get() === "number" && isNaN(get())) { if (typeof obj[name] === "number" &&
isNaN(obj[name]) &&
typeof get() === "number" &&
isNaN(get())) {
// keep empty // keep empty
} else { } else {
attributesCorrect = false; attributesCorrect = false;

View File

@ -19,7 +19,8 @@
/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//Do not cache any JSON files - see https://bugs.ecmascript.org/show_bug.cgi?id=87 // Do not cache any JSON files - see
// https://bugs.ecmascript.org/show_bug.cgi?id=87
$.ajaxSetup( {cache:false}); $.ajaxSetup( {cache:false});
/* /*
@ -29,22 +30,26 @@ $.ajaxSetup( {cache:false});
* * run(id, test): Runs the test specified. * * run(id, test): Runs the test specified.
* *
* Callbacks: * Callbacks:
* * onComplete(test): Called when the test is run. Test object contains result and error strings describing how the * * onComplete(test): Called when the test is run. Test object
* contains result and error strings describing how the
* test ran. * test ran.
*/ */
function BrowserRunner() { function BrowserRunner() {
var iframe, // injected iframe var iframe, // injected iframe
currentTest, // Current test being run. currentTest, // Current test being run.
scriptCache = {}, // Holds the various includes required to run certain sputnik tests. scriptCache = {}, // Holds the various includes required to
// run certain sputnik tests.
instance = this; instance = this;
/* Called by the child window to notify that the test has finished. This function call is put in a separate script /* Called by the child window to notify that the test has
* block at the end of the page so errors in the test script block should not prevent this function from being * finished. This function call is put in a separate script block
* called. * at the end of the page so errors in the test script block
* should not prevent this function from being called.
*/ */
function testFinished() { function testFinished() {
if(typeof currentTest.result === "undefined") { if(typeof currentTest.result === "undefined") {
// We didn't get a call to testRun, which likely means the test failed to load. // We didn't get a call to testRun, which likely means the
// test failed to load.
currentTest.result = "fail"; currentTest.result = "fail";
currentTest.error = "Failed to Load"; currentTest.error = "Failed to Load";
} else if(typeof currentTest.error !== "undefined") { } else if(typeof currentTest.error !== "undefined") {
@ -52,7 +57,8 @@ function BrowserRunner() {
if(currentTest.error instanceof Test262Error) { if(currentTest.error instanceof Test262Error) {
currentTest.error = currentTest.message; currentTest.error = currentTest.message;
} else { } else {
currentTest.error = currentTest.error.name + ": " + currentTest.error.message; currentTest.error = currentTest.error.name + ": " +
currentTest.error.message;
} }
} }
@ -75,10 +81,12 @@ function BrowserRunner() {
/* Run the test. */ /* Run the test. */
this.run = function(id, code) { this.run = function(id, code) {
var includes = code.match(/\$INCLUDE\(([^\)]+)\)/g), // find all of the $INCLUDE statements // find all of the $INCLUDE statements
var includes = code.match(/\$INCLUDE\(([^\)]+)\)/g),
include; include;
currentTest = {id: id}; // default test, in case it doesn't get registered. // default test, in case it doesn't get registered.
currentTest = {id: id};
iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
iframe.setAttribute("style", "display:none"); iframe.setAttribute("style", "display:none");
@ -103,11 +111,13 @@ function BrowserRunner() {
win.$INCLUDE = function() {}; win.$INCLUDE = function() {};
if(includes !== null) { if(includes !== null) {
// We have some includes, so loop through each include and pull in the dependencies. // We have some includes, so loop through each include and
// pull in the dependencies.
for(var i = 0; i < includes.length; i++) { for(var i = 0; i < includes.length; i++) {
include = includes[i].replace(/.*\(('|")(.*)('|")\)/, "$2"); include = includes[i].replace(/.*\(('|")(.*)('|")\)/, "$2");
// First check to see if we have this script cached already, and if not, grab it. // First check to see if we have this script cached
// already, and if not, grab it.
if(typeof scriptCache[include] === "undefined") { if(typeof scriptCache[include] === "undefined") {
$.ajax({ $.ajax({
async: false, async: false,
@ -117,12 +127,14 @@ function BrowserRunner() {
} }
// Finally, write the required script to the window. // Finally, write the required script to the window.
doc.writeln("<script type='text/javascript'>" + scriptCache[include] + "</script>"); doc.writeln("<script type='text/javascript'>" +
scriptCache[include] + "</script>");
} }
} }
//Write out all of our helper functions //Write out all of our helper functions
doc.writeln("<script type='text/javascript'>" + PickledSimpleTestAPIs + "</script>"); doc.writeln("<script type='text/javascript'>" +
PickledSimpleTestAPIs + "</script>");
@ -134,51 +146,126 @@ function BrowserRunner() {
var testDescrip = GlobalScopeTests[id]; var testDescrip = GlobalScopeTests[id];
//Add an error handler //Add an error handler
doc.writeln("<script type='text/javascript'>window.onerror = function(errorMsg, url, lineNumber) {window.iframeError = errorMsg;};" + "</script>"); doc.writeln("<script type='text/javascript'>" +
"window.onerror = function(errorMsg, url, lineNumber)"+
" {window.iframeError = errorMsg;};" +
"</script>");
//Parse and execute the code //Parse and execute the code
doc.writeln("<script type='text/javascript'>onErrorHack = true;try{" + code + "}catch(test262RuntimeError){window.iframeError=test262RuntimeError.message || \"None\";}</script>"); doc.writeln("<script type='text/javascript'>" +
"onErrorHack = true;try{" +
code +
"}catch(test262RuntimeError){" +
"window.iframeError=test262RuntimeError.message || " +
"'None';" +
"}</script>");
//validation //validation
if (testDescrip.negative!==undefined) { //An exception is expected if (testDescrip.negative!==undefined) {
if (win.onErrorHack===undefined) { //Hack for browsers not supporting window.onerror WRT early parse errors //An exception is expected
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', if (win.onErrorHack===undefined) {
'pass', 'Not parsable'); //Hack for browsers not supporting window.onerror
//WRT early parse errors
testRun(testDescrip.id,
testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'pass',
'Not parsable');
} }
else if (win.iframeError===undefined) { //no exception was thrown else if (win.iframeError===undefined) {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', //no exception was thrown
'fail', 'No Exception Thrown'); testRun(testDescrip.id,
} else if(! (new RegExp(testDescrip.negative, "i").test(win.iframeError))) { //wrong type of exception thrown testDescrip.path,
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', testDescrip.description,
'fail', 'Wrong Type of Exception Thrown'); code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'fail',
'No Exception Thrown');
} else if (! (new RegExp(testDescrip.negative, "i").test(
win.iframeError))) {
//wrong type of exception thrown
testRun(testDescrip.id,
testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'fail',
'Wrong Type of Exception Thrown');
} else { } else {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', testRun(testDescrip.id,
'pass', undefined); testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'pass',
undefined);
} }
} else if (win.iframeError!==undefined) { //Exception was not expected to be thrown } else if (win.iframeError!==undefined) {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', //Exception was not expected to be thrown
'fail', 'Unexpected Exception'); testRun(testDescrip.id,
testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'fail',
'Unexpected Exception');
} else { } else {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', testRun(testDescrip.id,
'pass', undefined); testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'pass',
undefined);
} }
} }
//--Scenario 2: we're dealing with a normal positive(?) test case //--Scenario 2: we're dealing with a normal positive(?) test case
else { else {
// Write ES5Harness.registerTest and fnGlobalObject, which returns the global object, and the testFinished call. // Write ES5Harness.registerTest and fnGlobalObject, which
doc.writeln("<script type='text/javascript'>ES5Harness = {};" + // returns the global object, and the testFinished call.
"ES5Harness.registerTest = function(test) {" + doc.writeln(
" var error;" + "<script type='text/javascript'>" +
" if(test.precondition && !test.precondition()) {" + "ES5Harness = {};" +
" testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', 'fail', 'Precondition Failed');" + "ES5Harness.registerTest = function(test) {" +
" } else {" + " var error;" +
" var testThis = test.strict===undefined ? window : undefined;" + " if(test.precondition && !test.precondition()) {" +
" try { var res = test.test.call(testThis); } catch(e) { res = 'fail'; error = e; }" + " testRun(test.id, " +
" var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail');" + "test.path, " +
" testRun(test.id, test.path, test.description, test.test.toString(), typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', retVal, error);" + "test.description, " +
" }" + "test.test.toString()," +
"}</script>" + "typeof test.precondition !== 'undefined' ? " +
"<script type='text/javascript'>" + code + "</script>"); "test.precondition.toString() : '', " +
"'fail', " +
"'Precondition Failed');" +
" } else {" +
" var testThis = " +
"test.strict===undefined ? window : undefined;" +
" try { " +
"var res = test.test.call(testThis); " +
"} catch(e) { res = 'fail'; error = e; }" +
" var retVal = /^s/i.test(test.id) ? " +
"(res === true || typeof res === 'undefined' ? " +
"'pass' : 'fail') : " +
"(res === true ? 'pass' : 'fail');" +
" testRun(test.id, " +
"test.path, " +
"test.description, " +
"test.test.toString(), " +
"typeof test.precondition !== 'undefined' ? " +
"test.precondition.toString() : '', " +
"retVal, " +
"error);" +
" }" +
"}</script>" +
"<script type='text/javascript'>" + code + "</script>");
} }
doc.writeln("<script type='text/javascript'>testFinished();</script>"); doc.writeln("<script type='text/javascript'>testFinished();</script>");
doc.close(); doc.close();
@ -191,9 +278,12 @@ function BrowserRunner() {
* * reset() - Start over at the first test. * * reset() - Start over at the first test.
* *
* Callbacks: * Callbacks:
* * onLoadingNextSection(path): Called after a request is sent for the next section xml, with the path to that xml. * * onLoadingNextSection(path): Called after a request is sent for
* * onInitialized(totalTests, version, date): Called after the testcaseslist.xml is loaded and parsed. * the next section xml, with the path to that xml.
* * onTestReady(id, code): Called when a test is ready with the test's id and code. * * onInitialized(totalTests, version, date): Called after the
* testcaseslist.xml is loaded and parsed.
* * onTestReady(id, code): Called when a test is ready with the
* test's id and code.
* * onTestsExhausted(): Called when there are no more tests to run. * * onTestsExhausted(): Called when there are no more tests to run.
*/ */
function TestLoader() { function TestLoader() {
@ -246,7 +336,9 @@ function TestLoader() {
tests: [] tests: []
}; };
} }
loader.onInitialized(loader.totalTests, loader.version, loader.date); loader.onInitialized(loader.totalTests,
loader.version,
loader.date);
getNextXML(); getNextXML();
}}); }});
} }
@ -260,11 +352,13 @@ function TestLoader() {
// We have tests left in this test group. // We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++]; var test = testGroups[testGroupIndex].tests[currentTestIndex++];
var scriptCode = test.code; var scriptCode = test.code;
//var scriptCode = (test.firstChild.text != undefined) ? test.firstChild.text : test.firstChild.textContent; //var scriptCode = (test.firstChild.text != undefined) ?
// test.firstChild.text : test.firstChild.textContent;
loader.onTestReady(test.id, $.base64Decode(scriptCode)); loader.onTestReady(test.id, $.base64Decode(scriptCode));
} else if(testGroupIndex < testGroups.length - 1) { } else if(testGroupIndex < testGroups.length - 1) {
// We don't have tests left in this test group, so move on to the next. // We don't have tests left in this test group, so move on
// to the next.
testGroupIndex++; testGroupIndex++;
getNextXML(); getNextXML();
} else { } else {
@ -368,9 +462,11 @@ $(function () {
presenter.setup(); presenter.setup();
$('.content-home').show(); $('.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.) // 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) { $('.nav-link').each(function (index) {
//Adding "targetDiv" attribute to the header tab and on that basis the div related to header tabs are displayed //Adding "targetDiv" attribute to the header tab and on that
//basis the div related to header tabs are displayed
if (index === 0) { if (index === 0) {
$(this).attr('targetDiv', '.content-home'); $(this).attr('targetDiv', '.content-home');
} else if (index === 1) { } else if (index === 1) {
@ -385,7 +481,8 @@ $(function () {
$(this).attr('targetDiv', '.content-browsers'); $(this).attr('targetDiv', '.content-browsers');
} }
//Attaching the click event to the header tab that shows the respective div of header //Attaching the click event to the header tab that shows the
//respective div of header
$(this).click(function () { $(this).click(function () {
var target = $(this).attr('targetDiv'); var target = $(this).attr('targetDiv');
$('#contentContainer > div:visible').hide(); $('#contentContainer > div:visible').hide();
@ -400,12 +497,14 @@ $(function () {
}); });
}); });
//Attach the click event to the start button. It starts, stops and pauses the tests //Attach the click event to the start button. It starts, stops and
//pauses the tests
$('.button-start').click(function () { $('.button-start').click(function () {
controller.toggle(); controller.toggle();
}); });
//Attach the click event to the reset button. It reset all the test to zero //Attach the click event to the reset button. It reset all the
//test to zero
$('.button-reset').click(function () { $('.button-reset').click(function () {
controller.reset(); controller.reset();
}); });