diff --git a/test/harness/ed.js b/test/harness/ed.js index 1c5cabd8e831572e79e2b3add66693ee984bfd98..6d652a9104f5a4c9dfedddcf8a56d29f68c97e44 100644 --- a/test/harness/ed.js +++ b/test/harness/ed.js @@ -6,9 +6,20 @@ //Error Detector if (this.window!==undefined) { //for console support - this.window.onerror = function(errorMsg, url, lineNumber) { - this.window.iframeError = errorMsg; - if(typeof $DONE === 'function') $DONE(); + this.window.onerror = function(errorMsg, url, lineNumber, colNumber, error) { + var cookedError; + + if (error) { + cookedError = error.toString(); + } else { + if (/Error:/.test(errorMsg)) { + cookedError = errorMsg; + } else { + cookedError = "UnknownError: " + errorMsg; + } + } + + $DONE(cookedError); }; } diff --git a/test/harness/gs.js b/test/harness/gs.js index 855cb85bf40b5bf2527510a280dd151ddfd8b614..abb0dec35832edd8f27cc67f7b128459a5449c79 100644 --- a/test/harness/gs.js +++ b/test/harness/gs.js @@ -5,68 +5,66 @@ /// copyright and this notice and otherwise comply with the Use Terms. //Global Scope Test Case Validator -function $DONE() { +var doneCalled; +function $DONE(argError) { + + var testError; + var result, resultError; + + if (argError) { + testError = argError.toString(); + } + + if (doneCalled) { + // ? log called twice + return; + } + doneCalled = true; //An exception is expected if (testDescrip.negative !== undefined) { //TODO - come up with a generic way of catching the error type //from this.onerror - testDescrip.negative = testDescrip.negative === "NotEarlyError" ? - testDescrip.negative : - (testDescrip.negative === "^((?!NotEarlyError).)*$" ? - testDescrip.negative : "."); - if (this.iframeError === undefined) { //no exception was thrown - testRun(testDescrip.id, - testDescrip.path, - testDescrip.description, - testDescrip.code, - 'fail', - Error('No exception was thrown; expected an error "message"' + - ' property matching the regular expression "' + - testDescrip.negative + '".')); - } else if (!(new RegExp(testDescrip.negative, - "i").test(this.iframeError))) { + + var negRegexp = new RegExp(testDescrip.negative, "i"), + unkRegexp = /^UnknownError:/; + + + if (!testError) { //no exception was thrown + result = 'fail'; + resultError = Error('No exception was thrown; expected an error "message"' + + ' property matching the regular expression "' + + testDescrip.negative + '".'); + } else if (!negRegexp.test(testError) && + !unkRegexp.test(testError)) { //wrong type of exception thrown - testRun(testDescrip.id, - testDescrip.path, - testDescrip.description, - testDescrip.code, - 'fail', - Error('Expected an exception with a "message"' + - ' property matching the regular expression "' + - testDescrip.negative + - '" to be thrown; actual was "' + - this.iframeError + '".')); + result = 'fail'; + resultError = Error('Expected an exception with a "message"' + + ' property matching the regular expression "' + + testDescrip.negative + + '" to be thrown; actual was "' + + testError + '".'); + } else { - testRun(testDescrip.id, - testDescrip.path, - testDescrip.description, - testDescrip.code, - 'pass', - undefined); + result = 'pass'; + resultError = 'undefined'; } + } else if (testError) { + //Exception was not expected to be thrown + result = 'fail'; + resultError = Error('Unexpected exception, "' + testError + '" was thrown.'); + } else { + result = 'pass'; + resultError = undefined; } - //Exception was not expected to be thrown - else if (this.iframeError !== undefined) { - testRun(testDescrip.id, - testDescrip.path, - testDescrip.description, - testDescrip.code, - 'fail', - Error('Unexpected exception, "' + - this.iframeError + '" was thrown.')); - } - - else { - testRun(testDescrip.id, - testDescrip.path, - testDescrip.description, - testDescrip.code, - 'pass', - undefined); - } + testRun(testDescrip.id, + testDescrip.path, + testDescrip.description, + testDescrip.code, + result, + resultError); //teardown testFinished(); -} \ No newline at end of file +} diff --git a/test/harness/sth.js b/test/harness/sth.js index 3acb5b6b2a3e2f2514ed4b7d30725c79e640c2fa..c3f94c6b8a00ef6607c55179e56ce4de7793b11f 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -129,7 +129,7 @@ function BrowserRunner() { //TODO - 500ms *should* be a sufficient delay setTimeout(function() { - instance.supportsWindowOnerror = iwinPrereqs.failCount === 2; + instance.supportsWindowOnerror = (iwinPrereqs.failCount === 2); //alert(iwinPrereqs.failCount); document.body.removeChild(iframePrereqs); instance.run(test, code); diff --git a/test/suite/ch08/8.7/S8.7.1_A2.js b/test/suite/ch08/8.7/S8.7.1_A2.js index 921775fa7c772c6ecff6ecbcf51ee61364fc3e6b..70fbfd7dc29b0381e51b37c497234450e7932f0c 100644 --- a/test/suite/ch08/8.7/S8.7.1_A2.js +++ b/test/suite/ch08/8.7/S8.7.1_A2.js @@ -14,8 +14,9 @@ var y = 1; ////////////////////////////////////////////////////////////////////////////// //CHECK#1 -if(delete y){ - $ERROR('#1: y = 1; (delete y) === false. Actual: ' + ((delete y))); +var result = delete y; +if(result){ + $ERROR('#1: y = 1; (delete y) === false. Actual: ' + result); }; // //////////////////////////////////////////////////////////////////////////////