diff --git a/test/harness/sth.js b/test/harness/sth.js index cd05685e1877a58da7cb3d374151a28705547020..d100e160daf6978b8a9e61c4a4d8eb7ce87e3ddd 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -91,6 +91,9 @@ function BrowserRunner() { currentTest.code = codeString; } + function isAsyncTest(code) { + return /\$DONE()/.test(code)); + } /* Run the test. */ this.run = function (test, code) { @@ -208,8 +211,8 @@ function BrowserRunner() { //this is mainly applicable for consoles that do not have setTimeout support //idoc.writeln("<script type='text/javascript' src='harness/timer.js' defer>" + "</script>"); - if(setTimeout === undefined && /\$DONE()/.test(code)){ - idoc.writeln("<script type='text/javascript'>"); + if(setTimeout === undefined && isAsyncTest(code)) { + idoc.writeln("<script type='text/javascript'>"); idoc.writeln(timerContents); idoc.writeln("</script>"); } @@ -225,15 +228,15 @@ function BrowserRunner() { idoc.writeln("<script type='text/javascript'>"); - if(!/\$DONE()/.test(code)) - //if the test is synchronous - call $DONE immediately + if (!isAsyncTest(code)) { + //if the test is synchronous - call $DONE immediately idoc.writeln("if(typeof $DONE === 'function') $DONE()"); - else{ - //in case the test does not call $DONE asynchronously then - //bailout after 1 min or given bailout time by calling $DONE + } else { + //in case the test does not call $DONE asynchronously then + //bailout after 1 min or given bailout time by calling $DONE var asyncval = parseInt(test.timeout); var testTimeout = asyncval !== asyncval ? 2000 : asyncval; - idoc.writeln("setTimeout(function() {$ERROR(\" Test Timed Out at " + testTimeout +"\" )} ," + testTimeout + ")"); + idoc.writeln("setTimeout(function() {$ERROR(\" Test Timed Out at " + testTimeout +"\" )} ," + testTimeout + ")"); } idoc.writeln("</script>"); idoc.close(); diff --git a/test/harness/timer.js b/test/harness/timer.js index 69762d83f54479a67962b411f3563688e61204c8..4dddbb3a1b3cd52b1aa91863517ef31e3c31b3f0 100644 --- a/test/harness/timer.js +++ b/test/harness/timer.js @@ -12,7 +12,7 @@ if(Promise !== undefined && this.setTimeout === undefined) var end = start + delay; function check(){ var timeLeft = end - Date.now(); - if(timeLeft) + if(timeLeft > 0) p.then(check); else callback(); diff --git a/tools/packaging/test262.py b/tools/packaging/test262.py index 5a1917eaa879390147bd6ea9f4ec24e38062dbde..1e7ad1689eeebcf1761cb5f3bd0d23e7d43af297 100755 --- a/tools/packaging/test262.py +++ b/tools/packaging/test262.py @@ -260,11 +260,14 @@ class TestCase(object): # "var testDescrip = " + str(self.testRecord) + ';\n\n' + \ source = self.suite.GetInclude("cth.js") + \ self.suite.GetInclude("sta.js") + \ - self.suite.GetInclude("ed.js") + \ - self.suite.GetInclude("testBuiltInObject.js") + \ - self.suite.GetInclude("testIntl.js") + \ - self.suite.GetInclude("timer.js") + \ - self.suite.GetInclude("doneprintHandle.js").replace('print', self.suite.print_handle) + \ + self.suite.GetInclude("ed.js") + + if self.IsAsyncTest(): + source = source + \ + self.suite.GetInclude("timer.js") + \ + self.suite.GetInclude("doneprintHandle.js").replace('print', self.suite.print_handle) + + source = source + \ self.GetAdditionalIncludes() + \ self.test + '\n'