java-topology/test/jdk/javax/script/Test3.js
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

24 lines
692 B
JavaScript

var ScriptContext = javax.script.ScriptContext;
if (key == undefined || key != 'engine value') {
throw "unexpected engine scope value";
}
// pre-defined context variable refers to current ScriptContext
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
throw "unexpected global scope value";
}
// change the engine scope value
key = 'new engine value';
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
throw "global scope should not change here";
}
// delete engine scope value
delete key;
if (key == undefined && key != 'global value') {
throw 'global scope should be visible after engine scope removal';
}