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

@ -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 &gt; </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 + " &gt; </a>");
link.bind('click', sectionSelected)
link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" +
sectionChain[i].id + ": " + sectionChain[i].name +
" &gt; </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, '&lt;').replace(/>/g, '&gt;'); +' </pre>';
innerHTML += '<pre>' +
test.description.replace(/</g, '&lt;').replace(/>/g, '&gt;') +
' </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();

View File

@ -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.
/* A section of the spec. Stores test results and subsections and some rolled up stats on how many tests passed or
* failed under that section
@ -57,16 +57,20 @@ function Section(parentSection, id, name) {
}
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
* tabulate pass/fail numbers*/
/* Add a test result to this section. Pushes the result to the
* test array and passes the result to addTestResult to tabulate
* pass/fail numbers
*/
this.addTest = function(test) {
this.tests.push(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.totalTests++;
@ -80,7 +84,7 @@ function Section(parentSection, id, name) {
if(this.parentSection !== null)
this.parentSection.addTestResult(test);
}
};
/* Renders this section as HTML. Used for the report page.*/
this.toHTML = function(options) {
@ -93,7 +97,7 @@ function Section(parentSection, id, name) {
}
var html = '<tbody id="section_' + this.id.replace(/\./g, "_") + '">';
if(options.header) {
html += "<tr><td class='tblHeader' colspan='3'>Chapter " + this.id + " - " + this.name + "</td>" +
"<td class='" + rollupCellClass(this.passPercent()) + "'>" + this.passPercent() + "%</td></tr>";
@ -103,31 +107,40 @@ function Section(parentSection, id, name) {
test = this.tests[i];
html += "<tr><td>" + test.id + "</td>" +
"<td>" + test.description + "</td>" +
"<td><a class='showSource' href='#" + test.id + "'>[source]</a></td>" +
"<td class='" + test.result + "'>" + test.result + "</td></tr>"
"<td><a class='showSource' href='#" + test.id +
"'>[source]</a></td>" +
"<td class='" + test.result + "'>" + test.result +
"</td></tr>";
}
for(var sectionId in this.subsections) {
var section = this.subsections[sectionId];
if(section.totalTests > 0) {
if(options.renderSubsections) {
html += section.toHTML({header: true, renderSubsections: false})
html += section.toHTML({
header: true,
renderSubsections: false});
} else {
html += "<tr><td colspan='3'><a class='section' href='#" + section.id + "'>Chapter " + section.id + " - " + section.name + "</a></td>" +
"<td class='" + rollupCellClass(section.passPercent()) + "'>" + section.passPercent() + "%</td></tr>";
html += "<tr><td colspan='3'><a class='section' href='#" +
section.id + "'>Chapter " + section.id + " - " +
section.name + "</a></td>" +
"<td class='" +
rollupCellClass(section.passPercent()) + "'>" +
section.passPercent() + "%</td></tr>";
}
}
}
return html + "</tbody>";
}
};
/* Render this section as XML. Used for the report page. */
this.toXML = function() {
var xml = "";
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++) {
xml += '<test>\r\n' +
@ -146,7 +159,7 @@ function Section(parentSection, id, name) {
}
return xml;
}
};
/* Reset counts and remove tests. */
this.reset = function() {
@ -159,5 +172,5 @@ function Section(parentSection, id, name) {
for(var subsection in this.subsections) {
this.subsections[subsection].reset();
}
}
};
}

View File

@ -37,7 +37,8 @@ function $FAIL(message) {
//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
//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
* 6. If seconds is supplied use ToNumber(seconds); 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
* 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1)
* 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99,
* Result(8) is 1900+ToInteger(Result(1));
* otherwise, Result(8) is Result(1)
* 9. Compute MakeDay(Result(8), Result(2), Result(3))
* 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7))
* 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 r2 = Number(month);

View File

@ -158,13 +158,22 @@ function 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
function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable, configurable) {
function dataPropertyAttributesAreCorrect(obj,
name,
value,
writable,
enumerable,
configurable) {
var attributesCorrect = true;
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
} else {
attributesCorrect = false;
@ -182,7 +191,10 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
var overwrited = false;
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
} else {
overwrited = true;
@ -222,14 +234,24 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
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
function accessorPropertyAttributesAreCorrect(obj, name, get, set, setVerifyHelpProp, enumerable, configurable) {
function accessorPropertyAttributesAreCorrect(obj,
name,
get,
set,
setVerifyHelpProp,
enumerable,
configurable) {
var attributesCorrect = true;
if (get !== undefined) {
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
} else {
attributesCorrect = false;

View File

@ -19,7 +19,8 @@
/// 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});
/*
@ -29,22 +30,26 @@ $.ajaxSetup( {cache:false});
* * run(id, test): Runs the test specified.
*
* 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.
*/
function BrowserRunner() {
var iframe, // injected iframe
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;
/* Called by the child window to notify that the test has finished. This function call is put in a separate script
* block at the end of the page so errors in the test script block should not prevent this function from being
* called.
/* Called by the child window to notify that the test has
* finished. This function call is put in a separate script block
* at the end of the page so errors in the test script block
* should not prevent this function from being called.
*/
function testFinished() {
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.error = "Failed to Load";
} else if(typeof currentTest.error !== "undefined") {
@ -52,7 +57,8 @@ function BrowserRunner() {
if(currentTest.error instanceof Test262Error) {
currentTest.error = currentTest.message;
} 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. */
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;
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.setAttribute("style", "display:none");
@ -103,11 +111,13 @@ function BrowserRunner() {
win.$INCLUDE = function() {};
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++) {
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") {
$.ajax({
async: false,
@ -117,12 +127,14 @@ function BrowserRunner() {
}
// 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
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];
//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
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
if (testDescrip.negative!==undefined) { //An exception is expected
if (win.onErrorHack===undefined) { //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');
if (testDescrip.negative!==undefined) {
//An exception is expected
if (win.onErrorHack===undefined) {
//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
testRun(testDescrip.id, testDescrip.path, testDescrip.description, 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 if (win.iframeError===undefined) {
//no exception was thrown
testRun(testDescrip.id,
testDescrip.path,
testDescrip.description,
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 {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
'pass', undefined);
testRun(testDescrip.id,
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
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
'fail', 'Unexpected Exception');
} else if (win.iframeError!==undefined) {
//Exception was not expected to be thrown
testRun(testDescrip.id,
testDescrip.path,
testDescrip.description,
code,
typeof testDescrip.precondition !== 'undefined' ?
testDescrip.precondition.toString() : '',
'fail',
'Unexpected Exception');
} else {
testRun(testDescrip.id, testDescrip.path, testDescrip.description, code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '',
'pass', undefined);
testRun(testDescrip.id,
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
else {
// Write ES5Harness.registerTest and fnGlobalObject, which returns the global object, and the testFinished call.
doc.writeln("<script type='text/javascript'>ES5Harness = {};" +
"ES5Harness.registerTest = function(test) {" +
" var error;" +
" if(test.precondition && !test.precondition()) {" +
" testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? 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>");
// Write ES5Harness.registerTest and fnGlobalObject, which
// returns the global object, and the testFinished call.
doc.writeln(
"<script type='text/javascript'>" +
"ES5Harness = {};" +
"ES5Harness.registerTest = function(test) {" +
" var error;" +
" if(test.precondition && !test.precondition()) {" +
" testRun(test.id, " +
"test.path, " +
"test.description, " +
"test.test.toString()," +
"typeof test.precondition !== 'undefined' ? " +
"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.close();
@ -191,9 +278,12 @@ function BrowserRunner() {
* * reset() - Start over at the first test.
*
* Callbacks:
* * onLoadingNextSection(path): Called after a request is sent for the next section xml, with the path to that xml.
* * 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.
* * onLoadingNextSection(path): Called after a request is sent for
* the next section xml, with the path to that xml.
* * 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.
*/
function TestLoader() {
@ -246,7 +336,9 @@ function TestLoader() {
tests: []
};
}
loader.onInitialized(loader.totalTests, loader.version, loader.date);
loader.onInitialized(loader.totalTests,
loader.version,
loader.date);
getNextXML();
}});
}
@ -260,11 +352,13 @@ function TestLoader() {
// We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++];
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));
} 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++;
getNextXML();
} else {
@ -368,9 +462,11 @@ $(function () {
presenter.setup();
$('.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) {
//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) {
$(this).attr('targetDiv', '.content-home');
} else if (index === 1) {
@ -385,7 +481,8 @@ $(function () {
$(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 () {
var target = $(this).attr('targetDiv');
$('#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 () {
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 () {
controller.reset();
});