aboutsummaryrefslogtreecommitdiff
path: root/test/src/jdk/nashorn/api
diff options
context:
space:
mode:
authorRaluca Sauciuc <ralucas@google.com>2017-06-12 15:34:33 -0700
committerRaluca Sauciuc <ralucas@google.com>2017-06-12 15:34:33 -0700
commit45faba88ae10e979db10142c68d02d986018010a (patch)
tree86b2ed40695204fc7df974bd10b3d6d2ba4de5db /test/src/jdk/nashorn/api
parentec3fecc6e531797f5525c3fd32fe547ea591f0ea (diff)
parent4dd3addbb05bb4225f6d14e53dc7d5f6e26c868d (diff)
downloadjdk8u_nashorn-45faba88ae10e979db10142c68d02d986018010a.tar.gz
Merge 'jetbrains-master-mirror' into studio-master-dev
This adds upstream's latest changes from branch 884, see https://github.com/JetBrains/jdk8u_nashorn/compare/736...884
Diffstat (limited to 'test/src/jdk/nashorn/api')
-rw-r--r--test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java b/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java
index f9c78fc7..7656dc6b 100644
--- a/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java
+++ b/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java
@@ -41,6 +41,7 @@ import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.AbstractJSObject;
import jdk.nashorn.api.scripting.JSObject;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
import org.testng.annotations.Test;
@@ -386,4 +387,41 @@ public class ScriptObjectMirrorTest {
assertTrue(func.isFunction());
assertEquals(func.call(e.eval("this"), "hello"), "hello world");
}
+
+ // @bug 8170565: JSObject call() is passed undefined for the argument 'thiz'
+ @Test
+ public void jsObjectThisTest() throws Exception {
+ final ScriptEngineManager engineManager = new ScriptEngineManager();
+ final ScriptEngine e = engineManager.getEngineByName("nashorn");
+ e.put("func", new AbstractJSObject() {
+ @Override
+ public boolean isFunction() { return true; }
+
+ @Override
+ public Object call(Object thiz, Object...args) {
+ return thiz;
+ }
+ });
+
+ assertTrue((boolean)e.eval("func() === this"));
+
+ // check that there is no blind undefined->Global translation!
+ assertTrue((boolean)e.eval("typeof(Function.prototype.call.call(func, undefined)) == 'undefined'"));
+
+ // make sure that strict functions don't get translated this for scope calls!
+ e.put("sfunc", new AbstractJSObject() {
+ @Override
+ public boolean isFunction() { return true; }
+
+ @Override
+ public boolean isStrictFunction() { return true; }
+
+ @Override
+ public Object call(Object thiz, Object...args) {
+ return thiz;
+ }
+ });
+
+ assertTrue((boolean)e.eval("typeof sfunc() == 'undefined'"));
+ }
}