2012-02-29 23:23:47 +01:00
|
|
|
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
|
|
/// Ecma International makes this code available under the terms and conditions set
|
|
|
|
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
|
|
|
/// "Use Terms"). Any redistribution of this code must retain the above
|
|
|
|
/// copyright and this notice and otherwise comply with the Use Terms.
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
// Do not cache any JSON files - see
|
|
|
|
// https://bugs.ecmascript.org/show_bug.cgi?id=87
|
2011-07-01 21:01:55 +02:00
|
|
|
$.ajaxSetup( {cache:false});
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/*
|
|
|
|
* Run a test in the browser. Works by injecting an iframe with the test code.
|
|
|
|
*
|
|
|
|
* Public Methods:
|
|
|
|
* * run(id, test): Runs the test specified.
|
|
|
|
*
|
|
|
|
* Callbacks:
|
2011-09-14 01:37:30 +02:00
|
|
|
* * onComplete(test): Called when the test is run. Test object
|
|
|
|
* contains result and error strings describing how the
|
2010-11-12 18:27:59 +01:00
|
|
|
* test ran.
|
|
|
|
*/
|
|
|
|
function BrowserRunner() {
|
|
|
|
var iframe, // injected iframe
|
|
|
|
currentTest, // Current test being run.
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
scriptCache = {}, // Holds the various includes required to run certain tests.
|
|
|
|
instance = this,
|
|
|
|
errorDetectorFileContents,
|
|
|
|
simpleTestAPIContents,
|
|
|
|
globalScopeContents,
|
2011-09-25 20:41:04 +02:00
|
|
|
harnessDir = "harness/";
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
|
2011-10-03 21:08:06 +02:00
|
|
|
$.ajax({async: false,
|
|
|
|
dataType: "text",
|
|
|
|
success: function(data){errorDetectorFileContents = data;},
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
url:harnessDir+"ed.js"});
|
2011-10-03 21:08:06 +02:00
|
|
|
|
|
|
|
$.ajax({async: false,
|
|
|
|
dataType: "text",
|
|
|
|
success: function(data){simpleTestAPIContents = data;},
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
url:harnessDir+"sta.js"});
|
2011-10-03 21:08:06 +02:00
|
|
|
|
|
|
|
$.ajax({async: false,
|
|
|
|
dataType: "text",
|
|
|
|
success: function(data){globalScopeContents = data;},
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
url:harnessDir+"gs.js"});
|
2011-10-03 21:08:06 +02:00
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
/* 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.
|
2010-11-12 18:27:59 +01:00
|
|
|
*/
|
|
|
|
function testFinished() {
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
if((typeof currentTest.result) === "undefined") {
|
2011-09-14 01:37:30 +02:00
|
|
|
// We didn't get a call to testRun, which likely means the
|
|
|
|
// test failed to load.
|
2010-11-12 18:27:59 +01:00
|
|
|
currentTest.result = "fail";
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
currentTest.error = "Failed to load test case (probable parse error).";
|
|
|
|
currentTest.description = "Failed to load test case!";
|
|
|
|
} else if((typeof currentTest.error) !== "undefined") {
|
2010-11-12 18:27:59 +01:00
|
|
|
// We have an error logged from testRun.
|
2011-09-12 22:34:49 +02:00
|
|
|
if(currentTest.error instanceof Test262Error) {
|
2010-11-12 18:27:59 +01:00
|
|
|
currentTest.error = currentTest.message;
|
|
|
|
} else {
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
currentTest.error = currentTest.error.name + ": " + currentTest.error.message;
|
2010-11-02 00:28:46 +01:00
|
|
|
}
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
} else if ((typeof currentTest.error === "undefined") && (currentTest.result === "fail")) {
|
|
|
|
currentTest.error = "Test case returned non-true value.";
|
2010-11-02 00:28:46 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
document.body.removeChild(iframe);
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
instance.onComplete(currentTest);
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Called from the child window after the test has run. */
|
2011-09-25 20:41:04 +02:00
|
|
|
function testRun(id, path, description, codeString, result, error) {
|
2010-11-12 18:27:59 +01:00
|
|
|
currentTest.id = id;
|
|
|
|
currentTest.path = path;
|
|
|
|
currentTest.description = description;
|
|
|
|
currentTest.result = result;
|
|
|
|
currentTest.error = error;
|
|
|
|
currentTest.code = codeString;
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
|
|
|
|
2010-11-02 00:28:46 +01:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Run the test. */
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
this.run = function (test, code) {
|
2011-11-11 20:40:05 +01:00
|
|
|
|
|
|
|
//--Detect proper window.onerror support
|
|
|
|
if (instance.supportsWindowOnerror===undefined) {
|
|
|
|
var iframePrereqs = document.createElement("iframe");
|
|
|
|
iframePrereqs.setAttribute("id", "prereqsIframe");
|
|
|
|
if (!/firefox/i.test(navigator.userAgent)) {
|
|
|
|
iframePrereqs.setAttribute("style", "display:none");
|
|
|
|
}
|
|
|
|
document.body.appendChild(iframePrereqs);
|
|
|
|
|
|
|
|
var iwinPrereqs = iframePrereqs.contentWindow;
|
|
|
|
var idocPrereqs = iwinPrereqs.document;
|
|
|
|
idocPrereqs.open();
|
|
|
|
|
|
|
|
iwinPrereqs.failCount = 0;
|
|
|
|
|
|
|
|
var stuff = [
|
|
|
|
"window.onerror = function(a, b, c) { this.failCount++; }",
|
|
|
|
"va xyz =",
|
|
|
|
"throw Error();"
|
|
|
|
];
|
|
|
|
|
|
|
|
for(var i in stuff) {
|
|
|
|
idocPrereqs.writeln("<script type='text/javascript'>");
|
|
|
|
idocPrereqs.writeln(stuff[i]);
|
|
|
|
idocPrereqs.writeln("</script>");
|
|
|
|
}
|
|
|
|
idocPrereqs.close();
|
|
|
|
|
|
|
|
//TODO - 500ms *should* be a sufficient delay
|
|
|
|
setTimeout(function() {
|
|
|
|
instance.supportsWindowOnerror = iwinPrereqs.failCount === 2;
|
|
|
|
//alert(iwinPrereqs.failCount);
|
|
|
|
document.body.removeChild(iframePrereqs);
|
|
|
|
instance.run(test, code);
|
|
|
|
}, 500);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
currentTest = {};
|
|
|
|
for (var tempIndex in test) {
|
|
|
|
if (test.hasOwnProperty(tempIndex)) {
|
|
|
|
currentTest[tempIndex] = test[tempIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentTest.code = code;
|
2011-11-11 20:40:05 +01:00
|
|
|
|
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
iframe = document.createElement("iframe");
|
2011-09-25 20:41:04 +02:00
|
|
|
iframe.setAttribute("id", "runnerIframe");
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
//FireFox has a defect where it doesn't fire window.onerror for an iframe if the iframe
|
|
|
|
//is invisible.
|
2011-09-25 20:41:04 +02:00
|
|
|
if (!/firefox/i.test(navigator.userAgent)) {
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
iframe.setAttribute("style", "display:none");
|
|
|
|
}
|
2010-11-12 18:27:59 +01:00
|
|
|
document.body.appendChild(iframe);
|
|
|
|
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
var iwin = window.frames[window.frames.length - 1];
|
|
|
|
var idoc = iwin.document;
|
|
|
|
idoc.open();
|
2010-11-12 18:27:59 +01:00
|
|
|
|
|
|
|
// Set up some globals.
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
iwin.testRun = testRun;
|
|
|
|
iwin.testFinished = testFinished;
|
2011-09-12 22:34:49 +02:00
|
|
|
|
2011-02-04 01:28:52 +01:00
|
|
|
//TODO: these should be moved to sta.js
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
var includes = code.match(/\$INCLUDE\(([^\)]+)\)/g), // find all of the $INCLUDE statements
|
|
|
|
include;
|
2010-11-12 18:27:59 +01:00
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
if (includes !== null) {
|
2011-09-14 01:37:30 +02:00
|
|
|
// We have some includes, so loop through each include and
|
|
|
|
// pull in the dependencies.
|
2011-09-25 20:41:04 +02:00
|
|
|
for (var i = 0; i < includes.length; i++) {
|
2010-11-12 18:27:59 +01:00
|
|
|
include = includes[i].replace(/.*\(('|")(.*)('|")\)/, "$2");
|
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
// First check to see if we have this script cached
|
|
|
|
// already, and if not, grab it.
|
2011-09-25 20:41:04 +02:00
|
|
|
if (typeof scriptCache[include] === "undefined") {
|
2010-11-12 18:27:59 +01:00
|
|
|
$.ajax({
|
|
|
|
async: false,
|
2011-09-25 20:41:04 +02:00
|
|
|
url: 'harness/' + include,
|
|
|
|
success: function (s) { scriptCache[include] = s; }
|
2011-09-12 22:34:49 +02:00
|
|
|
});
|
2010-11-02 00:28:46 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
// Finally, write the required script to the window.
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
idoc.writeln("<script type='text/javascript'>" + scriptCache[include] + "</script>");
|
2010-11-02 00:28:46 +01:00
|
|
|
}
|
|
|
|
}
|
2011-09-12 22:34:49 +02:00
|
|
|
|
2011-02-04 01:28:52 +01:00
|
|
|
//Write out all of our helper functions
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
//idoc.writeln("<script type='text/javascript' src='harness/sta.js'>" + "</script>");
|
|
|
|
idoc.writeln("<script type='text/javascript'>");
|
|
|
|
idoc.writeln(simpleTestAPIContents);
|
|
|
|
idoc.writeln("</script>");
|
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
iwin.iframeError = undefined;
|
|
|
|
iwin.onerror = undefined;
|
|
|
|
iwin.testDescrip = currentTest;
|
|
|
|
|
|
|
|
//Add an error handler capable of catching so-called early errors
|
|
|
|
//idoc.writeln("<script type='text/javascript' src='harness/ed.js'>" + "</script>");
|
|
|
|
idoc.writeln("<script type='text/javascript'>");
|
|
|
|
idoc.writeln(errorDetectorFileContents);
|
|
|
|
idoc.writeln("</script>");
|
|
|
|
|
|
|
|
//Run the code
|
|
|
|
idoc.writeln("<script type='text/javascript'>");
|
2011-11-11 20:40:05 +01:00
|
|
|
if (! instance.supportsWindowOnerror) {
|
2011-09-25 20:41:04 +02:00
|
|
|
idoc.writeln("try {eval(\"" + this.convertForEval(code) + "\");} catch(e) {window.onerror(e.toString(), null, null);}");
|
|
|
|
} else {
|
|
|
|
idoc.writeln(code);
|
2011-04-20 20:17:38 +02:00
|
|
|
}
|
2011-09-25 20:41:04 +02:00
|
|
|
idoc.writeln("</script>");
|
|
|
|
|
|
|
|
//Validate the results
|
|
|
|
//idoc.writeln("<script type='text/javascript' src='harness/gs.js' defer>" + "</script>");
|
|
|
|
idoc.writeln("<script type='text/javascript'>");
|
|
|
|
idoc.writeln(globalScopeContents);
|
|
|
|
idoc.writeln("</script>");
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
idoc.close();
|
2011-10-03 21:08:06 +02:00
|
|
|
};
|
|
|
|
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
//--Helper functions-------------------------------------------------------
|
|
|
|
this.convertForEval = function(txt) {
|
|
|
|
txt = txt.replace(/\\/g,"\\\\");
|
|
|
|
txt = txt.replace(/\"/g,"\\\"");
|
|
|
|
txt = txt.replace(/\'/g,"\\\'");
|
|
|
|
txt = txt.replace(/\r/g,"\\r");
|
|
|
|
txt = txt.replace(/\n/g,"\\n");
|
|
|
|
return txt;
|
2011-10-03 21:08:06 +02:00
|
|
|
};
|
2010-11-12 18:27:59 +01:00
|
|
|
}
|
2010-10-19 05:50:07 +02:00
|
|
|
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
/* Loads tests from the sections specified in testcases.json.
|
2010-11-12 18:27:59 +01:00
|
|
|
* Public Methods:
|
|
|
|
* * getNextTest() - Start loading the next test.
|
|
|
|
* * reset() - Start over at the first test.
|
|
|
|
*
|
|
|
|
* Callbacks:
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
* * onLoadingNextSection(path): Called after a request is sent for the next section json, with the path to that json.
|
|
|
|
* * onInitialized(totalTests, version, date): Called after the testcases.json is loaded and parsed.
|
2011-09-14 01:37:30 +02:00
|
|
|
* * onTestReady(id, code): Called when a test is ready with the
|
|
|
|
* test's id and code.
|
2010-11-12 18:27:59 +01:00
|
|
|
* * onTestsExhausted(): Called when there are no more tests to run.
|
|
|
|
*/
|
|
|
|
function TestLoader() {
|
2011-06-07 18:48:10 +02:00
|
|
|
var testGroups = [],
|
2010-11-12 18:27:59 +01:00
|
|
|
testGroupIndex = 0,
|
|
|
|
currentTestIndex = 0,
|
|
|
|
loader = this;
|
|
|
|
|
|
|
|
this.version = undefined;
|
|
|
|
this.date = undefined;
|
|
|
|
this.totalTests = 0;
|
|
|
|
|
|
|
|
/* Get the XML for the next section */
|
|
|
|
function getNextXML() {
|
|
|
|
var group = testGroups[testGroupIndex];
|
|
|
|
currentTestIndex = 0;
|
|
|
|
|
|
|
|
if(group.tests.length > 0) {
|
|
|
|
// already loaded this section.
|
|
|
|
loader.getNextTest();
|
2010-10-19 05:50:07 +02:00
|
|
|
return;
|
2010-11-02 00:28:46 +01:00
|
|
|
}
|
2011-03-11 19:59:52 +01:00
|
|
|
$.ajax({url: group.path, dataType: 'json', success: function(data) {
|
|
|
|
group.tests = data.testsCollection.tests;
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.getNextTest();
|
2011-09-12 22:34:49 +02:00
|
|
|
},
|
2011-03-11 19:59:52 +01:00
|
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
2011-09-12 22:34:49 +02:00
|
|
|
//alert(XMLHttpRequest);
|
2011-03-11 19:59:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.onLoadingNextSection(group.path);
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Get the test list xml */
|
|
|
|
function loadTestXML() {
|
|
|
|
var testsListLoader = new XMLHttpRequest();
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2011-03-11 19:59:52 +01:00
|
|
|
$.ajax({url: TEST_LIST_PATH, dataType: 'json', success: function(data) {
|
|
|
|
var testSuite = data.testSuite;
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2011-03-11 19:59:52 +01:00
|
|
|
loader.version = data.version;
|
|
|
|
loader.date = data.date;
|
2011-09-12 22:34:49 +02:00
|
|
|
loader.totalTests = data.numTests;
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2011-03-11 19:59:52 +01:00
|
|
|
for (var i = 0; i < testSuite.length; i++) {
|
2010-11-12 18:27:59 +01:00
|
|
|
testGroups[i] = {
|
2011-03-11 19:59:52 +01:00
|
|
|
path: testSuite[i],
|
2010-11-12 18:27:59 +01:00
|
|
|
tests: []
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
2012-03-29 01:05:03 +02:00
|
|
|
loader.onInitialized(loader.totalTests);
|
2010-11-12 18:27:59 +01:00
|
|
|
getNextXML();
|
|
|
|
}});
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
function getIdFromPath (path) {
|
|
|
|
//path is of the form "a/b/c.js"
|
2011-10-03 21:08:06 +02:00
|
|
|
|
2011-09-25 20:41:04 +02:00
|
|
|
var id = path.split("/");
|
|
|
|
//id is now of the form ["a", "b", "c.js"];
|
|
|
|
|
|
|
|
id = id[id.length-1];
|
|
|
|
//id is now of the form "c.js"
|
|
|
|
|
|
|
|
id = id.replace(/\.js$/i, "");
|
|
|
|
//id is now of the form "c"
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Move on to the next test */
|
|
|
|
this.getNextTest = function() {
|
|
|
|
if(testGroups.length == 0) {
|
|
|
|
// Initialize.
|
|
|
|
loadTestXML();
|
|
|
|
} else if(currentTestIndex < testGroups[testGroupIndex].tests.length) {
|
|
|
|
// We have tests left in this test group.
|
|
|
|
var test = testGroups[testGroupIndex].tests[currentTestIndex++];
|
2011-09-25 20:41:04 +02:00
|
|
|
var scriptCode = test.code;
|
|
|
|
test.id = getIdFromPath(test.path);
|
2011-09-14 01:37:30 +02:00
|
|
|
//var scriptCode = (test.firstChild.text != undefined) ?
|
|
|
|
// test.firstChild.text : test.firstChild.textContent;
|
2010-11-12 18:27:59 +01:00
|
|
|
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
loader.onTestReady(test, $.base64Decode(scriptCode));
|
2010-11-12 18:27:59 +01:00
|
|
|
} else if(testGroupIndex < testGroups.length - 1) {
|
2011-09-14 01:37:30 +02:00
|
|
|
// We don't have tests left in this test group, so move on
|
|
|
|
// to the next.
|
2010-11-12 18:27:59 +01:00
|
|
|
testGroupIndex++;
|
|
|
|
getNextXML();
|
|
|
|
} else {
|
|
|
|
// We're done.
|
|
|
|
loader.onTestsExhausted();
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Start over at the beginning */
|
|
|
|
this.reset = function() {
|
|
|
|
currentTestIndex = 0;
|
|
|
|
testGroupIndex = 0;
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2011-10-03 21:08:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
}
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
/* Controls test generation and running, and sends results to the presenter. */
|
|
|
|
function Controller() {
|
|
|
|
var state = 'stopped';
|
|
|
|
var runner = new BrowserRunner();
|
|
|
|
var loader = new TestLoader();
|
|
|
|
var controller = this;
|
2011-02-04 01:28:52 +01:00
|
|
|
var startTime;
|
|
|
|
var elapsed = 0;
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
//Hook which allows browser implementers to hook their own test harness API
|
|
|
|
//into this test framework to handle test case failures and passes in their
|
|
|
|
//own way (e.g., logging failures to the filesystem)
|
|
|
|
this.implementerHook = {
|
|
|
|
//Adds a test result
|
|
|
|
addTestResult: function (test) { },
|
2011-10-03 21:08:06 +02:00
|
|
|
|
|
|
|
//Called whenever all tests have finished running. Provided with the
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
//elapsed time in milliseconds.
|
|
|
|
finished: function(elapsed) { }
|
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
runner.onComplete = function(test) {
|
|
|
|
presenter.addTestResult(test);
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
try {
|
|
|
|
controller.implementerHook.addTestResult(test);
|
|
|
|
} catch(e) { /*no-op*/}
|
2011-10-03 21:08:06 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
if(state === 'running')
|
|
|
|
setTimeout(loader.getNextTest, 10);
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2012-03-29 01:05:03 +02:00
|
|
|
loader.onInitialized = function(totalTests) {
|
2010-11-12 18:27:59 +01:00
|
|
|
presenter.setTotalTests(totalTests);
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.onLoadingNextSection = function(path) {
|
|
|
|
presenter.updateStatus("Loading: " + path);
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
loader.onTestReady = function(testObj, testSrc) {
|
|
|
|
presenter.updateStatus("Running Test: " + testObj.id);
|
|
|
|
runner.run(testObj, testSrc);
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.onTestsExhausted = function() {
|
|
|
|
state = 'stopped';
|
2011-02-04 01:28:52 +01:00
|
|
|
elapsed += new Date() - startTime;
|
|
|
|
elapsed = elapsed/(1000*60); //minutes
|
|
|
|
elapsed = elapsed.toFixed(1);
|
|
|
|
presenter.finished(elapsed);
|
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files
such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test
case validator). This change makes it far easier to maintain the test harness code
- reorganized helper.js providing a clear indication which methods are used by external objects,
which are implementation details, and which are unequivocally test262-specific. I've also added,
openErrorWindow, which will be used to open a descriptive error message window for each test case
failure reported on the 'Run' tab
- improved the error message for syntax errors occurring when a test case fails to load
- sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file
directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness
object has been moved from sth.js (in a string) to here
- sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers
to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was
basically re-written
Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to
existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used
as indices into the GlobalScopeTests array.
TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html.
Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py
now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically
generating *.json and *.html test chapters.
2011-08-25 20:18:44 +02:00
|
|
|
try {
|
|
|
|
controller.implementerHook.finished(elapsed);
|
|
|
|
} catch(e) { /*no-op*/}
|
2011-10-03 21:08:06 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
this.start = function() {
|
|
|
|
state = 'running';
|
2011-02-04 01:28:52 +01:00
|
|
|
startTime = new Date();
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.getNextTest();
|
|
|
|
presenter.started();
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
this.pause = function() {
|
2011-02-04 01:28:52 +01:00
|
|
|
elapsed += new Date() - startTime;
|
2010-11-12 18:27:59 +01:00
|
|
|
state = 'paused';
|
|
|
|
presenter.paused();
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
this.reset = function() {
|
2011-02-04 01:28:52 +01:00
|
|
|
startTime = new Date();
|
|
|
|
elapsed = 0;
|
2010-11-12 18:27:59 +01:00
|
|
|
loader.reset();
|
|
|
|
presenter.reset();
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
this.toggle = function() {
|
|
|
|
if(state === 'running') {
|
|
|
|
controller.pause();
|
|
|
|
} else {
|
|
|
|
controller.start();
|
|
|
|
}
|
2011-09-12 22:34:49 +02:00
|
|
|
};
|
2010-10-19 05:50:07 +02:00
|
|
|
}
|
|
|
|
|
2011-09-12 22:34:49 +02:00
|
|
|
var controller = new Controller();
|
2010-11-12 18:27:59 +01:00
|
|
|
|
2011-02-08 18:42:59 +01:00
|
|
|
/* Helper function which shows if we're in the 'debug' mode of the Test262 site.
|
2011-09-12 22:34:49 +02:00
|
|
|
This mode is only useful for debugging issues with the test harness and
|
2011-02-08 18:42:59 +01:00
|
|
|
website. */
|
|
|
|
function isSiteDebugMode() {
|
2011-09-12 22:34:49 +02:00
|
|
|
var str=window.location.href.substring(window.location.href.indexOf("?")+1);
|
2011-02-08 18:42:59 +01:00
|
|
|
if(str.indexOf("sitedebug") > -1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 18:27:59 +01:00
|
|
|
$(function () {
|
|
|
|
presenter.setup();
|
|
|
|
$('.content-home').show();
|
2011-09-14 01:37:30 +02:00
|
|
|
// Adding attribute to the tabs (e.g. Home, Run etc.) and
|
|
|
|
// attaching the click event on buttons (e.g. Reset, Start etc.)
|
2010-11-12 18:27:59 +01:00
|
|
|
$('.nav-link').each(function (index) {
|
2011-09-14 01:37:30 +02:00
|
|
|
//Adding "targetDiv" attribute to the header tab and on that
|
|
|
|
//basis the div related to header tabs are displayed
|
2010-11-12 18:27:59 +01:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
//Attaching the click event to the header tab that shows the
|
|
|
|
//respective div of header
|
2010-11-12 18:27:59 +01:00
|
|
|
$(this).click(function () {
|
|
|
|
var target = $(this).attr('targetDiv');
|
|
|
|
$('#contentContainer > div:visible').hide();
|
|
|
|
$('.navBar .selected').toggleClass('selected');
|
|
|
|
$(this).addClass('selected');
|
|
|
|
$(target).show();
|
|
|
|
|
|
|
|
//If clicked tab is Result, it generates the results.
|
|
|
|
if ($(target).hasClass('content-results')) {
|
|
|
|
presenter.refresh();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
//Attach the click event to the start button. It starts, stops and
|
|
|
|
//pauses the tests
|
2010-11-12 18:27:59 +01:00
|
|
|
$('.button-start').click(function () {
|
|
|
|
controller.toggle();
|
|
|
|
});
|
|
|
|
|
2011-09-14 01:37:30 +02:00
|
|
|
//Attach the click event to the reset button. It reset all the
|
|
|
|
//test to zero
|
2010-11-12 18:27:59 +01:00
|
|
|
$('.button-reset').click(function () {
|
|
|
|
controller.reset();
|
|
|
|
});
|
2012-03-29 01:05:03 +02:00
|
|
|
|
|
|
|
var SUITE_DESCRIP_PATH = "json/suiteDescrip.json";
|
|
|
|
$.ajax({ url: SUITE_DESCRIP_PATH, dataType: 'json', success: function (data) {
|
|
|
|
presenter.setVersion(data.version);
|
|
|
|
presenter.setDate(data.date);
|
|
|
|
}
|
|
|
|
});
|
2010-11-12 18:27:59 +01:00
|
|
|
});
|