aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/tests
diff options
context:
space:
mode:
authorandrew <devnull@localhost>2010-10-19 17:55:59 +0100
committerandrew <devnull@localhost>2010-10-19 17:55:59 +0100
commit7603e948d7a0a7eb2e72358cb4a40ae6779f95da (patch)
treec6441f7d14eafe8119d890cddd09b05b8f88c52a /plugin/tests
Initial import from IcedTea6.
2010-10-19 Andrew John Hughes <[email protected]> * .hgignore, * Makefile.am, * acinclude.m4, * autogen.sh, * configure.ac, * extra/net/sourceforge/jnlp/about/HTMLPanel.java, * extra/net/sourceforge/jnlp/about/Main.java, * extra/net/sourceforge/jnlp/about/resources/about.html, * extra/net/sourceforge/jnlp/about/resources/applications.html, * extra/net/sourceforge/jnlp/about/resources/notes.html, * javac.in, * javaws.desktop: Imported from IcedTea6. * launcher/java.c, * launcher/java.h, * launcher/java_md.c, * launcher/java_md.h, * launcher/jli_util.h, * launcher/jni.h, * launcher/jvm.h, * launcher/jvm_md.h, * launcher/manifest_info.h, * launcher/splashscreen.h, * launcher/splashscreen_stubs.c, * launcher/version_comp.h, * launcher/wildcard.h: Imported from OpenJDK. * netx/javaws.1, * netx/javax/jnlp/BasicService.java, * netx/javax/jnlp/ClipboardService.java, * netx/javax/jnlp/DownloadService.java, * netx/javax/jnlp/DownloadServiceListener.java, * netx/javax/jnlp/ExtendedService.java, * netx/javax/jnlp/ExtensionInstallerService.java, * netx/javax/jnlp/FileContents.java, * netx/javax/jnlp/FileOpenService.java, * netx/javax/jnlp/FileSaveService.java, * netx/javax/jnlp/JNLPRandomAccessFile.java, * netx/javax/jnlp/PersistenceService.java, * netx/javax/jnlp/PrintService.java, * netx/javax/jnlp/ServiceManager.java, * netx/javax/jnlp/ServiceManagerStub.java, * netx/javax/jnlp/SingleInstanceListener.java, * netx/javax/jnlp/SingleInstanceService.java, * netx/javax/jnlp/UnavailableServiceException.java, * netx/net/sourceforge/jnlp/AppletDesc.java, * netx/net/sourceforge/jnlp/ApplicationDesc.java, * netx/net/sourceforge/jnlp/AssociationDesc.java, * netx/net/sourceforge/jnlp/ComponentDesc.java, * netx/net/sourceforge/jnlp/DefaultLaunchHandler.java, * netx/net/sourceforge/jnlp/ExtensionDesc.java, * netx/net/sourceforge/jnlp/IconDesc.java, * netx/net/sourceforge/jnlp/InformationDesc.java, * netx/net/sourceforge/jnlp/InstallerDesc.java, * netx/net/sourceforge/jnlp/JARDesc.java, * netx/net/sourceforge/jnlp/JNLPFile.java, * netx/net/sourceforge/jnlp/JNLPSplashScreen.java, * netx/net/sourceforge/jnlp/JREDesc.java, * netx/net/sourceforge/jnlp/LaunchException.java, * netx/net/sourceforge/jnlp/LaunchHandler.java, * netx/net/sourceforge/jnlp/Launcher.java, * netx/net/sourceforge/jnlp/MenuDesc.java, * netx/net/sourceforge/jnlp/NetxPanel.java, * netx/net/sourceforge/jnlp/Node.java, * netx/net/sourceforge/jnlp/PackageDesc.java, * netx/net/sourceforge/jnlp/ParseException.java, * netx/net/sourceforge/jnlp/Parser.java, * netx/net/sourceforge/jnlp/PluginBridge.java, * netx/net/sourceforge/jnlp/PropertyDesc.java, * netx/net/sourceforge/jnlp/RelatedContentDesc.java, * netx/net/sourceforge/jnlp/ResourcesDesc.java, * netx/net/sourceforge/jnlp/SecurityDesc.java, * netx/net/sourceforge/jnlp/ShortcutDesc.java, * netx/net/sourceforge/jnlp/StreamEater.java, * netx/net/sourceforge/jnlp/UpdateDesc.java, * netx/net/sourceforge/jnlp/Version.java, * netx/net/sourceforge/jnlp/cache/CacheEntry.java, * netx/net/sourceforge/jnlp/cache/CacheUtil.java, * netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java, * netx/net/sourceforge/jnlp/cache/DownloadIndicator.java, * netx/net/sourceforge/jnlp/cache/Resource.java, * netx/net/sourceforge/jnlp/cache/ResourceTracker.java, * netx/net/sourceforge/jnlp/cache/UpdatePolicy.java, * netx/net/sourceforge/jnlp/cache/package.html, * netx/net/sourceforge/jnlp/event/ApplicationEvent.java, * netx/net/sourceforge/jnlp/event/ApplicationListener.java, * netx/net/sourceforge/jnlp/event/DownloadEvent.java, * netx/net/sourceforge/jnlp/event/DownloadListener.java, * netx/net/sourceforge/jnlp/event/package.html, * netx/net/sourceforge/jnlp/package.html, * netx/net/sourceforge/jnlp/resources/Manifest.mf, * netx/net/sourceforge/jnlp/resources/Messages.properties, * netx/net/sourceforge/jnlp/resources/about.jnlp, * netx/net/sourceforge/jnlp/resources/default.jnlp, * netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java, * netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java, * netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java, * netx/net/sourceforge/jnlp/runtime/AppletInstance.java, * netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java, * netx/net/sourceforge/jnlp/runtime/Boot.java, * netx/net/sourceforge/jnlp/runtime/Boot13.java, * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java, * netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java, * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java, * netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java, * netx/net/sourceforge/jnlp/runtime/package.html, * netx/net/sourceforge/jnlp/security/AccessWarningPane.java, * netx/net/sourceforge/jnlp/security/AppletWarningPane.java, * netx/net/sourceforge/jnlp/security/CertVerifier.java, * netx/net/sourceforge/jnlp/security/CertWarningPane.java, * netx/net/sourceforge/jnlp/security/CertsInfoPane.java, * netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java, * netx/net/sourceforge/jnlp/security/MoreInfoPane.java, * netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java, * netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java, * netx/net/sourceforge/jnlp/security/SecurityUtil.java, * netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java, * netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java, * netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java, * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java, * netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java, * netx/net/sourceforge/jnlp/services/ExtendedSingleInstanceService.java, * netx/net/sourceforge/jnlp/services/InstanceExistsException.java, * netx/net/sourceforge/jnlp/services/ServiceUtil.java, * netx/net/sourceforge/jnlp/services/SingleInstanceLock.java, * netx/net/sourceforge/jnlp/services/XBasicService.java, * netx/net/sourceforge/jnlp/services/XClipboardService.java, * netx/net/sourceforge/jnlp/services/XDownloadService.java, * netx/net/sourceforge/jnlp/services/XExtendedService.java, * netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java, * netx/net/sourceforge/jnlp/services/XFileContents.java, * netx/net/sourceforge/jnlp/services/XFileOpenService.java, * netx/net/sourceforge/jnlp/services/XFileSaveService.java, * netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java, * netx/net/sourceforge/jnlp/services/XPersistenceService.java, * netx/net/sourceforge/jnlp/services/XPrintService.java, * netx/net/sourceforge/jnlp/services/XServiceManagerStub.java, * netx/net/sourceforge/jnlp/services/XSingleInstanceService.java, * netx/net/sourceforge/jnlp/services/package.html, * netx/net/sourceforge/jnlp/tools/CharacterEncoder.java, * netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java, * netx/net/sourceforge/jnlp/tools/JarRunner.java, * netx/net/sourceforge/jnlp/tools/JarSigner.java, * netx/net/sourceforge/jnlp/tools/JarSignerResources.java, * netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java, * netx/net/sourceforge/jnlp/tools/KeyTool.java, * netx/net/sourceforge/jnlp/util/FileUtils.java, * netx/net/sourceforge/jnlp/util/PropertiesFile.java, * netx/net/sourceforge/jnlp/util/Reflect.java, * netx/net/sourceforge/jnlp/util/WeakList.java, * netx/net/sourceforge/jnlp/util/XDesktopEntry.java, * netx/net/sourceforge/nanoxml/XMLElement.java, * netx/net/sourceforge/nanoxml/XMLParseException.java, * plugin/icedteanp/IcedTeaJavaRequestProcessor.cc, * plugin/icedteanp/IcedTeaJavaRequestProcessor.h, * plugin/icedteanp/IcedTeaNPPlugin.cc, * plugin/icedteanp/IcedTeaNPPlugin.h, * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc, * plugin/icedteanp/IcedTeaPluginRequestProcessor.h, * plugin/icedteanp/IcedTeaPluginUtils.cc, * plugin/icedteanp/IcedTeaPluginUtils.h, * plugin/icedteanp/IcedTeaRunnable.cc, * plugin/icedteanp/IcedTeaRunnable.h, * plugin/icedteanp/IcedTeaScriptablePluginObject.cc, * plugin/icedteanp/IcedTeaScriptablePluginObject.h, * plugin/icedteanp/java/netscape/javascript/JSException.java, * plugin/icedteanp/java/netscape/javascript/JSObject.java, * plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java, * plugin/icedteanp/java/netscape/javascript/JSProxy.java, * plugin/icedteanp/java/netscape/javascript/JSRunnable.java, * plugin/icedteanp/java/netscape/javascript/JSUtil.java, * plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java, * plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java, * plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java, * plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java, * plugin/icedteanp/java/sun/applet/JavaConsole.java, * plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java, * plugin/icedteanp/java/sun/applet/PasswordAuthenticationDialog.java, * plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java, * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java, * plugin/icedteanp/java/sun/applet/PluginCallRequest.java, * plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java, * plugin/icedteanp/java/sun/applet/PluginClassLoader.java, * plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java, * plugin/icedteanp/java/sun/applet/PluginCookieManager.java, * plugin/icedteanp/java/sun/applet/PluginDebug.java, * plugin/icedteanp/java/sun/applet/PluginException.java, * plugin/icedteanp/java/sun/applet/PluginMain.java, * plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java, * plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java, * plugin/icedteanp/java/sun/applet/PluginObjectStore.java, * plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java, * plugin/icedteanp/java/sun/applet/PluginProxySelector.java, * plugin/icedteanp/java/sun/applet/PluginStreamHandler.java, * plugin/icedteanp/java/sun/applet/RequestQueue.java, * plugin/icedteanp/java/sun/applet/TestEnv.java, * plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java, * plugin/tests/LiveConnect/DummyObject.java, * plugin/tests/LiveConnect/OverloadTestHelper1.java, * plugin/tests/LiveConnect/OverloadTestHelper2.java, * plugin/tests/LiveConnect/OverloadTestHelper3.java, * plugin/tests/LiveConnect/PluginTest.java, * plugin/tests/LiveConnect/build, * plugin/tests/LiveConnect/common.js, * plugin/tests/LiveConnect/index.html, * plugin/tests/LiveConnect/jjs_eval_test.js, * plugin/tests/LiveConnect/jjs_func_parameters_tests.js, * plugin/tests/LiveConnect/jjs_func_rettype_tests.js, * plugin/tests/LiveConnect/jjs_get_tests.js, * plugin/tests/LiveConnect/jjs_set_tests.js, * plugin/tests/LiveConnect/jsj_func_overload_tests.js, * plugin/tests/LiveConnect/jsj_func_parameters_tests.js, * plugin/tests/LiveConnect/jsj_func_rettype_tests.js, * plugin/tests/LiveConnect/jsj_get_tests.js, * plugin/tests/LiveConnect/jsj_set_tests.js, * plugin/tests/LiveConnect/jsj_type_casting_tests.js, * plugin/tests/LiveConnect/jsj_type_conversion_tests.js: Initial import from IcedTea6. * AUTHORS, * COPYING * INSTALL, * NEWS, * README: New documentation.
Diffstat (limited to 'plugin/tests')
-rw-r--r--plugin/tests/LiveConnect/DummyObject.java15
-rw-r--r--plugin/tests/LiveConnect/OverloadTestHelper1.java1
-rw-r--r--plugin/tests/LiveConnect/OverloadTestHelper2.java1
-rw-r--r--plugin/tests/LiveConnect/OverloadTestHelper3.java1
-rw-r--r--plugin/tests/LiveConnect/PluginTest.java710
-rwxr-xr-xplugin/tests/LiveConnect/build18
-rw-r--r--plugin/tests/LiveConnect/common.js219
-rw-r--r--plugin/tests/LiveConnect/index.html91
-rw-r--r--plugin/tests/LiveConnect/jjs_eval_test.js57
-rw-r--r--plugin/tests/LiveConnect/jjs_func_parameters_tests.js107
-rw-r--r--plugin/tests/LiveConnect/jjs_func_rettype_tests.js61
-rw-r--r--plugin/tests/LiveConnect/jjs_get_tests.js114
-rw-r--r--plugin/tests/LiveConnect/jjs_set_tests.js314
-rw-r--r--plugin/tests/LiveConnect/jsj_func_overload_tests.js181
-rw-r--r--plugin/tests/LiveConnect/jsj_func_parameters_tests.js216
-rw-r--r--plugin/tests/LiveConnect/jsj_func_rettype_tests.js262
-rw-r--r--plugin/tests/LiveConnect/jsj_get_tests.js260
-rw-r--r--plugin/tests/LiveConnect/jsj_set_tests.js318
-rw-r--r--plugin/tests/LiveConnect/jsj_type_casting_tests.js825
-rw-r--r--plugin/tests/LiveConnect/jsj_type_conversion_tests.js825
20 files changed, 4596 insertions, 0 deletions
diff --git a/plugin/tests/LiveConnect/DummyObject.java b/plugin/tests/LiveConnect/DummyObject.java
new file mode 100644
index 0000000..9f87784
--- /dev/null
+++ b/plugin/tests/LiveConnect/DummyObject.java
@@ -0,0 +1,15 @@
+public class DummyObject {
+ private String str;
+
+ public DummyObject(String s) {
+ this.str = s;
+ }
+
+ public void setStr(String s) {
+ this.str = s;
+ }
+
+ public String toString() {
+ return str;
+ }
+}
diff --git a/plugin/tests/LiveConnect/OverloadTestHelper1.java b/plugin/tests/LiveConnect/OverloadTestHelper1.java
new file mode 100644
index 0000000..adedd34
--- /dev/null
+++ b/plugin/tests/LiveConnect/OverloadTestHelper1.java
@@ -0,0 +1 @@
+public class OverloadTestHelper1 {}
diff --git a/plugin/tests/LiveConnect/OverloadTestHelper2.java b/plugin/tests/LiveConnect/OverloadTestHelper2.java
new file mode 100644
index 0000000..4ae5d57
--- /dev/null
+++ b/plugin/tests/LiveConnect/OverloadTestHelper2.java
@@ -0,0 +1 @@
+public class OverloadTestHelper2 extends OverloadTestHelper1 {}
diff --git a/plugin/tests/LiveConnect/OverloadTestHelper3.java b/plugin/tests/LiveConnect/OverloadTestHelper3.java
new file mode 100644
index 0000000..c02e784
--- /dev/null
+++ b/plugin/tests/LiveConnect/OverloadTestHelper3.java
@@ -0,0 +1 @@
+public class OverloadTestHelper3 extends OverloadTestHelper2 {}
diff --git a/plugin/tests/LiveConnect/PluginTest.java b/plugin/tests/LiveConnect/PluginTest.java
new file mode 100644
index 0000000..296a141
--- /dev/null
+++ b/plugin/tests/LiveConnect/PluginTest.java
@@ -0,0 +1,710 @@
+import javax.swing.JApplet;
+import java.awt.Graphics;
+import java.awt.*;
+import java.applet.*;
+import java.awt.event.*;
+import netscape.javascript.JSObject;
+import java.lang.reflect.Array;
+
+public class PluginTest extends JApplet {
+
+ public int i = 42;
+ public double d = 42.42;
+ public float f = 42.1F;
+ public long l = 4294967296L;
+ public boolean b = true;
+ public char c = '\u2323';
+ public byte by = 43;
+ public String rs = "I'm a string!";
+ public String ss = "𠁎〒£$ǣ€𝍖";
+ public Object n = null;
+ public int[] ia = new int[5];
+
+ public Integer I = 24;
+ public Double D = 24.24;
+ public Float F = 24.124F;
+ public Long L = 6927694924L;
+ public Boolean B = false;
+ public Character C = '\u1526';
+ public Byte By = 34;
+ public Double[] Da1 = new Double[10];
+ public Double[] Da2 = null;
+
+ public char[] ca = new char[3];
+ public Character[] Ca = new Character[3];
+
+ public void setUpForGMTests() {
+ i = 42;
+ d = 42.42;
+ f = 42.1F;
+ l = 4294967296L;
+ b = true;
+ c = '\u2323';
+ by = 43;
+ rs = "I'm a string!";
+ ss = "𠁎〒£$ǣ€𝍖";
+ n = null;
+
+ I = 24;
+ D = 24.24;
+ F = 24.124F;
+ L = 6927694924L;
+ B = false;
+ C = '\u1526';
+ By = 34;
+
+ ia[4] = 1024;
+ Da1[9] = D;
+ }
+
+ public void setUpForSMTests() {
+ i = 0;
+ d = 0.0;
+ f = 0F;
+ l = 0L;
+ b = false;
+ c = 'A';
+ by = 0;
+ rs = "";
+ ss = "";
+ n = new String("non-null object");
+
+ I = 0;
+ D = 0.0;
+ F = 0F;
+ L = 0L;
+ B = false;
+ C = 'A';
+ By = null;
+
+ ia[4] = 0;
+ Da1[9] = D;
+ }
+
+ /*
+ *****************************************
+ * JS -> Java Parameter conversion tests *
+ *****************************************
+ */
+ public void setUpForReturnTests() {
+ i = 41;
+ d = 41.41;
+ f = 41.411F;
+ l = 4294967297L;
+ b = true;
+ c = '\u2329';
+ by = 44;
+ rs = "I'm a string too!";
+ ss = "𠁎〒£$ǣ€𝍖";
+ n = null;
+
+ I = 14;
+ D = 14.14;
+ F = 14.114F;
+ L = 6927694925L;
+ B = false;
+ C = '\u2417';
+ By = 46;
+ }
+
+ /*
+ **************************************
+ * JS -> Java invocation return tests *
+ **************************************
+ */
+
+ public int intReturnTest() { return i; }
+
+ public double doubleReturnTest() { return d; }
+
+ public float floatReturnTest() { return f; }
+
+ public long longReturnTest() { return l; }
+
+ public boolean booleanReturnTest() { return b; }
+
+ public char charReturnTest() { return c; }
+
+ public byte byteReturnTest() { return by; }
+
+ public char[] charArrayReturnTest() {
+ ca[0] = '\u2410';
+ ca[1] = '\u2411';
+ ca[2] = '\u2412';
+ return ca;
+ }
+
+ public String regularStringReturnTest() { return rs; }
+
+ public String specialStringReturnTest() { return ss; }
+
+ public void voidReturnTest() { }
+
+ public Object nullReturnTest() { return null; }
+
+ public Integer IntegerReturnTest() { return I; }
+
+ public Double DoubleReturnTest() { return D; }
+ public void DoubleSetTest(double set) { D = set; }
+
+ public Float FloatReturnTest() { return F; }
+
+ public Long LongReturnTest() { return L; }
+
+ public Boolean BooleanReturnTest() { return B; }
+
+ public Character CharacterReturnTest() { return C; }
+
+ public Byte ByteReturnTest() { return By; }
+
+ public Character[] CharacterArrayReturnTest() {
+ Ca[0] = '\u2350';
+ Ca[1] = '\u2351';
+ Ca[2] = '\u2352';
+ return Ca;
+ }
+
+ /*
+ **************************************
+ * JS -> Java parameter passing tests *
+ **************************************
+ */
+
+ public void setUpForParameterTests() {
+ i = 41;
+ d = 41.41;
+ f = 41.411F;
+ l = 4294967297L;
+ b = true;
+ c = '\u2329';
+ by = 44;
+ rs = "I'm a string too!";
+ ss = "𠁎〒£$ǣ€𝍖";
+ n = null;
+
+ I = 14;
+ D = 14.14;
+ F = 14.114F;
+ L = 6927694925L;
+ B = false;
+ C = '\u2417';
+ By = 46;
+ }
+
+ public String functioniParamTest(int i) {
+ String ret = Integer.toString(i);
+ return ret;
+ }
+
+ public String functiondParamTest(double d) {
+ String ret = Double.toString(d);
+ return ret;
+ }
+
+ public String functionfParamTest(float f) {
+ String ret = Float.toString(f);
+ return ret;
+ }
+
+ public String functionlParamTest(long l) {
+ String ret = Long.toString(l);
+ return ret;
+ }
+
+ public String functionbParamTest(boolean b) {
+ String ret = Boolean.toString(b);
+ return ret;
+ }
+
+ public String functioncParamTest(char c) {
+ String ret = Character.toString(c);
+ return ret;
+ }
+
+ public String functionbyParamTest(byte b) {
+ String ret = Byte.toString(b);
+ return ret;
+ }
+
+ public String functioncaParamTest(char[] ca) {
+
+ String ret = "";
+ ret += ca[0];
+ for (int i=1 ; i < ca.length; i++) {
+ ret += ":" + ca[i];
+ }
+
+ return ret;
+ }
+
+ public String functionsiaParamTest(String[] s) {
+
+ String ret = s[0];
+ for (int i=1 ; i < s.length; i++) {
+ ret += ":" + s[i];
+ }
+
+ return ret;
+ }
+
+ public String functionsParamTest(String s) {
+ return s + ":" + s.getClass().getName();
+ }
+
+ public String functionIParamTest(Integer p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionDParamTest(Double p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionFParamTest(Float p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionLParamTest(Long p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionBParamTest(Boolean p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionCParamTest(Character p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionBParamTest(Byte p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functionCaParamTest(Character p) {
+ String ret = p.toString() + ":" + p.getClass().getName();
+ return ret;
+ }
+
+ public String functioncomplexaParamTest(DummyObject[] ca) {
+ String ret = ca[0].toString();
+ for (int i=1 ; i < ca.length; i++) {
+ ret += ":" + ca[i].toString();
+ }
+
+ return ret;
+ }
+
+ /*
+ ***********************************************
+ * JS -> Java overload resolution plugin tests *
+ ***********************************************
+ */
+
+ /* Numeric type to the analogous Java primitive type */
+
+ public String foo_num_to_num(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
+
+ // int -> int is lower than:
+ // int to double
+ public String foo_num_to_num(long p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":long"; }
+ // int to String
+ public String foo_num_to_num(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+ /* Null to any non-primitive type */
+ public String foo_null_to_nonprim(Integer p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":Integer"; }
+
+ // Null to non-prim is better than:
+ // null -> prim (not allowed)
+ public String foo_null_to_nonprim(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
+
+
+ /* JSObject to JSObject */
+ public String foo_jso_to_jso(JSObject p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":JSObject"; }
+
+ // JSO -> JSO is better than:
+ // JSO -> String
+ public String foo_jso_to_jso(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+ // JSO -> Java array
+ public String foo_jso_to_jso(String[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+ // JSO -> Superclass (Object)
+ public String foo_jso_to_jso(Object p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+ /* Class type to Class type where the types are equal */
+ public String foo_ct_to_ct(OverloadTestHelper2 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+ // CT -> CT is better than:
+ // CT -> Superclass
+ public String foo_ct_to_ct(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+ // CT->Subclass
+ public String foo_ct_to_ct(OverloadTestHelper3 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+
+ /* Numeric type to a different primitive type */
+ public String foo_multiprim(double p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":double"; }
+
+ // Num -> Diff. prim. is better than:
+ // Better than anything else.. using string as a dummy
+ public String foo_multiprim(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+
+ /* String to numeric */
+ public String foo_strnum(double p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":double"; }
+
+ // Str -> Num is better than:
+ // Anything else .. using OverloadTestHelper1 as a dummy
+ public String foo_strnum(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+ /* Class type to superclass type (with subclass passed) */
+ public String foo_ct_to_sc(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":OverloadTestHelper1"; }
+
+ // CT -> Superclass is better than CT to String
+ public String foo_ct_to_sc(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+
+ /* Any Java value to String */
+ public String foo_jv_to_str(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+ // JV -> Str is better than anything else allowed
+ public String foo_jv_to_str(JSObject p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+
+ /* JSO to Array (lower cost) */
+ public String foo_jso_to_array(int[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int[]"; }
+
+ // JSO to array is better than:
+ // something not possible
+ public String foo_jso_to_array(Integer p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+
+ /****** Not allowed resolutions *******/
+
+ /* null to primitive */
+ public String foo_null_to_prim(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
+
+ /* JSObject to something else */
+ public String foo_jso_to_somethingelse(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+ /* Any other conversion not described ... e.g. sending non-array to array */
+ public String foo_unsupported(Object[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
+
+ /*
+ ******************************
+ * JS -> Java type conversion *
+ ******************************
+ */
+
+ public byte byte_type = 0;
+ public char char_type = 'A';
+ public short short_type = 0;
+ public int int_type = 0;
+ public long long_type = 0L;
+ public float float_type = 0F;
+ public double double_type = 0.0;
+ public boolean boolean_type = false;
+
+ public byte[] byte_array = null;
+ public char[] char_array = null;
+ public short[] short_array = null;
+ public int[] int_array = null;
+ public long[] long_array = null;
+ public float[] float_array = null;
+ public double[] double_array = null;
+ public char[][] char_array_array = null;
+
+ public Byte Byte_type = null;
+ public Character Character_type = 'A';
+ public Short Short_type = 0;
+ public Integer Integer_type = 0;
+ public Long Long_type = 0L;
+ public Float Float_type = 0F;
+ public Double Double_type = 0.0;
+ public String String_type = "";
+ public Boolean Boolean_type = false;
+ public JSObject JSObject_type = null;
+
+ public Byte[] Byte_array = null;
+ public Character[] Character_array = null;
+ public Short[] Short_array = null;
+ public Integer[] Integer_array = null;
+ public Long[] Long_array = null;
+ public Float[] Float_array = null;
+ public Double[] Double_array = null;
+ public String[] String_array = null;
+ public String[][] String_array_array = null;
+
+ public Object Object_type = null;
+
+ public String getArrayAsStr(Object array) {
+ int size = Array.getLength(array);
+
+ String ret = "";
+ for (int i=0; i < size; i++) {
+ ret += Array.get(array, i) == null ? "null" : Array.get(array, i).toString();
+ ret += ",";
+ }
+
+ if (ret.length() > 0) {
+ ret = ret.substring(0, ret.length()-1);
+ }
+
+ return ret;
+ }
+
+ /*
+ **************************
+ **************************
+ * Begin Java -> JS tests *
+ **************************
+ **************************
+ */
+
+ public DummyObject dummyObject = new DummyObject("DummyObject1");
+ public Object value;
+ private JSObject window;
+
+ /*
+ *************************
+ * Java -> JS read tests *
+ *************************
+ */
+
+ public boolean jjsReadIntTest() {
+ value = new Integer(window.getMember("intvar").toString());
+ return ((Integer) value).equals(1);
+ }
+
+ public boolean jjsReadDoubleTest() {
+ value = new Double(window.getMember("doublevar").toString());
+ return ((Double) value).equals(1.1);
+ }
+
+ public boolean jjsReadBooleanTest() {
+ value = new Boolean(window.getMember("boolvar").toString());
+ return ((Boolean) value).equals(true);
+ }
+
+ public boolean jjsReadStringTest() {
+ value = window.getMember("stringvar").toString();
+ return ((String) value).equals("stringvar");
+ }
+
+ public boolean jjsReadObjectTest() {
+ value = window.getMember("objectvar").toString();
+ return value.equals("DummyObject1");
+ }
+
+ public boolean jjsRead1DArrayTest() {
+ value = ((JSObject) window.getMember("arrayvar")).getSlot(1);
+ return value.toString().equals("100");
+ }
+
+ public boolean jjsRead2DArrayTest() {
+ value = ((JSObject) ((JSObject) window.getMember("arrayvar2")).getSlot(1)).getSlot(2);
+ return value.toString().equals("200");
+ }
+
+ /*
+ **************************
+ * Java -> JS write tests *
+ **************************
+ */
+
+ public void jjsSetIntTest() {
+ window.setMember("setvar", (int) 1);
+ }
+
+ public void jjsSetIntegerTest() {
+ window.setMember("setvar", new Integer(2));
+ }
+
+ public void jjsSetdoubleTest() {
+ window.setMember("setvar", (double) 2.1);
+ }
+
+ public void jjsSetDoubleTest() {
+ window.setMember("setvar", new Double(2.2));
+ }
+
+ public void jjsSetfloatTest() {
+ window.setMember("setvar", (float) 2.3);
+ }
+
+ public void jjsSetFloatTest() {
+ window.setMember("setvar", new Float(2.4));
+ }
+
+ public void jjsSetshortTest() {
+ window.setMember("setvar", (short) 3);
+ }
+
+ public void jjsSetShortTest() {
+ window.setMember("setvar", new Short((short) 4));
+ }
+
+ public void jjsSetlongTest() {
+ window.setMember("setvar", (long) 4294967296L);
+ }
+
+ public void jjsSetLongTest() {
+ window.setMember("setvar", new Long(4294967297L));
+ }
+
+ public void jjsSetbyteTest() {
+ window.setMember("setvar", (byte) 5);
+ }
+
+ public void jjsSetByteTest() {
+ window.setMember("setvar", new Byte((byte) 6));
+ }
+
+ public void jjsSetcharTest() {
+ window.setMember("setvar", (char) '\u2323');
+ }
+
+ public void jjsSetCharacterTest() {
+ window.setMember("setvar", new Character('\u2324'));
+ }
+
+ public void jjsSetbooleanTest() {
+ window.setMember("setvar", (boolean) true);
+ }
+
+ public void jjsSetBooleanTest() {
+ window.setMember("setvar", new Boolean(false));
+ }
+
+ public void jjsSetStringTest() {
+ window.setMember("setvar", "𠁎〒£$ǣ€𝍖");
+ }
+
+ public void jjsSetObjectTest() {
+ dummyObject = new DummyObject("DummyObject2");
+ window.setMember("setvar", dummyObject);
+ }
+
+ public void jjsSet1DArrayTest() {
+ ((JSObject) window.getMember("setvar")).setSlot(1, 100);
+ }
+
+ public void jjsSet2DArrayTest() {
+ ((JSObject) ((JSObject) window.getMember("setvar")).getSlot(1)).setSlot(2, 200);
+ }
+
+ /*
+ ****************************************
+ * Java -> JS call parameter conversion *
+ ****************************************
+ */
+
+ public String jjsCallParamTest(String type) {
+
+ Object ret = new Object();
+
+ int i = 1;
+ double d = 1.1;
+ float f = 1.2F;
+ long l = 4294967296L;
+ short s = 2;
+ byte b = 3;
+ char c = '\u2323';
+ boolean bl = true;
+ Integer I = 4;
+ Double D = 4.1;
+ Float F = 4.2F;
+ Long L = 4294967297L;
+ Short S = 5;
+ Byte B = 6;
+ Boolean Bl = false;
+ Character C = '\u2324';
+ String str = "𠁎〒£$ǣ€𝍖";
+ Object o = new DummyObject("d1");
+
+ String callParamTestFuncName = "JJSParameterTypeCallTest";
+
+ if (type.equals("int"))
+ ret = window.call(callParamTestFuncName, new Object[]{i});
+ else if (type.equals("double"))
+ ret = window.call(callParamTestFuncName, new Object[]{d});
+ else if (type.equals("float"))
+ ret = window.call(callParamTestFuncName, new Object[]{f});
+ else if (type.equals("long"))
+ ret = window.call(callParamTestFuncName, new Object[]{l});
+ else if (type.equals("short"))
+ ret = window.call(callParamTestFuncName, new Object[]{s});
+ else if (type.equals("byte"))
+ ret = window.call(callParamTestFuncName, new Object[]{b});
+ else if (type.equals("char"))
+ ret = window.call(callParamTestFuncName, new Object[]{c});
+ else if (type.equals("boolean"))
+ ret = window.call(callParamTestFuncName, new Object[]{bl});
+ else if (type.equals("java.lang.Integer"))
+ ret = window.call(callParamTestFuncName, new Object[]{I});
+ else if (type.equals("java.lang.Double"))
+ ret = window.call(callParamTestFuncName, new Object[]{D});
+ else if (type.equals("java.lang.Float"))
+ ret = window.call(callParamTestFuncName, new Object[]{F});
+ else if (type.equals("java.lang.Long"))
+ ret = window.call(callParamTestFuncName, new Object[]{L});
+ else if (type.equals("java.lang.Short"))
+ ret = window.call(callParamTestFuncName, new Object[]{S});
+ else if (type.equals("java.lang.Byte"))
+ ret = window.call(callParamTestFuncName, new Object[]{B});
+ else if (type.equals("java.lang.Boolean"))
+ ret = window.call(callParamTestFuncName, new Object[]{Bl});
+ else if (type.equals("java.lang.Character"))
+ ret = window.call(callParamTestFuncName, new Object[]{C});
+ else if (type.equals("java.lang.String"))
+ ret = window.call(callParamTestFuncName, new Object[]{str});
+ else if (type.equals("PluginTest.Packages.DummyObject"))
+ ret = window.call(callParamTestFuncName, new Object[]{o});
+ else
+ ret = "Unknown param type: " + type;
+
+ return ret.toString();
+ }
+
+ /*
+ *******************************************
+ * Java -> JS invocation return type tests *
+ *******************************************
+ */
+
+ public String jjsReturnTypeTest(String type) {
+
+ String returnTypeTestFuncName = "JJSReturnTypeCallTest";
+ Object ret = window.call(returnTypeTestFuncName, new Object[]{type});
+
+ return ret.toString();
+ }
+
+
+ /*
+ ***********************************
+ * Java -> JS invocation eval test *
+ ***********************************
+ */
+
+ public String jjsEvalTest(String str) {
+ return window.eval(str).toString();
+ }
+
+ public void init() {
+ window = JSObject.getWindow(this);
+ //JSObject.getWindow(this).call("appletLoaded", new Object[]{});
+ }
+
+}
+
diff --git a/plugin/tests/LiveConnect/build b/plugin/tests/LiveConnect/build
new file mode 100755
index 0000000..a840f28
--- /dev/null
+++ b/plugin/tests/LiveConnect/build
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# change to dir with tests
+cd `dirname $0`
+
+JAVAC=javac
+JAR=jar
+
+if [ ! -z $JAVA_HOME ]; then
+ JAVAC=$JAVA_HOME/bin/javac
+ JAVAC=$JAVA_HOME/bin/jar
+fi
+
+$JAVAC PluginTest.java DummyObject.java OverloadTestHelper*java
+$JAR cf PluginTest.jar PluginTest.class DummyObject.class OverloadTestHelper*class
+rm -f *class
+
+echo "Done. Now launch \"firefox file://`pwd`/index.html\""
diff --git a/plugin/tests/LiveConnect/common.js b/plugin/tests/LiveConnect/common.js
new file mode 100644
index 0000000..a7f807d
--- /dev/null
+++ b/plugin/tests/LiveConnect/common.js
@@ -0,0 +1,219 @@
+/*
+ * Commonly used functions
+ */
+
+ var cell, cellText; // reused
+
+ function updateTotals() {
+ document.getElementById("totals").innerHTML = "<table class=\"results\" width=\"100%\"><tr><th>Total tests run </th><th> Passed </th><th> Failed </th><th> Errors </th></tr>" +
+ "<tr><td>" + (passed+failed+errored) + " </td><td> " + passed + " </td><td> " + failed + " </td><td> " + errored + " </td></tr>";
+ }
+
+ function pass(row) {
+ cell = document.createElement("td");
+ cell.setAttribute("style","color:green;text-align:center;font-weight: bold");
+ cellText = document.createTextNode("passed");
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ passed++;
+ updateTotals();
+ }
+
+ function fail(row, reason) {
+ cell = document.createElement("td");
+ cell.setAttribute("style","color:red;text-align:center;font-weight: bold");
+ if (reason)
+ cellText = document.createTextNode(reason);
+ else
+ cellText = document.createTextNode("failed");
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ failed++;
+ updateTotals();
+ }
+
+ function error(type, expected, e, row) {
+
+ cell = document.createElement("td");
+ cell.setAttribute("style","color:red;text-align:center;font-weight: bold");
+ cell.setAttribute("colspan","5");
+ cellText = document.createTextNode("An error occurred when running this test: " + e);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ errored++;
+ updateTotals();
+ }
+
+ function check(actual, expected, expectedtype, row) {
+ if (actual == expected) {
+ if (typeof(actual) == expectedtype) {
+ pass(row);
+ } else {
+ fail(row, "Type mismatch: " + typeof(actual) + " != " + expectedtype);
+ }
+ } else {
+ fail(row, "Failed: " + actual + " [" + typeof(actual) + "] != " + expected + " [" + typeof(expected) + "]");
+ }
+ }
+
+ function doTest() {
+
+ passed = 0;
+ failed = 0;
+ errored = 0;
+ document.getElementById("results").innerHTML = "";
+ updateTotals();
+
+ try {
+ if (document.getElementById("testForm").jsjget.checked == 1)
+ getMemberTests();
+
+ if (document.getElementById("testForm").jsjset.checked == 1)
+ setMemberTests();
+
+ if (document.getElementById("testForm").jsjfp.checked == 1)
+ fpCallTests();
+
+ if (document.getElementById("testForm").jsjfrt.checked == 1)
+ rtCallTests();
+
+ if (document.getElementById("testForm").jsjfr.checked == 1)
+ frCallTests();
+
+ if (document.getElementById("testForm").jsjtc.checked == 1)
+ typeCastingTests();
+
+ if (document.getElementById("testForm").jjsget.checked == 1)
+ jjsGetMemberTests();
+
+ if (document.getElementById("testForm").jjsset.checked == 1)
+ jjsSetMemberTests();
+
+ if (document.getElementById("testForm").jjcparam.checked == 1)
+ jjsCallParameterTests();
+
+ if (document.getElementById("testForm").jjcrt.checked == 1)
+ jjsCallReturnTypeTests();
+
+ if (document.getElementById("testForm").jjeval.checked == 1)
+ jjsEvalTests();
+ } catch (e) {
+ document.getElementById("results").innerHTML += "<font color=\"red\">ERROR:<BR>" + e;
+ }
+ }
+
+ function testAll() {
+ document.getElementById("testForm").jsjget.checked = 1;
+ document.getElementById("testForm").jsjset.checked = 1;
+ document.getElementById("testForm").jsjfp.checked = 1;
+ document.getElementById("testForm").jsjfrt.checked = 1;
+ document.getElementById("testForm").jsjfr.checked = 1;
+ document.getElementById("testForm").jsjtc.checked = 1;
+ document.getElementById("testForm").jjsget.checked = 1;
+ document.getElementById("testForm").jjsset.checked = 1;
+ document.getElementById("testForm").jjcparam.checked = 1;
+ document.getElementById("testForm").jjcrt.checked = 1;
+ document.getElementById("testForm").jjeval.checked = 1;
+
+ doTest();
+ }
+
+
+var intvar;
+var doublevar;
+var boolvar;
+var stringvar;
+var objectvar;
+var arrayvar;
+var arrayvar2;
+var setvar;
+
+function initVars() {
+ intvar = 1;
+ doublevar = 1.1;
+ boolvar = true;
+ stringvar = "stringvar";
+ objectvar = new PluginTest.Packages.DummyObject("DummyObject1");
+ arrayvar = new Array();
+ arrayvar[1] = 100;
+
+ arrayvar2 = new Array();
+ arrayvar2[1] = new Array();
+ arrayvar2[1][2] = 200;
+}
+
+function createResultTable(tbl, tblBody, columnNames) {
+ tbl.setAttribute("border", "5");
+ tbl.setAttribute("width", "100%");
+ tbl.setAttribute("class", "results");
+ row = document.createElement("tr");
+
+ for (var i=0; i < columnNames.length; i++) {
+ cell = document.createElement("th");
+ cellText = document.createTextNode(columnNames[i]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+ }
+
+ tblBody.appendChild(row);
+ tbl.appendChild(tblBody);
+ document.getElementById("results").appendChild(tbl);
+}
+
+function addResult() {
+
+ var row = arguments[arguments.length-1];
+
+ // Different length arguments imply different width distributions
+
+ if (arguments.length == 4) {
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","25%");
+ cellText = document.createTextNode(arguments[0]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(arguments[1]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","40%");
+ cellText = document.createTextNode(arguments[2]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ } else if (arguments.length == 5) {
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","25%");
+ cellText = document.createTextNode(arguments[0]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(arguments[1]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(arguments[2]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(arguments[3]);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ }
+}
diff --git a/plugin/tests/LiveConnect/index.html b/plugin/tests/LiveConnect/index.html
new file mode 100644
index 0000000..bef16f4
--- /dev/null
+++ b/plugin/tests/LiveConnect/index.html
@@ -0,0 +1,91 @@
+<HTML>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+<HEAD>
+
+ <style type="text/css">
+ table.results {
+ background-color: white;
+ border-collapse: collapse;
+ border-color: black black black black;
+ border-spacing: 0px;
+ border-style: outset outset outset outset;
+ border-width: 0px 0px 0px 0px;
+ }
+
+ table.results th {
+ background-color: white;
+ border-style: inset inset inset inset;
+ border-color: gray gray gray gray;
+ border-width: 1px 1px 1px 1px;
+ padding: 1px 1px 1px 1px;
+ }
+
+ table.results td {
+ background-color: white;
+ border-color: gray gray gray gray;
+ border-style: inset inset inset inset;
+ border-width: 1px 1px 1px 1px;
+ padding: 2px 2px 2px 2px;
+ }
+
+ </style>
+
+ <!-- Load all tests scripts -->
+ <script language="JavaScript" src="common.js"></script>
+ <script language="JavaScript" src="jsj_get_tests.js"></script>
+ <script language="JavaScript" src="jsj_set_tests.js"></script>
+ <script language="JavaScript" src="jsj_func_rettype_tests.js"></script>
+ <script language="JavaScript" src="jsj_func_parameters_tests.js"></script>
+ <script language="JavaScript" src="jsj_func_overload_tests.js"></script>
+ <script language="JavaScript" src="jsj_type_conversion_tests.js"></script>
+ <script language="JavaScript" src="jjs_tests.js"></script>
+ <script language="JavaScript" src="jjs_get_tests.js"></script>
+ <script language="JavaScript" src="jjs_set_tests.js"></script>
+ <script language="JavaScript" src="jjs_func_rettype_tests.js"></script>
+ <script language="JavaScript" src="jjs_func_parameters_tests.js"></script>
+ <script language="JavaScript" src="jjs_eval_test.js"></script>
+
+</HEAD>
+
+<BODY>
+
+<!-- Test selection/launch input -->
+<form id="testForm">
+ <table STYLE="width:100%; float:static">
+ <tr>
+ <td>
+ <input type=checkbox name="jsjget"><tt>JS -> Java read tests</tt><BR>
+ <input type=checkbox name="jsjset"><tt>JS -> Java set tests</tt><BR>
+ <input type=checkbox name="jsjfp"><tt>JS -> Java function parameter conversion tests</tt><BR>
+ <input type=checkbox name="jsjfrt"><tt>JS -> Java function return type tests</tt><BR>
+ <input type=checkbox name="jsjfr"><tt>JS -> Java function resolution tests</tt><BR>
+ </td>
+ <td>
+ <input type=checkbox name="jsjtc"><tt>JS -> Java type conversion tests</tt><BR>
+ <input type=checkbox name="jjsget"><tt>Java -> JS read tests</tt><BR>
+ <input type=checkbox name="jjsset"><tt>Java -> JS set tests</tt><BR>
+ <input type=checkbox name="jjcparam"><tt>Java -> JS function parameter conversion tests</tt><BR>
+ <input type=checkbox name="jjcrt"><tt>Java -> JS function return type tests</tt><BR>
+ <input type=checkbox name="jjeval"><tt>Java -> JS eval test</tt><BR>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type=button id="run_selected" value="Run selected tests" onclick="doTest();">
+ <input type=button id= "run_all" value="Run all tests" onclick="testAll();">
+ </td>
+ </tr>
+ </table>
+</form>
+
+<!-- Results -->
+<DIV ID="RESULTS">
+ <DIV ID="totals" STYLE="width:100%; float:static"></DIV>
+ <DIV ID="results" STYLE="width:100%; float:static"></DIV>
+</DIV>
+
+<APPLET CODE="PluginTest.class" ARCHIVE="PluginTest.jar" NAME="PluginTest" WIDTH="0" HEIGHT=0 MAYSCRIPT></APPLET><BR>
+
+</BODY>
+</HTML>
diff --git a/plugin/tests/LiveConnect/jjs_eval_test.js b/plugin/tests/LiveConnect/jjs_eval_test.js
new file mode 100644
index 0000000..55512df
--- /dev/null
+++ b/plugin/tests/LiveConnect/jjs_eval_test.js
@@ -0,0 +1,57 @@
+/******************************************************
+ * Tests for parameter conversion between Java and JS *
+ ******************************************************/
+
+
+function jjsEvalTests() {
+
+ document.getElementById("results").innerHTML += "<h2>Java -> JS Eval Test:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Evaluating";
+ columnNames[1] = "Expected result";
+ columnNames[2] = "Result";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ evalstr = "document.location";
+ expectedvalue = eval(evalstr);
+ actualValue = PluginTest.jjsEvalTest(evalstr);
+ addResult(evalstr, expectedvalue, actualValue, row);
+ check(actualValue, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ evalstr = "1+1";
+ expectedvalue = eval(evalstr);
+ actualValue = PluginTest.jjsEvalTest(evalstr);
+ addResult(evalstr, expectedvalue, actualValue, row);
+ check(actualValue, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ evalstr = "typeof(true)";
+ expectedvalue = eval(evalstr);
+ actualValue = PluginTest.jjsEvalTest(evalstr);
+ addResult(evalstr, expectedvalue, actualValue, row);
+ check(actualValue, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jjs_func_parameters_tests.js b/plugin/tests/LiveConnect/jjs_func_parameters_tests.js
new file mode 100644
index 0000000..9c34c8e
--- /dev/null
+++ b/plugin/tests/LiveConnect/jjs_func_parameters_tests.js
@@ -0,0 +1,107 @@
+/******************************************************
+ * Tests for parameter conversion between Java and JS *
+ ******************************************************/
+
+function JJSParameterTypeCallTest(type_parameter) {
+ return type_parameter + ":" + typeof(type_parameter);
+}
+
+function runSingleJjsCallParameterTest(type, control_arg, row) {
+ try {
+ expectedvalue = JJSParameterTypeCallTest(control_arg);
+ actualvalue = PluginTest.jjsCallParamTest(type);
+ addResult(type, expectedvalue, actualvalue, row);
+ check(actualvalue, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+}
+
+function jjsCallParameterTests() {
+
+ document.getElementById("results").innerHTML += "<h2>Java -> JS Call tests (Parameter Type):</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Parameter Type (Java side)";
+ columnNames[1] = "Expecting Java to receive";
+ columnNames[2] = "Java Received";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("int", 1, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("double", 1.1, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("float", 1.2000000476837158, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("long", 4294967296, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("short", 2, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("byte", 3, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("char", 8995, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("boolean", true, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Integer", 4, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Double", 4.1, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Float", 4.199999809265137, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Long", 4294967297, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Short", 5, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Byte", 6, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Boolean", false, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.Character", 8996, row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("java.lang.String", "𠁎〒£$ǣ€𝍖", row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJjsCallParameterTest("PluginTest.Packages.DummyObject", (new PluginTest.Packages.DummyObject("d1")), row);
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jjs_func_rettype_tests.js b/plugin/tests/LiveConnect/jjs_func_rettype_tests.js
new file mode 100644
index 0000000..0234204
--- /dev/null
+++ b/plugin/tests/LiveConnect/jjs_func_rettype_tests.js
@@ -0,0 +1,61 @@
+/******************************************************
+ * Tests for parameter conversion between Java and JS *
+ ******************************************************/
+
+function JJSReturnTypeCallTest(type) {
+
+ if (type == "Number")
+ return 1;
+
+ if (type == "Boolean")
+ return false;
+
+ if (type == "String")
+ return "𠁎〒£$ǣ€𝍖";
+
+ if (type == "Object")
+ return window;
+}
+
+function runSingleJJSReturnTypeTest(type, row) {
+ try {
+ expectedvalue = JJSReturnTypeCallTest(type);
+ actualvalue = PluginTest.jjsReturnTypeTest(type);
+ addResult(type, expectedvalue, actualvalue, row);
+ check(actualvalue, expectedvalue + "", "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+}
+
+function jjsCallReturnTypeTests() {
+
+ document.getElementById("results").innerHTML += "<h2>Java -> JS Call tests (Return Type):</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Parameter Type (Java side)";
+ columnNames[1] = "Expected return value";
+ columnNames[2] = "Actual return value";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ row = document.createElement("tr");
+ runSingleJJSReturnTypeTest("Number", row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJJSReturnTypeTest("Boolean", row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJJSReturnTypeTest("String", row);
+ tblBody.appendChild(row);
+
+ row = document.createElement("tr");
+ runSingleJJSReturnTypeTest("Object", row);
+ tblBody.appendChild(row);
+}
diff --git a/plugin/tests/LiveConnect/jjs_get_tests.js b/plugin/tests/LiveConnect/jjs_get_tests.js
new file mode 100644
index 0000000..05c2c8f
--- /dev/null
+++ b/plugin/tests/LiveConnect/jjs_get_tests.js
@@ -0,0 +1,114 @@
+/*****************************************
+ * Tests for reading JS values from Java *
+ *****************************************/
+
+function jjsGetMemberTests() {
+
+ initVars();
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java get tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Member Type";
+ columnNames[1] = "Expected Value";
+ columnNames[2] = "Actual value";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ expectedvalue = intvar;
+ tpassed = PluginTest.jjsReadIntTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ expectedvalue = doublevar;
+ tpassed = PluginTest.jjsReadDoubleTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ expectedvalue = boolvar;
+ tpassed = PluginTest.jjsReadBooleanTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "string";
+ expectedvalue = stringvar;
+ tpassed = PluginTest.jjsReadStringTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "object";
+ expectedvalue = objectvar;
+ tpassed = PluginTest.jjsReadObjectTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "1D Array";
+ expectedvalue = 100;
+ tpassed = PluginTest.jjsRead1DArrayTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "2D Array";
+ expectedvalue = 200;
+ tpassed = PluginTest.jjsRead2DArrayTest();
+ actualValue = PluginTest.value;
+ addResult(type, expectedvalue, PluginTest.value, row);
+ check(tpassed, true, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row); return;
+
+}
+
diff --git a/plugin/tests/LiveConnect/jjs_set_tests.js b/plugin/tests/LiveConnect/jjs_set_tests.js
new file mode 100644
index 0000000..cffc123
--- /dev/null
+++ b/plugin/tests/LiveConnect/jjs_set_tests.js
@@ -0,0 +1,314 @@
+/*****************************************
+ * Tests for setting JS values from Java *
+ *****************************************/
+
+function jjsSetMemberTests() {
+
+ initVars();
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java set tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Java Member Type";
+ columnNames[1] = "Old Value";
+ columnNames[2] = "Expected value";
+ columnNames[3] = "Actual Value";
+ columnNames[4] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ oldvalue = setvar;
+ PluginTest.jjsSetIntTest();
+ expectedvalue = 1;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Integer";
+ oldvalue = setvar;
+ PluginTest.jjsSetIntegerTest();
+ expectedvalue = 2;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ oldvalue = setvar;
+ PluginTest.jjsSetdoubleTest();
+ expectedvalue = 2.1;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Double";
+ oldvalue = setvar;
+ PluginTest.jjsSetDoubleTest();
+ expectedvalue = 2.2;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "float";
+ oldvalue = setvar;
+ PluginTest.jjsSetfloatTest();
+ expectedvalue = 2.299999952316284 ;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Float";
+ oldvalue = setvar;
+ PluginTest.jjsSetFloatTest();
+ expectedvalue = 2.4000000953674316;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "long";
+ oldvalue = setvar;
+ PluginTest.jjsSetlongTest();
+ expectedvalue = 4294967296;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Long";
+ oldvalue = setvar;
+ PluginTest.jjsSetLongTest();
+ expectedvalue = 4294967297;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "short";
+ oldvalue = setvar;
+ PluginTest.jjsSetshortTest();
+ expectedvalue = 3;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Short";
+ oldvalue = setvar;
+ PluginTest.jjsSetShortTest();
+ expectedvalue = 4;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "byte";
+ oldvalue = setvar;
+ PluginTest.jjsSetbyteTest();
+ expectedvalue = 5;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Byte";
+ oldvalue = setvar;
+ PluginTest.jjsSetByteTest();
+ expectedvalue = 6;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char";
+ oldvalue = setvar;
+ PluginTest.jjsSetcharTest();
+ expectedvalue = 8995;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Character";
+ oldvalue = setvar;
+ PluginTest.jjsSetCharacterTest();
+ expectedvalue = 8996;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ oldvalue = setvar;
+ PluginTest.jjsSetbooleanTest();
+ expectedvalue = true;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.Boolean";
+ oldvalue = setvar;
+ PluginTest.jjsSetBooleanTest();
+ expectedvalue = false;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "boolean", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "java.lang.String";
+ oldvalue = setvar;
+ PluginTest.jjsSetStringTest();
+ expectedvalue = "𠁎〒£$ǣ€𝍖";
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "(Complex java object)";
+ oldvalue = setvar;
+ PluginTest.jjsSetObjectTest();
+ expectedvalue = PluginTest.dummyObject;
+ addResult(type, oldvalue, expectedvalue, setvar, row);
+ check(setvar, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "1D Array";
+ setvar = new Array();
+ oldvalue = setvar[1];
+ PluginTest.jjsSet1DArrayTest();
+ expectedvalue = 100;
+ addResult(type, oldvalue, expectedvalue, setvar[1], row);
+ check(setvar[1], expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "2D Array";
+ setvar = new Array();
+ setvar[1] = new Array();
+ oldvalue = setvar[1][2];
+ PluginTest.jjsSet2DArrayTest();
+ expectedvalue = 200;
+ addResult(type, oldvalue, expectedvalue, setvar[1][2], row);
+ check(setvar[1][2], expectedvalue, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+}
+
+function java_to_js_call_test_info (type, expectedreply, functionreply, row) {
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","25%");
+ cellText = document.createTextNode(type);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(expectedreply);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+ cell = document.createElement("td");
+ cell.setAttribute("width","20%");
+ cellText = document.createTextNode(functionreply);
+ cell.appendChild(cellText);
+ row.appendChild(cell);
+
+}
+
diff --git a/plugin/tests/LiveConnect/jsj_func_overload_tests.js b/plugin/tests/LiveConnect/jsj_func_overload_tests.js
new file mode 100644
index 0000000..a7e8d6a
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_func_overload_tests.js
@@ -0,0 +1,181 @@
+ /**************************************************************
+ * Tests for overloaded function resolution when calling Java *
+ * functions from JS *
+ **************************************************************/
+
+function frCallTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java Call tests [Overload and casting]:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Available functions";
+ columnNames[1] = "Expected reply";
+ columnNames[2] = "Reply";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_null_to_nonprim";
+ available = fname + " [(Integer), (int)]";
+ expectedreply = fname + ":Integer";
+ reply = PluginTest.foo_null_to_nonprim(null);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":Integer", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_jso_to_jso";
+ available = fname + " [(JSObject), (String), (String[]), (Object)]";
+ expectedreply = fname + ":JSObject";
+ reply = PluginTest.foo_jso_to_jso(window);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":JSObject", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_ct_to_ct";
+ available = fname + " [(OverloadTestHelper1), (OverloadTestHelper2), (OverloadTestHelper3)]";
+ expectedreply = fname + ":OverloadTestHelper2";
+ reply = PluginTest.foo_ct_to_ct(new PluginTest.Packages.OverloadTestHelper2());
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":OverloadTestHelper2", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_multiprim";
+ available = fname + " [(double), (String)]";
+ expectedreply = fname + ":double";
+ reply = PluginTest.foo_multiprim(1.1);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":double", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_multiprim";
+ available = fname + " [(double), (String)]";
+ expectedreply = fname + ":double";
+ reply = PluginTest.foo_multiprim(1.1);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":double", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_strnum";
+ available = fname + " [(double), (OverloadTestHelper1)]";
+ expectedreply = fname + ":double";
+ reply = PluginTest.foo_strnum(1.1);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":double", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_ct_to_sc";
+ available = fname + " [(OverloadTestHelper1), (String)]";
+ expectedreply = fname + ":double";
+ reply = PluginTest.foo_ct_to_sc(new PluginTest.Packages.OverloadTestHelper2());
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":OverloadTestHelper1", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_jv_to_str";
+ available = fname + " [(String), (JSObject)]";
+ expectedreply = fname + ":String";
+ reply = PluginTest.foo_jv_to_str(new PluginTest.Packages.OverloadTestHelper1());
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":java.lang.String", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ fname = "foo_jso_to_array";
+ available = fname + " [(int[]), (Integer), (Integer[])]";
+ expectedreply = fname + ":int[]";
+ arr = new Array();
+ arr[0] = 10;
+ reply = PluginTest.foo_jso_to_array(arr);
+ addResult(available, expectedreply, reply, row);
+ check(fname + ":int[]", reply, "string", row);
+ } catch (e) {
+ error(null, null, e, row);
+ }
+ tblBody.appendChild(row);
+
+ // Tests where exceptions are expected
+ fname = "foo_null_to_prim";
+ available = fname + " [(int)] -- Not allowed";
+
+ try {
+ row = document.createElement("tr");
+ expectedreply = null;
+ reply = PluginTest.foo_null_to_prim(null);
+ fail(row, "An exception was expected. Instead, got reply: " + reply);
+ } catch (e) {
+ addResult(available, "[An exception]", e.toString(), row);
+ pass(row);
+ }
+ tblBody.appendChild(row);
+ fname = "foo_jso_to_somethingelse";
+ available = fname + " [(OverloadTestHelper1)] -- Not allowed";
+
+ try {
+ row = document.createElement("tr");
+ expectedreply = null;
+ reply = PluginTest.foo_jso_to_somethingelse(window);
+ fail(row, "An exception was expected. Instead, got reply: " + reply);
+ } catch (e) {
+ addResult(available, "[An exception]", e.toString(), row);
+ pass(row);
+ }
+ tblBody.appendChild(row);
+ fname = "foo_unsupported";
+ available = fname + " [(Object[] p)] -- Not allowed";
+ try {
+ row = document.createElement("tr");
+ expectedreply = null;
+ reply = PluginTest.foo_unsupported(25);
+ fail(row, "An exception was expected. Instead, got reply: " + reply);
+ } catch (e) {
+ addResult(available, "[An exception]", e.toString(), row);
+ pass(row);
+ }
+
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jsj_func_parameters_tests.js b/plugin/tests/LiveConnect/jsj_func_parameters_tests.js
new file mode 100644
index 0000000..ca1a820
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_func_parameters_tests.js
@@ -0,0 +1,216 @@
+ /********************************************************************
+ * Tests for function parameter coversion when calling Java from JS *
+ ********************************************************************/
+
+function fpCallTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java Call tests [Parameter type]:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Parameter type";
+ columnNames[1] = "Sending";
+ columnNames[2] = "Expected reply";
+ columnNames[3] = "Reply";
+ columnNames[4] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ PluginTest.setUpForReturnTests();
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ send = 1;
+ reply = PluginTest.functioniParamTest(send);
+ addResult(type, send, send, reply, row);
+ check(send, reply, "number", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ send = 1.1;
+ reply = PluginTest.functiondParamTest(send);
+ addResult(type, send, send, reply, row);
+ check(send, reply, "number", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "float";
+ send = 1.11;
+ reply = PluginTest.functionfParamTest(send);
+ addResult(type, send, send, reply, row);
+ check(send, reply, "number", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "long";
+ send = 4294967300;
+ reply = PluginTest.functionlParamTest(send);
+ addResult(type, send, send, reply, row);
+ check(send, reply, "number", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ send = true;
+ reply = PluginTest.functionbParamTest(send);
+ addResult(type, send, send, reply, row);
+ check("true", reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char";
+ send = 75;
+ reply = PluginTest.functioncParamTest(send);
+ addResult(type, send, "K", reply, row);
+ check("K", reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "byte";
+ send = 76;
+ reply = PluginTest.functionbyParamTest(send);
+ addResult(type, send, send, reply, row);
+ check(send, reply, "number", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char[] (simple primitive)";
+ arr = new Array();
+ arr[0] = 80;
+ arr[1] = 81;
+ reply = PluginTest.functioncaParamTest(arr);
+ addResult(type, "[80,81]", "P:Q", reply, row);
+ check(reply, "P:Q", "string", row);
+ } catch (e) {
+ error(type, "P:Q", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String";
+ send = "$〒£€𝍖𠁎ǣ";
+ expectedreply = "$〒£€𝍖𠁎ǣ:java.lang.String";
+ reply = PluginTest.functionsParamTest(send);
+ addResult(type, send, expectedreply, reply, row);
+ check(expectedreply, reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Integer";
+ send = "32";
+ expectedreply = send+":java.lang.Integer";
+ reply = PluginTest.functionIParamTest(send);
+ addResult(type, send, expectedreply, reply, row);
+ check(expectedreply, reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double";
+ send = 32.0;
+ expectedreply = "32.0:java.lang.Double";
+ reply = PluginTest.functionDParamTest(send);
+ addResult(type, send, expectedreply, reply, row);
+ check(expectedreply, reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Float";
+ send = 32.01;
+ expectedreply = send+":java.lang.Float";
+ reply = PluginTest.functionFParamTest(send);
+ addResult(type, send, expectedreply, reply, row);
+ check(expectedreply, reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Long";
+ send = 4294967301;
+ expectedreply = send+":java.lang.Long";
+ reply = PluginTest.functionLParamTest(send);
+ addResult(type, send, expectedreply, reply, row);
+ check(expectedreply, reply, "string", row);
+ } catch (e) {
+ error(type, send, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "String/Int [] (mixed)";
+ arr = new Array();
+ arr[0] = "s1";
+ arr[1] = 42;
+ reply = PluginTest.functionsiaParamTest(arr);
+ addResult(type, "[s1,42]", "s1:42", reply, row);
+ check(reply, "s1:42", "string", row);
+ } catch (e) {
+ error(type, "s1:42", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "DummyObject[] (complex)";
+ arr = new Array();
+ arr[0] = new PluginTest.Packages.DummyObject("DummyObject1");
+ arr[1] = new PluginTest.Packages.DummyObject("DummyObject2");
+ reply = PluginTest.functioncomplexaParamTest(arr);
+ addResult(type, "[DummyObject1,DummyObjec2]", "DummyObject1:DummyObject2", reply, row);
+ check(reply, "DummyObject1:DummyObject2", "string", row);
+ } catch (e) {
+ error(type, "DummyObject1:DummyObject2", e, row);
+ }
+
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jsj_func_rettype_tests.js b/plugin/tests/LiveConnect/jsj_func_rettype_tests.js
new file mode 100644
index 0000000..4a5c97b
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_func_rettype_tests.js
@@ -0,0 +1,262 @@
+/***********************************************************************
+ * Tests to process various return types from Java side function calls *
+ ***********************************************************************/
+
+function rtCallTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java Call tests [Return Type]:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Function return type";
+ columnNames[1] = "Expected Value";
+ columnNames[2] = "Actual Value";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ PluginTest.setUpForParameterTests();
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ expectedvalue = 41;
+ addResult(type, expectedvalue, PluginTest.intReturnTest(), row);
+ check(PluginTest.intReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ expectedvalue = 41.41;
+ addResult(type, expectedvalue, PluginTest.doubleReturnTest(), row);
+ check(PluginTest.doubleReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "float";
+ expectedvalue = 41.4109992980957;
+ addResult(type, expectedvalue, PluginTest.floatReturnTest(), row);
+ check(PluginTest.floatReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "long";
+ expectedvalue = 4294967297;
+ addResult(type, expectedvalue, PluginTest.longReturnTest(), row);
+ check(PluginTest.longReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ expectedvalue = true;
+ addResult(type, expectedvalue, PluginTest.booleanReturnTest(), row);
+ check(PluginTest.booleanReturnTest(), expectedvalue, "boolean", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char";
+ expectedvalue = 9001;
+ addResult(type, expectedvalue, PluginTest.charReturnTest(), row);
+ check(PluginTest.charReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "byte";
+ expectedvalue = 44;
+ addResult(type, expectedvalue, PluginTest.byteReturnTest(), row);
+ check(PluginTest.byteReturnTest(), expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char[] (direct element access)";
+ expectedvalue = 9234;
+ addResult(type, expectedvalue, PluginTest.charArrayReturnTest()[2], row);
+ check(PluginTest.charArrayReturnTest()[2], expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Regular char string";
+ expectedvalue = "I'm a string too!";
+ addResult(type, expectedvalue, PluginTest.regularStringReturnTest(), row);
+ check(PluginTest.regularStringReturnTest(), expectedvalue, "string", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Special char string";
+ expectedvalue = "𠁎〒£$ǣ€𝍖";
+ addResult(type, expectedvalue, PluginTest.specialStringReturnTest(), row);
+ check(PluginTest.specialStringReturnTest(), expectedvalue, "string", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "void";
+ expectedvalue = null;
+ addResult(type, "undefined", PluginTest.voidReturnTest(), row);
+ check(PluginTest.voidReturnTest(), expectedvalue, "undefined", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "null";
+ expectedvalue = null;
+ addResult(type, expectedvalue, PluginTest.nullReturnTest(), row);
+ check(PluginTest.nullReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Integer";
+ expectedvalue = 14;
+ addResult(type, expectedvalue, PluginTest.IntegerReturnTest(), row);
+ check(PluginTest.IntegerReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double";
+ expectedvalue = 14.14;
+ addResult(type, expectedvalue, PluginTest.DoubleReturnTest(), row);
+ check(PluginTest.DoubleReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Float";
+ expectedvalue = 14.114;
+ addResult(type, expectedvalue, PluginTest.FloatReturnTest(), row);
+ check(PluginTest.FloatReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Long";
+ expectedvalue = 6927694925;
+ addResult(type, expectedvalue, PluginTest.LongReturnTest(), row);
+ check(PluginTest.LongReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean";
+ expectedvalue = "false";
+ addResult(type, expectedvalue, PluginTest.BooleanReturnTest(), row);
+ check(PluginTest.BooleanReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Character";
+ expectedvalue = "␗";
+ addResult(type, expectedvalue, PluginTest.CharacterReturnTest(), row);
+ check(PluginTest.CharacterReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Byte";
+ expectedvalue = 46;
+ addResult(type, expectedvalue, PluginTest.ByteReturnTest(), row);
+ check(PluginTest.ByteReturnTest(), expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Character[] (direct element access)";
+ expectedvalue = "⍑";
+ addResult(type, expectedvalue, PluginTest.CharacterArrayReturnTest()[1], row);
+ check(PluginTest.CharacterArrayReturnTest()[1], expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Character[] (Full array)";
+ expectedvalue = "[Ljava.lang.Character;@";
+ addResult(type, expectedvalue+"*", PluginTest.CharacterArrayReturnTest(), row);
+ if (PluginTest.CharacterArrayReturnTest().toString().substr(0,23) == "[Ljava.lang.Character;@")
+ if (typeof(PluginTest.CharacterArrayReturnTest()) == "object") {
+ pass(row);
+ } else {
+ fail(row, "Type mismatch: " + typeof(SMPluginTest.Da) + " != object");
+ }
+ else
+ fail(row, "");
+
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jsj_get_tests.js b/plugin/tests/LiveConnect/jsj_get_tests.js
new file mode 100644
index 0000000..ad4b3d8
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_get_tests.js
@@ -0,0 +1,260 @@
+/********************************************
+ * Tests for getting members from Java side *
+ ********************************************/
+
+function getMemberTests() {
+ document.getElementById("results").innerHTML += "<h2>JS -> Java get tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Member Type";
+ columnNames[1] = "Expected Value";
+ columnNames[2] = "Actual Value";
+ columnNames[3] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ PluginTest.setUpForGMTests();
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ expectedvalue = 42;
+ addResult(type, expectedvalue, PluginTest.i, row);
+ check(PluginTest.i, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ expectedvalue = 42.42;
+ addResult(type, expectedvalue, PluginTest.d, row);
+ check(PluginTest.d, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "float";
+ expectedvalue = 42.099998474121094;
+ addResult(type, expectedvalue, PluginTest.f, row);
+ check(PluginTest.f, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "long";
+ expectedvalue = 4294967296;
+ addResult(type, expectedvalue, PluginTest.l, row);
+ check(PluginTest.l, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ expectedvalue = true;
+ addResult(type, expectedvalue, PluginTest.b, row);
+ check(PluginTest.b, expectedvalue, "boolean", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char";
+ expectedvalue = 8995;
+ addResult(type, expectedvalue, PluginTest.c, row);
+ check(PluginTest.c, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "byte";
+ expectedvalue = 43;
+ addResult(type, expectedvalue, PluginTest.by, row);
+ check(PluginTest.by, expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "int[] (element access)";
+ expectedvalue = "1024";
+ addResult(type, expectedvalue, PluginTest.ia[4], row);
+ check(PluginTest.ia[4], expectedvalue, "number", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "int[] (beyond length)";
+ expectedvalue = null;
+ addResult(type, expectedvalue, PluginTest.ia[30], row);
+ check(PluginTest.ia[30], expectedvalue, "undefined", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Regular String";
+ expectedvalue = "I'm a string!";
+ addResult(type, expectedvalue, PluginTest.rs, row);
+ check(PluginTest.rs, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String with special characters";
+ expectedvalue = "𠁎〒£$ǣ€𝍖";
+ addResult(type, expectedvalue, PluginTest.ss, row);
+ check(PluginTest.ss, expectedvalue, "string", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "null";
+ expectedvalue = null;
+ addResult(type, expectedvalue, PluginTest.n, row);
+ check(PluginTest.n, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Integer";
+ expectedvalue = 24;
+ addResult(type, expectedvalue, PluginTest.I, row);
+ check(PluginTest.I, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double";
+ expectedvalue = 24.24;
+ addResult(type, expectedvalue, PluginTest.D, row);
+ check(PluginTest.D, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Float";
+ expectedvalue = 24.124;
+ addResult(type, expectedvalue, PluginTest.F, row);
+ check(PluginTest.F, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Long";
+ expectedvalue = 6927694924;
+ addResult(type, expectedvalue, PluginTest.L, row);
+ check(PluginTest.L, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean";
+ expectedvalue = "false";
+ addResult(type, expectedvalue, PluginTest.B, row);
+ check(PluginTest.B, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Character";
+ expectedvalue = 'ᔦ';
+ addResult(type, expectedvalue, PluginTest.C, row);
+ check(PluginTest.C, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Byte";
+ expectedvalue = 34;
+ addResult(type, expectedvalue, PluginTest.By, row);
+ check(PluginTest.By, expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double[] (element access)";
+ expectedvalue = "24.24";
+ addResult(type, expectedvalue, PluginTest.Da1[9], row);
+ check(PluginTest.Da1[9], expectedvalue, "object", row);
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double[] (Full array)";
+ expectedvalue = "[Ljava.lang.Double;@";
+ addResult(type, expectedvalue+"*", PluginTest.Da1, row);
+
+ if (PluginTest.Da1.toString().substr(0,20) == expectedvalue)
+ if (typeof(PluginTest.Da1) == "object") {
+ pass(row);
+ } else {
+ fail(row, "Type mismatch: " + typeof(PluginTest.Da1) + " != object");
+ }
+ else
+ fail(row, "");
+ } catch (e) {
+ error(type, expectedvalue, e, row);
+ }
+
+ tblBody.appendChild(row);
+}
diff --git a/plugin/tests/LiveConnect/jsj_set_tests.js b/plugin/tests/LiveConnect/jsj_set_tests.js
new file mode 100644
index 0000000..aa30c0a
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_set_tests.js
@@ -0,0 +1,318 @@
+/******************************************
+ * Tests for setting members on Java side *
+ ******************************************/
+
+function setMemberTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java set tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Member Type";
+ columnNames[1] = "Old Value";
+ columnNames[2] = "Setting To";
+ columnNames[3] = "New Value";
+ columnNames[4] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ PluginTest.setUpForSMTests();
+
+ try {
+ row = document.createElement("tr");
+ type = "int";
+ setto = 42;
+ curr = PluginTest.i;
+ PluginTest.i = setto;
+ now = PluginTest.i;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "double";
+ setto = 42.42;
+ curr = PluginTest.d;
+ PluginTest.d = setto;
+ now = PluginTest.d;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "float";
+ setto = 42.421;
+ curr = PluginTest.f;
+ PluginTest.f = setto;
+ now = PluginTest.f;
+ addResult(type, curr, 42.42100143432617, now, row);
+ check(now, 42.42100143432617, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "long";
+ setto = 4294967296;
+ curr = PluginTest.l;
+ PluginTest.l = setto;
+ now = PluginTest.l;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "boolean";
+ setto = true;
+ curr = PluginTest.b;
+ PluginTest.b = setto;
+ now = PluginTest.b;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "char";
+ setto = 58;
+ curr = PluginTest.c;
+ PluginTest.c = setto;
+ now = PluginTest.c;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "byte";
+ setto = 43;
+ curr = PluginTest.by;
+ PluginTest.by = setto;
+ now = PluginTest.by;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "int[] (element)";
+ setto = 100;
+ curr = PluginTest.ia[4];
+ PluginTest.ia[4] = setto;
+ now = PluginTest.ia[4];
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "int[] (beyond length)";
+ setto = 100;
+ curr = PluginTest.ia[30];
+ PluginTest.ia[30] = setto;
+ now = PluginTest.ia[30];
+ addResult(type, curr, setto, now, row);
+ check(now, null, "undefined", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Regular string";
+ setto = 'Test string';
+ curr = PluginTest.rs;
+ PluginTest.rs = setto;
+ now = PluginTest.rs;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String with special chars";
+ setto = "𠁎〒£$ǣ€𝍖";
+ curr = PluginTest.ss;
+ PluginTest.ss = setto;
+ now = PluginTest.ss;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "null";
+ setto = null;
+ curr = PluginTest.n;
+ PluginTest.n = setto;
+ now = PluginTest.n;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Integer";
+ setto = 24;
+ curr = PluginTest.I;
+ PluginTest.I = setto;
+ now = PluginTest.I;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double";
+ setto = 24.24;
+ curr = PluginTest.D;
+ PluginTest.D = setto;
+ now = PluginTest.D;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Float";
+ setto = 24.124;
+ curr = PluginTest.F;
+ PluginTest.F = setto;
+ now = PluginTest.F;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Long";
+ setto = 6927694924;
+ curr = PluginTest.L;
+ PluginTest.L = setto;
+ now = PluginTest.L;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean";
+ setto = new java.lang.Boolean("true");
+ curr = PluginTest.B;
+ PluginTest.B = setto;
+ now = PluginTest.B;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Character";
+ setto = new java.lang.Character(64);
+ curr = PluginTest.C;
+ PluginTest.C = setto;
+ now = PluginTest.C;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Byte";
+ setto = new java.lang.Byte(39);
+ curr = PluginTest.By;
+ PluginTest.By = setto;
+ now = PluginTest.By;
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double[] (element)";
+ setto = 100.100;
+ curr = PluginTest.Da1[9];
+ PluginTest.Da1[9] = setto;
+ now = PluginTest.Da1[9];
+ addResult(type, curr, setto, now, row);
+ check(now, setto, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Double[] (Full array)";
+ curr = PluginTest.Da2;
+ PluginTest.Da2 = java.lang.reflect.Array.newInstance(java.lang.Double, 3);
+ PluginTest.Da2[0] = 1.1;
+ PluginTest.Da2[1] = 2.1;
+ addResult(type, curr, "[1.1,2.1,null]", "["+PluginTest.Da2[0]+","+PluginTest.Da2[1]+","+PluginTest.Da2[2]+"]", row);
+ check("["+PluginTest.Da2[0]+","+PluginTest.Da2[1]+","+PluginTest.Da2[2]+"]", "[1.1,2.1,null]", "string", row);
+ } catch (e) {
+ error(type, "[1.0,2.0,]", e, row);
+ }
+
+ tblBody.appendChild(row);
+}
+
diff --git a/plugin/tests/LiveConnect/jsj_type_casting_tests.js b/plugin/tests/LiveConnect/jsj_type_casting_tests.js
new file mode 100644
index 0000000..2debbf0
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_type_casting_tests.js
@@ -0,0 +1,825 @@
+/************************************************************
+ * Tests for data type conversion from JS to Java variables *
+ ************************************************************/
+
+function typeCastingTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java type casting tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Test Type";
+ columnNames[1] = "Send Value";
+ columnNames[2] = "Expected Value";
+ columnNames[3] = "Actual Value";
+ columnNames[4] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.String (Integer)";
+ setto = 1;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.String (Double)";
+ setto = 1.1;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.Object (Integer)";
+ setto = 1.0;
+ PluginTest.Object_type = setto;
+ now = PluginTest.Object_type + " | Superclass = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ addResult (type, setto, setto + " | Superclass = java.lang.Number", now, row);
+ check(now, setto + " | Superclass = java.lang.Number", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.Object (Double)";
+ setto = 1.1;
+ PluginTest.Object_type = setto;
+ now = PluginTest.Object_type + " | Superclass = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ addResult (type, setto, setto + " | Superclass = java.lang.Number", now, row);
+ check(now, setto + " | Superclass = java.lang.Number", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> boolean (0)";
+ setto = 0;
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, false, now, row);
+ check(now, false, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> boolean (1.1)";
+ setto = 1.1;
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, true, now, row);
+ check(now, true, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Boolean (true)";
+ setto = true;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Boolean (false)";
+ setto = false;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type;
+ addResult (type, setto, "false", now, row);
+ check(now, "false", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Object";
+ setto = true;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type + " | Class = " + PluginTest.Boolean_type.getClass().getName();
+ addResult (type, setto, "true | Class = java.lang.Boolean", now, row);
+ check(now, "true | Class = java.lang.Boolean", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.String";
+ setto = true;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.String";
+ setto = true;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> byte (true)";
+ setto = true;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> char (true)";
+ setto = true;
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> short (true)";
+ setto = true;
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> int (true)";
+ setto = true;
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> long (true)";
+ setto = true;
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> float (true)";
+ setto = true;
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> double (true)";
+ setto = true;
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> byte (false)";
+ setto = false;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> char (false)";
+ setto = false;
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> short (false)";
+ setto = false;
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> int (false)";
+ setto = false;
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> long (false)";
+ setto = false;
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> float (false)";
+ setto = false;
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> double (false)";
+ setto = false;
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> Object";
+ setto = "𠁎〒£$ǣ€𝍖";
+ PluginTest.Object_type = setto;
+
+ // Some weird FF bug is causing getClass to not work correctly when set
+ // to a String (hasProperty/hasMethod "getClass" doesn't come through
+ // to the plugin at all, so it is definitely an ff issue). So for now,
+ // we just compare values.
+
+ //now = PluginTest.Object_type + " | Class = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ //addResult (type, setto, setto + " | Class = java.lang.String", now, row);
+ //check(now, setto + " | Class = java.lang.String", "string", row);
+
+ now = PluginTest.Object_type;
+ PluginTest.Object_type.charAt(3); // try a String specific function to be sure it is a String
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> byte";
+ setto = "1";
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> short";
+ setto = "2";
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 2, now, row);
+ check(now, 2, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> int";
+ setto = "3";
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 3, now, row);
+ check(now, 3, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> long";
+ setto = "4";
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 4, now, row);
+ check(now, 4, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> float";
+ setto = "0.0";
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> double";
+ setto = "6.2";
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 6.2, now, row);
+ check(now, 6.2, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> char";
+ setto = "7";
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 7, now, row);
+ check(now, 7, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> boolean (empty/false)";
+ setto = "";
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, false, now, row);
+ check(now, false, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> boolean (non-empty/true)";
+ setto = "A non-empty string";
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, true, now, row);
+ check(now, true, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> byte[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.byte_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.byte_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> char[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.char_array = setto;
+
+ // For char array, don't convert to string.. the empty/null/0 character messes it up
+ now = PluginTest.char_array[0] + "," + PluginTest.char_array[1] + "," + PluginTest.char_array[2];
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> short[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.short_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.short_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> int[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.int_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.int_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> long[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.long_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.long_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> float[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.float_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.float_array);
+ addResult (type, setto, "1.0,0.0,2.0", now, row);
+ check(now, "1.0,0.0,2.0", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> double[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.double_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.double_array);
+ addResult (type, setto, "1.0,0.0,2.0", now, row);
+ check(now, "1.0,0.0,2.0", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> String[] (int)";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.String_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.String_array);
+ addResult (type, setto, "1,null,2", now, row);
+ check(now, "1,null,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> String[] (int)";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.String_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.String_array);
+ addResult (type, setto, "1,null,2", now, row);
+ check(now, "1,null,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = "100";
+ a[0][2] = "102";
+ a[2][0] = "120";
+ a[2][1] = "121";
+ a[2][3] = "123";
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> char[][] (string to primitive)";
+ PluginTest.char_array_array = a;
+ now = PluginTest.char_array_array[0][0] + "," +
+ PluginTest.char_array_array[0][1] + "," +
+ PluginTest.char_array_array[0][2] + "," +
+ PluginTest.char_array_array[1][0] + "," +
+ PluginTest.char_array_array[2][0] + "," +
+ PluginTest.char_array_array[2][1] + "," +
+ PluginTest.char_array_array[2][2] + "," +
+ PluginTest.char_array_array[2][3];
+ expected = "100,0,102,undefined,120,121,0,123"
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = 100;
+ a[0][2] = 102;
+ a[2][0] = 120;
+ a[2][1] = 121;
+ a[2][3] = 123;
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> String[][] (int to complex)";
+ PluginTest.String_array_array = a;
+ now = PluginTest.String_array_array[0][0] + "," +
+ PluginTest.String_array_array[0][1] + "," +
+ PluginTest.String_array_array[0][2] + "," +
+ PluginTest.String_array_array[1][0] + "," +
+ PluginTest.String_array_array[2][0] + "," +
+ PluginTest.String_array_array[2][1] + "," +
+ PluginTest.String_array_array[2][2] + "," +
+ PluginTest.String_array_array[2][3];
+ expected = "100,null,102,undefined,120,121,null,123";
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = 100;
+ a[0][2] = 102;
+ a[2][0] = 120;
+ a[2][1] = 121;
+ a[2][3] = 123;
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> String";
+ PluginTest.String_type = a;
+ now = PluginTest.String_type;
+ expected = "100,,102,,120,121,,123";
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "JSObject -> JSObject";
+ setto = window;
+ PluginTest.JSObject_type = setto;
+ now = PluginTest.JSObject_type;
+ addResult (type, setto, "[object Window]", now, row);
+ check(now, "[object Window]", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "JSObject -> String";
+ setto = window;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "[object Window]", now, row);
+ check(now, "[object Window]", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Java Object -> Java Object";
+ PluginTest.Float_type = 1.111;
+ orig_hash = PluginTest.Float_type.hashCode();
+ PluginTest.Object_type = PluginTest.Float_type;
+ new_hash = PluginTest.Object_type.hashCode();
+ addResult (type, "hashcode=" + orig_hash, orig_hash, new_hash, row);
+ check(new_hash, orig_hash, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Java Object -> String";
+ setto = new PluginTest.Packages.DummyObject("Test object");
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "Test object", now, row);
+ check(now, "Test object", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "null -> Java Object (String)";
+
+ // Assuming the set tests have passed, we know that object is non-null after this
+ PluginTest.String_type = "Not Null";
+
+ setto = null;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, null, now, row);
+ check(now, null, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+/*
+ // NULL -> primitive tests are disabled for now due to ambiguity.
+ // Section 2.2 here: http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/
+ // States that null to primitive is not allowed, yet, section 2.3.7 claims it is..
+
+ try {
+ row = document.createElement("tr");
+ type = "null -> byte";
+
+ // Assuming the set tests have passed, we know that object is non-null after this
+ PluginTest.byte_type = "100";
+
+ setto = null;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, null, now, row);
+ check(now, null, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+*/
+
+}
+
+
+
diff --git a/plugin/tests/LiveConnect/jsj_type_conversion_tests.js b/plugin/tests/LiveConnect/jsj_type_conversion_tests.js
new file mode 100644
index 0000000..2debbf0
--- /dev/null
+++ b/plugin/tests/LiveConnect/jsj_type_conversion_tests.js
@@ -0,0 +1,825 @@
+/************************************************************
+ * Tests for data type conversion from JS to Java variables *
+ ************************************************************/
+
+function typeCastingTests() {
+
+ document.getElementById("results").innerHTML += "<h2>JS -> Java type casting tests:</h2>";
+
+ var tbl = document.createElement("table");
+ var tblBody = document.createElement("tbody");
+ var columnNames = new Array();
+ columnNames[0] = "Test Type";
+ columnNames[1] = "Send Value";
+ columnNames[2] = "Expected Value";
+ columnNames[3] = "Actual Value";
+ columnNames[4] = "Status";
+ var row;
+
+ createResultTable(tbl, tblBody, columnNames);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.String (Integer)";
+ setto = 1;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.String (Double)";
+ setto = 1.1;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.Object (Integer)";
+ setto = 1.0;
+ PluginTest.Object_type = setto;
+ now = PluginTest.Object_type + " | Superclass = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ addResult (type, setto, setto + " | Superclass = java.lang.Number", now, row);
+ check(now, setto + " | Superclass = java.lang.Number", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> java.lang.Object (Double)";
+ setto = 1.1;
+ PluginTest.Object_type = setto;
+ now = PluginTest.Object_type + " | Superclass = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ addResult (type, setto, setto + " | Superclass = java.lang.Number", now, row);
+ check(now, setto + " | Superclass = java.lang.Number", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> boolean (0)";
+ setto = 0;
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, false, now, row);
+ check(now, false, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Numeric -> boolean (1.1)";
+ setto = 1.1;
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, true, now, row);
+ check(now, true, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Boolean (true)";
+ setto = true;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Boolean (false)";
+ setto = false;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type;
+ addResult (type, setto, "false", now, row);
+ check(now, "false", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.Object";
+ setto = true;
+ PluginTest.Boolean_type = setto;
+ now = PluginTest.Boolean_type + " | Class = " + PluginTest.Boolean_type.getClass().getName();
+ addResult (type, setto, "true | Class = java.lang.Boolean", now, row);
+ check(now, "true | Class = java.lang.Boolean", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.String";
+ setto = true;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> java.lang.String";
+ setto = true;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "true", now, row);
+ check(now, "true", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> byte (true)";
+ setto = true;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> char (true)";
+ setto = true;
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> short (true)";
+ setto = true;
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> int (true)";
+ setto = true;
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> long (true)";
+ setto = true;
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> float (true)";
+ setto = true;
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> double (true)";
+ setto = true;
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> byte (false)";
+ setto = false;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> char (false)";
+ setto = false;
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> short (false)";
+ setto = false;
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> int (false)";
+ setto = false;
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> long (false)";
+ setto = false;
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> float (false)";
+ setto = false;
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Boolean -> double (false)";
+ setto = false;
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> Object";
+ setto = "𠁎〒£$ǣ€𝍖";
+ PluginTest.Object_type = setto;
+
+ // Some weird FF bug is causing getClass to not work correctly when set
+ // to a String (hasProperty/hasMethod "getClass" doesn't come through
+ // to the plugin at all, so it is definitely an ff issue). So for now,
+ // we just compare values.
+
+ //now = PluginTest.Object_type + " | Class = " + PluginTest.Object_type.getClass().getSuperclass().getName();
+ //addResult (type, setto, setto + " | Class = java.lang.String", now, row);
+ //check(now, setto + " | Class = java.lang.String", "string", row);
+
+ now = PluginTest.Object_type;
+ PluginTest.Object_type.charAt(3); // try a String specific function to be sure it is a String
+ addResult (type, setto, setto, now, row);
+ check(now, setto, "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> byte";
+ setto = "1";
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, 1, now, row);
+ check(now, 1, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> short";
+ setto = "2";
+ PluginTest.short_type = setto;
+ now = PluginTest.short_type;
+ addResult (type, setto, 2, now, row);
+ check(now, 2, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> int";
+ setto = "3";
+ PluginTest.int_type = setto;
+ now = PluginTest.int_type;
+ addResult (type, setto, 3, now, row);
+ check(now, 3, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> long";
+ setto = "4";
+ PluginTest.long_type = setto;
+ now = PluginTest.long_type;
+ addResult (type, setto, 4, now, row);
+ check(now, 4, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> float";
+ setto = "0.0";
+ PluginTest.float_type = setto;
+ now = PluginTest.float_type;
+ addResult (type, setto, 0, now, row);
+ check(now, 0, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> double";
+ setto = "6.2";
+ PluginTest.double_type = setto;
+ now = PluginTest.double_type;
+ addResult (type, setto, 6.2, now, row);
+ check(now, 6.2, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> char";
+ setto = "7";
+ PluginTest.char_type = setto;
+ now = PluginTest.char_type;
+ addResult (type, setto, 7, now, row);
+ check(now, 7, "number", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> boolean (empty/false)";
+ setto = "";
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, false, now, row);
+ check(now, false, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+
+ try {
+ row = document.createElement("tr");
+ type = "String -> boolean (non-empty/true)";
+ setto = "A non-empty string";
+ PluginTest.boolean_type = setto;
+ now = PluginTest.boolean_type;
+ addResult (type, setto, true, now, row);
+ check(now, true, "boolean", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> byte[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.byte_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.byte_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> char[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.char_array = setto;
+
+ // For char array, don't convert to string.. the empty/null/0 character messes it up
+ now = PluginTest.char_array[0] + "," + PluginTest.char_array[1] + "," + PluginTest.char_array[2];
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> short[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.short_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.short_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> int[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.int_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.int_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> long[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.long_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.long_array);
+ addResult (type, setto, "1,0,2", now, row);
+ check(now, "1,0,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> float[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.float_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.float_array);
+ addResult (type, setto, "1.0,0.0,2.0", now, row);
+ check(now, "1.0,0.0,2.0", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> double[]";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.double_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.double_array);
+ addResult (type, setto, "1.0,0.0,2.0", now, row);
+ check(now, "1.0,0.0,2.0", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> String[] (int)";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.String_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.String_array);
+ addResult (type, setto, "1,null,2", now, row);
+ check(now, "1,null,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Array -> String[] (int)";
+ setto = new Array();
+ setto[0] = 1;
+ setto[2] = 2;
+ PluginTest.String_array = setto;
+ now = PluginTest.getArrayAsStr(PluginTest.String_array);
+ addResult (type, setto, "1,null,2", now, row);
+ check(now, "1,null,2", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = "100";
+ a[0][2] = "102";
+ a[2][0] = "120";
+ a[2][1] = "121";
+ a[2][3] = "123";
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> char[][] (string to primitive)";
+ PluginTest.char_array_array = a;
+ now = PluginTest.char_array_array[0][0] + "," +
+ PluginTest.char_array_array[0][1] + "," +
+ PluginTest.char_array_array[0][2] + "," +
+ PluginTest.char_array_array[1][0] + "," +
+ PluginTest.char_array_array[2][0] + "," +
+ PluginTest.char_array_array[2][1] + "," +
+ PluginTest.char_array_array[2][2] + "," +
+ PluginTest.char_array_array[2][3];
+ expected = "100,0,102,undefined,120,121,0,123"
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = 100;
+ a[0][2] = 102;
+ a[2][0] = 120;
+ a[2][1] = 121;
+ a[2][3] = 123;
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> String[][] (int to complex)";
+ PluginTest.String_array_array = a;
+ now = PluginTest.String_array_array[0][0] + "," +
+ PluginTest.String_array_array[0][1] + "," +
+ PluginTest.String_array_array[0][2] + "," +
+ PluginTest.String_array_array[1][0] + "," +
+ PluginTest.String_array_array[2][0] + "," +
+ PluginTest.String_array_array[2][1] + "," +
+ PluginTest.String_array_array[2][2] + "," +
+ PluginTest.String_array_array[2][3];
+ expected = "100,null,102,undefined,120,121,null,123";
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ var a = [];
+ a[0] = [];
+ a[1] = [];
+ a[2] = [];
+ a[0][0] = 100;
+ a[0][2] = 102;
+ a[2][0] = 120;
+ a[2][1] = 121;
+ a[2][3] = 123;
+
+ //
+ // a = [[00, , 02] // normal
+ // [] // empty
+ // [20, 21, , 23]] // length = element0.length + 1
+ //
+
+ row = document.createElement("tr");
+ type = "Array -> String";
+ PluginTest.String_type = a;
+ now = PluginTest.String_type;
+ expected = "100,,102,,120,121,,123";
+ addResult (type, a, expected, now, row);
+ check(now, expected, "string", row);
+ } catch (e) {
+ error(type, a, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "JSObject -> JSObject";
+ setto = window;
+ PluginTest.JSObject_type = setto;
+ now = PluginTest.JSObject_type;
+ addResult (type, setto, "[object Window]", now, row);
+ check(now, "[object Window]", "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "JSObject -> String";
+ setto = window;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "[object Window]", now, row);
+ check(now, "[object Window]", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Java Object -> Java Object";
+ PluginTest.Float_type = 1.111;
+ orig_hash = PluginTest.Float_type.hashCode();
+ PluginTest.Object_type = PluginTest.Float_type;
+ new_hash = PluginTest.Object_type.hashCode();
+ addResult (type, "hashcode=" + orig_hash, orig_hash, new_hash, row);
+ check(new_hash, orig_hash, "number", row);
+ } catch (e) {
+ error(type, "", e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "Java Object -> String";
+ setto = new PluginTest.Packages.DummyObject("Test object");
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, "Test object", now, row);
+ check(now, "Test object", "string", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+ try {
+ row = document.createElement("tr");
+ type = "null -> Java Object (String)";
+
+ // Assuming the set tests have passed, we know that object is non-null after this
+ PluginTest.String_type = "Not Null";
+
+ setto = null;
+ PluginTest.String_type = setto;
+ now = PluginTest.String_type;
+ addResult (type, setto, null, now, row);
+ check(now, null, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+
+/*
+ // NULL -> primitive tests are disabled for now due to ambiguity.
+ // Section 2.2 here: http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/
+ // States that null to primitive is not allowed, yet, section 2.3.7 claims it is..
+
+ try {
+ row = document.createElement("tr");
+ type = "null -> byte";
+
+ // Assuming the set tests have passed, we know that object is non-null after this
+ PluginTest.byte_type = "100";
+
+ setto = null;
+ PluginTest.byte_type = setto;
+ now = PluginTest.byte_type;
+ addResult (type, setto, null, now, row);
+ check(now, null, "object", row);
+ } catch (e) {
+ error(type, setto, e, row);
+ }
+ tblBody.appendChild(row);
+*/
+
+}
+
+
+