jdk/test/javax/script/Test3.js
author mchung
Mon, 27 Oct 2014 13:45:39 -0700
changeset 27260 8d82d0e9556b
parent 16038 de84354579d3
permissions -rw-r--r--
8043277: Update jdk regression tests to extend the default security policy instead of override Reviewed-by: alanb, mullan, chegar, sla
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
     1
var ScriptContext = javax.script.ScriptContext;
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
     2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
if (key == undefined || key != 'engine value') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
    throw "unexpected engine scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
// pre-defined context variable refers to current ScriptContext
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
     8
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
    throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
// change the engine scope value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
key = 'new engine value';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
    15
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
    throw "global scope should not change here";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
// delete engine scope value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
delete key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
    22
if (key == undefined && key != 'global value') {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
    throw 'global scope should be visible after engine scope removal';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
}