aboutsummaryrefslogtreecommitdiffstats
path: root/website
diff options
context:
space:
mode:
authorDavid Fugate <dfugate@microsoft.com>2011-04-20 15:39:50 -0700
committerDavid Fugate <dfugate@microsoft.com>2011-04-20 15:39:50 -0700
commitef45786a2144177c364a2bf3ba8b5d3282aa1afb (patch)
tree98d63836e8dfce5c38b9faa2dd9fece0f1045b5d /website
parentb055423983aa1739f41b25da2ab825e5b61f4a86 (diff)
A major web browser does not fire window.onerror for iframes when the iframe's document
contains a JavaScript syntax error (major test area). Added a workaround.
Diffstat (limited to 'website')
-rw-r--r--website/resources/scripts/global/sth.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/website/resources/scripts/global/sth.js b/website/resources/scripts/global/sth.js
index d312fc01a..aa42bd23d 100644
--- a/website/resources/scripts/global/sth.js
+++ b/website/resources/scripts/global/sth.js
@@ -91,7 +91,7 @@ function BrowserRunner() {
// Set up some globals.
win.testRun = testRun;
win.testFinished = testFinished;
- win.iframeError = undefined;
+
//TODO: these should be moved to sta.js
win.SputnikError = SputnikError;
win.$ERROR = $ERROR;
@@ -125,16 +125,23 @@ function BrowserRunner() {
//--Scenario 1: we're dealing with a global scope test case
if (GlobalScopeTests[id]!==undefined) {
+ win.iframeError = undefined;
+ win.onerror = undefined;
+ win.onErrorHack = undefined;
var testDescrip = GlobalScopeTests[id];
-
+
//Add an error handler
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'>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.iframeError===undefined) { //no exception was thrown
+ 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
@@ -150,7 +157,7 @@ function BrowserRunner() {
} else {
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 {