From 08a7f7433a2db1e0329752d16561a745c2805b20 Mon Sep 17 00:00:00 2001 From: David Fugate Date: Thu, 7 Apr 2011 10:12:45 -0700 Subject: [PATCH] Few minor changes to sta.js and sth.js to support Strict Mode. Renamed move_test.py to FixTestCasePlacement.py. Still a work in progress. --- test/harness/sta.js | 14 +++++++++++++- test/harness/sth.js | 3 ++- .../misc/{move_test.py => FixTestCasePlacement.py} | 0 3 files changed, 15 insertions(+), 2 deletions(-) rename tools/misc/{move_test.py => FixTestCasePlacement.py} (100%) diff --git a/test/harness/sta.js b/test/harness/sta.js index fd3873438a..19547c223d 100644 --- a/test/harness/sta.js +++ b/test/harness/sta.js @@ -141,10 +141,22 @@ SimpleTestAPIs.push(fnSupportsStrict); //----------------------------------------------------------------------------- function fnGlobalObject() { - return (function() { return this }).call(null); + return Function("return this")(); } SimpleTestAPIs.push(fnGlobalObject); +//----------------------------------------------------------------------------- +function fnSupportsStrict() { + "use strict"; + try { + eval('with ({}) {}'); + return false; + } catch (e) { + return true; + } +} +SimpleTestAPIs.push(fnSupportsStrict); + //----------------------------------------------------------------------------- //Verify all attributes specified data property of given object: value, writable, enumerable, configurable //If all attribute values are expected, return true, otherwise, return false diff --git a/test/harness/sth.js b/test/harness/sth.js index 5d533f9743..fc83cfbf34 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -129,7 +129,8 @@ function BrowserRunner() { " 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 {" + - " try { var res = test.test.call(window); } catch(e) { res = 'fail'; error = e; }" + + " 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);" + " }" + diff --git a/tools/misc/move_test.py b/tools/misc/FixTestCasePlacement.py similarity index 100% rename from tools/misc/move_test.py rename to tools/misc/FixTestCasePlacement.py