Debian Codegraph @

rhino/testsrc/tests/js1_6/Regress/regress-382509.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
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 }