diff options
author | Jana Fabrikova <[email protected]> | 2013-02-06 16:39:43 +0100 |
---|---|---|
committer | Jana Fabrikova <[email protected]> | 2013-02-06 16:39:43 +0100 |
commit | ab80a9d3760309ffd0c84870a3ea9ee8548d847f (patch) | |
tree | ec1d670f9354edbc471f517f650803cafa2fdadc | |
parent | b4f62853fb8c9f4e671be61b9779d81e43cc8572 (diff) |
modification of JSToJSet reproducer, added JSObject case and bug annotations
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js | 12 | ||||
-rw-r--r-- | tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java | 12 | ||||
-rw-r--r-- | tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java | 61 |
4 files changed, 73 insertions, 26 deletions
@@ -1,5 +1,19 @@ 2013-02-06 Jana Fabrikova <[email protected]> + * /tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java: + adding 1 testcase setting applets variable of type JSObject from JS, + adding KnownToFail anotation and @Bug annotation with id=PR1298 to + (AppletJSToJSet_intArrayElement_Test) and + (AppletJSToJSet_DoubleArrayElement_Test) methods + * /tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js: + adding the JSObject case to (doSetTests) function + * /tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java: + adding the JSObject variable to the applet and modifying + (printNewValueAndFinish) method in order to output new values + of JSObject variable + +2013-02-06 Jana Fabrikova <[email protected]> + * /tests/reproducers/simple/JSToJGet/resources/JSToJGet.html: adding 1 testcase reading applets variable of type JSObject from JS * /tests/reproducers/simple/JSToJGet/testcases/JSToJGetTest.java: diff --git a/tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js b/tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js index cf92110..501577a 100644 --- a/tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js +++ b/tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js @@ -1,3 +1,9 @@ +//dummy javascript class whose instance is passed as JSObject parameter: +function JSCar(mph,color){ + this.mph = mph; + this.color = color; +} + function doSetTests( ){ var urlArgs = document.URL.split("?"); @@ -18,12 +24,16 @@ function doSetTests( ){ if( field === "_specialString"){ value = "𠁎〒£$ǣ€𝍖"; } + + if( field === "_JSObject"){ + value = new JSCar(100,"red"); + } + }else if(value.indexOf('[') != -1){ var elem = value.substring(1); value = new Array(); eval('value[0] = elem'); - } eval('applet.' + field + '= value'); diff --git a/tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java b/tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java index bbeec3d..842d795 100644 --- a/tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java +++ b/tests/reproducers/simple/JSToJSet/srcs/JSToJSet.java @@ -1,7 +1,7 @@ -import java.applet.*; -import java.awt.*; +import java.applet.Applet; import java.lang.reflect.Array; import java.lang.reflect.Field; +import netscape.javascript.JSObject; public class JSToJSet extends Applet { @@ -27,6 +27,7 @@ public class JSToJSet extends Applet { public Double[] _DoubleArray2; public char[] _charArray = new char[1]; public Character[] _CharacterArray = new Character[1]; + public JSObject _JSObject; public void init() { String initStr = "JSToJSet applet initialized."; @@ -36,7 +37,12 @@ public class JSToJSet extends Applet { public void printNewValueAndFinish(String fieldname) throws Exception { Field field = getClass().getDeclaredField(fieldname); Object value = field.get(this); - if (value != null && value.getClass().isArray()) { + + if( fieldname.equals("_JSObject") ){ + Integer mph = (Integer)_JSObject.getMember("mph"); + String color = (String)_JSObject.getMember("color"); + System.out.println("New value is: "+mph+", "+color); + }else if (value != null && value.getClass().isArray()) { System.out.println("New array value is: " + Array.get(value, 0)); } else { System.out.println("New value is: " + value); diff --git a/tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java b/tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java index 196c60a..0681e2b 100644 --- a/tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java +++ b/tests/reproducers/simple/JSToJSet/testcases/JSToJSetTest.java @@ -40,18 +40,25 @@ import net.sourceforge.jnlp.ServerAccess; import net.sourceforge.jnlp.browsertesting.BrowserTest; import net.sourceforge.jnlp.browsertesting.Browsers; import net.sourceforge.jnlp.closinglisteners.CountingClosingListener; +import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.annotations.KnownToFail; import net.sourceforge.jnlp.annotations.NeedsDisplay; import net.sourceforge.jnlp.annotations.TestInBrowsers; import org.junit.Assert; import org.junit.Test; +@Bug( id = { "PR1298" }) public class JSToJSetTest extends BrowserTest { private final String exceptionStr = "xception"; private final String errorStr = "rror"; private final String initStr = "JSToJSet applet initialized."; private final String afterStr = "afterTests"; + + public enum TestType{ + ARRAY_ELEMENT, WHOLE_ARRAY, NORMAL_VALUE + } private class CountingClosingListenerImpl extends CountingClosingListener { @@ -71,7 +78,7 @@ public class JSToJSetTest extends BrowserTest { // Assert that the values set by JavaScript are ok Assert.assertTrue("JSToJSet: the output should include: "+expectedStdout+", but it didnt.", - pr.stdout.contains(expectedStdout)); + pr.stdout.contains(expectedStdout)); } @@ -82,24 +89,24 @@ public class JSToJSetTest extends BrowserTest { evaluateStdoutContents(expectedStdout, pr); } - private void jsToJavaSetSpecialTest(String fieldStr, String valueStr, int testType) throws Exception { - String strURL = "/JSToJSet.html?"; - String expectedStdout = ""; - switch( testType ){ - case 0://array element - strURL += fieldStr + ";" + valueStr; - expectedStdout = "New array value is: "+valueStr; + private void jsToJavaSetSpecialTest(String fieldStr, String valueStr, TestType testType) throws Exception { + String strURL = "/JSToJSet.html?"; + String expectedStdout = ""; + switch( testType ){ + case ARRAY_ELEMENT://array element + strURL += fieldStr + ";" + valueStr; + expectedStdout = "New array value is: "+valueStr; break; - case 1://whole array, set 1st element - strURL += fieldStr + ";[" + valueStr; - expectedStdout = "New array value is: "+valueStr; - break; - case 2://char et al - to be set at JS side - strURL += fieldStr + ";JavaScript"; - expectedStdout = "New value is: "+valueStr; + case WHOLE_ARRAY://whole array, set 1st element + strURL += fieldStr + ";[" + valueStr; + expectedStdout = "New array value is: "+valueStr; + break; + case NORMAL_VALUE://char et al - to be set at JS side + strURL += fieldStr + ";JavaScript"; + expectedStdout = "New value is: "+valueStr; break; default: - break; + break; } ProcessResult pr = server.executeBrowser(strURL, new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); @@ -145,7 +152,7 @@ public class JSToJSetTest extends BrowserTest { @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay public void AppletJSToJSet_char_Test() throws Exception { - jsToJavaSetSpecialTest("_char", "a", 2); + jsToJavaSetSpecialTest("_char", "a", TestType.NORMAL_VALUE); } @Test @@ -158,8 +165,10 @@ public class JSToJSetTest extends BrowserTest { @Test @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay + @KnownToFail + @Bug( id = {"PR1298"}) public void AppletJSToJSet_intArrayElement_Test() throws Exception { - jsToJavaSetSpecialTest("_intArray[0]", "1", 0); + jsToJavaSetSpecialTest("_intArray[0]", "1", TestType.ARRAY_ELEMENT); } @Test @@ -173,7 +182,7 @@ public class JSToJSetTest extends BrowserTest { @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay public void AppletJSToJSet_specialCharsString_Test() throws Exception { - jsToJavaSetSpecialTest("_specialString", "𠁎〒£$ǣ€𝍖", 2); + jsToJavaSetSpecialTest("_specialString", "𠁎〒£$ǣ€𝍖", TestType.NORMAL_VALUE); } @Test @@ -222,7 +231,7 @@ public class JSToJSetTest extends BrowserTest { @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay public void AppletJSToJSet_Character_Test() throws Exception { - jsToJavaSetSpecialTest("_Character", "A", 2); + jsToJavaSetSpecialTest("_Character", "A", TestType.NORMAL_VALUE); } @Test @@ -235,15 +244,23 @@ public class JSToJSetTest extends BrowserTest { @Test @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay + @KnownToFail + @Bug( id = {"PR1298"}) public void AppletJSToJSet_DoubleArrayElement_Test() throws Exception { - jsToJavaSetSpecialTest("_DoubleArray[0]", "1.1", 0); + jsToJavaSetSpecialTest("_DoubleArray[0]", "1.1", TestType.ARRAY_ELEMENT); } @Test @TestInBrowsers(testIn = { Browsers.all }) @NeedsDisplay public void AppletJSToJSet_DoubleFullArray_Test() throws Exception { - jsToJavaSetSpecialTest("_DoubleArray2", "0.1", 1); + jsToJavaSetSpecialTest("_DoubleArray2", "0.1", TestType.WHOLE_ARRAY); } + @Test + @TestInBrowsers(testIn = { Browsers.all }) + @NeedsDisplay + public void AppletJSToJSet_JSObject_Test() throws Exception { + jsToJavaSetSpecialTest("_JSObject", "100, red", TestType.NORMAL_VALUE); + } } |