| 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 |
global.foo = eval; |
| 27 |
global.a = 'global'; |
| 28 |
expect = 'global indirect'; |
| 29 |
actual = String(['a+" indirect"'].map(global.foo)); |
| 30 |
reportCompare(expect, actual, summary + ': global indirect'); |
| 31 |
|
| 32 |
object.foo = eval; |
| 33 |
object.a = 'local'; |
| 34 |
expect = 'EvalError: function eval must be called directly, and not by way of a function of another name'; |
| 35 |
try |
| 36 |
{ |
| 37 |
actual = String(['a+" indirect"'].map(object.foo, object)); |
| 38 |
} |
| 39 |
catch(ex) |
| 40 |
{ |
| 41 |
actual = ex + ''; |
| 42 |
} |
| 43 |
reportCompare(expect, actual, summary + ': local indirect'); |
| 44 |
|
| 45 |
exitFunc ('test'); |
| 46 |
} |