sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 1 | var ScriptContext = javax.script.ScriptContext; |
| 2 | |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 3 | if (key == undefined || key != 'engine value') { |
| 4 | throw "unexpected engine scope value"; |
| 5 | } |
| 6 | |
| 7 | // pre-defined context variable refers to current ScriptContext |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 8 | if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') { |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 9 | throw "unexpected global scope value"; |
| 10 | } |
| 11 | |
| 12 | // change the engine scope value |
| 13 | key = 'new engine value'; |
| 14 | |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 15 | if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') { |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 16 | throw "global scope should not change here"; |
| 17 | } |
| 18 | |
| 19 | // delete engine scope value |
| 20 | delete key; |
| 21 | |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 22 | if (key == undefined && key != 'global value') { |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 23 | throw 'global scope should be visible after engine scope removal'; |
| 24 | } |