| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-382509.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 382509; |
| 9 |
var summary = 'Disallow non-global indirect eval'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
var global = typeof window == 'undefined' ? this : window; |
| 14 |
var object = {}; |
| 15 |
|
| 16 |
|
| 17 |
test(); |
| 18 |
|
| 19 |
|
| 20 |
function test() |
| 21 |
{ |
| 22 |
enterFunc ('test'); |
| 23 |
printBugNumber(BUGNUMBER); |
| 24 |
printStatus (summary); |
| 25 |
|
| 26 |
if (options().match(/strict/)) |
| 27 |
{ |
| 28 |
options('strict'); |
| 29 |
} |
| 30 |
if (options().match(/werror/)) |
| 31 |
{ |
| 32 |
options('werror'); |
| 33 |
} |
| 34 |
|
| 35 |
global.foo = eval; |
| 36 |
global.a = 'global'; |
| 37 |
expect = 'global indirect'; |
| 38 |
actual = global.foo('a+" indirect"'); |
| 39 |
reportCompare(expect, actual, summary + ': global indirect'); |
| 40 |
|
| 41 |
object.foo = eval; |
| 42 |
object.a = 'local'; |
| 43 |
expect = 'EvalError: function eval must be called directly, and not by way of a function of another name'; |
| 44 |
try |
| 45 |
{ |
| 46 |
actual = object.foo('a+" indirect"'); |
| 47 |
} |
| 48 |
catch(ex) |
| 49 |
{ |
| 50 |
actual = ex + ''; |
| 51 |
} |
| 52 |
reportCompare(expect, actual, summary + ': local indirect'); |
| 53 |
|
| 54 |
options('strict'); |
| 55 |
options('werror'); |
| 56 |
|
| 57 |
try |
| 58 |
{ |
| 59 |
var foo = eval; |
| 60 |
print("foo(1+1)" + foo('1+1')); |
| 61 |
actual = 'No Error'; |
| 62 |
} |
| 63 |
catch(ex) |
| 64 |
{ |
| 65 |
actual = ex + ''; |
| 66 |
} |
| 67 |
reportCompare(expect, actual, summary + ': strict, rename warning'); |
| 68 |
|
| 69 |
options('strict'); |
| 70 |
options('werror'); |
| 71 |
|
| 72 |
expect = 'No Error'; |
| 73 |
try |
| 74 |
{ |
| 75 |
var foo = eval; |
| 76 |
foo('1+1'); |
| 77 |
actual = 'No Error'; |
| 78 |
} |
| 79 |
catch(ex) |
| 80 |
{ |
| 81 |
actual = ex + ''; |
| 82 |
} |
| 83 |
reportCompare(expect, actual, summary + ': not strict, no rename warning'); |
| 84 |
|
| 85 |
exitFunc ('test'); |
| 86 |
} |