author | sundar |
Fri, 20 Sep 2013 22:37:08 +0530 | |
changeset 20219 | 809c0f893cb0 |
parent 18615 | 3f6e6adcbc1a |
child 24778 | 2ff5d7041566 |
permissions | -rw-r--r-- |
18615
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
1 |
/* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
4 |
* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
8 |
* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
14 |
* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
18 |
* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
21 |
* questions. |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
22 |
*/ |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
23 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
24 |
/** |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
25 |
* JDK-8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223 |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
26 |
* |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
27 |
* @test |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
28 |
* @option -scripting |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
29 |
* @run |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
30 |
*/ |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
31 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
32 |
var m = new javax.script.ScriptEngineManager(); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
33 |
var e = m.getEngineByName("nashorn"); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
34 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
35 |
e.eval(<<EOF |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
36 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
37 |
'use strict'; |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
38 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
39 |
try { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
40 |
context = 444; |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
41 |
print("FAILED!! context write should have thrown error"); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
42 |
} catch (e) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
43 |
if (! (e instanceof TypeError)) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
44 |
print("TypeError expected but got " + e); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
45 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
46 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
47 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
48 |
try { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
49 |
engine = "hello"; |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
50 |
print("FAILED!! engine write should have thrown error"); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
51 |
} catch (e) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
52 |
if (! (e instanceof TypeError)) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
53 |
print("TypeError expected but got " + e); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
54 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
55 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
56 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
57 |
try { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
58 |
delete context; |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
59 |
print("FAILED!! context delete should have thrown error"); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
60 |
} catch (e) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
61 |
if (! (e instanceof SyntaxError)) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
62 |
print("SyntaxError expected but got " + e); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
63 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
64 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
65 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
66 |
try { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
67 |
delete engine; |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
68 |
print("FAILED!! engine delete should have thrown error"); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
69 |
} catch (e) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
70 |
if (! (e instanceof SyntaxError)) { |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
71 |
print("SyntaxError expected but got " + e); |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
72 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
73 |
} |
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
74 |
|
3f6e6adcbc1a
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
sundar
parents:
diff
changeset
|
75 |
EOF); |