blob: 5f7aba45e935feaf2002358b5e527962af8cac6a [file] [log] [blame]
sundaraffd2db2013-02-27 17:22:44 +05301var ScriptContext = javax.script.ScriptContext;
2
duke6e45e102007-12-01 00:00:00 +00003if (key == undefined || key != 'engine value') {
4 throw "unexpected engine scope value";
5}
6
7// pre-defined context variable refers to current ScriptContext
sundaraffd2db2013-02-27 17:22:44 +05308if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
duke6e45e102007-12-01 00:00:00 +00009 throw "unexpected global scope value";
10}
11
12// change the engine scope value
13key = 'new engine value';
14
sundaraffd2db2013-02-27 17:22:44 +053015if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
duke6e45e102007-12-01 00:00:00 +000016 throw "global scope should not change here";
17}
18
19// delete engine scope value
20delete key;
21
sundaraffd2db2013-02-27 17:22:44 +053022if (key == undefined && key != 'global value') {
duke6e45e102007-12-01 00:00:00 +000023 throw 'global scope should be visible after engine scope removal';
24}