diff options
5 files changed, 60 insertions, 48 deletions
@@ -1,3 +1,14 @@ +2013-01-04 Adam Domurad <[email protected]> + + * plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java: + Code-formatting fixes and cosmetic changes. + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: + Same. + * tests/reproducers/simple/JSObjectFromEval/srcs/JSObjectFromEval.java: + Same. + * tests/reproducers/simple/JSObjectFromEval/testcases/JSObjectFromEvalTest.java: + Same. + 2013-01-03 Adam Domurad <[email protected]> Fix breakage in unit test CodeBaseClassLoaderTest.testParentClassLoaderIsAskedForClassesApplication diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java index 733c644..dc209ff 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java @@ -53,13 +53,16 @@ import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.util.ArrayList; +import java.util.Arrays; import java.util.Hashtable; import java.util.List; import java.util.Map; -import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.DefaultLaunchHandler; +import net.sourceforge.jnlp.runtime.JNLPRuntime; +import netscape.javascript.JSObject; import netscape.javascript.JSObjectCreatePermission; +import netscape.javascript.JSUtil; class Signature { private String signature; @@ -489,9 +492,7 @@ public class PluginAppletSecurityContext { final Object fValue = MethodOverloadResolver.getCostAndCastedObject(value, f.getType())[1]; AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext(); - checkPermission(src, - message.startsWith("SetStaticField") ? (Class) o : o.getClass(), - acc); + checkPermission(src, message.startsWith("SetStaticField") ? (Class) o : o.getClass(), acc); Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { @@ -514,8 +515,9 @@ public class PluginAppletSecurityContext { Integer arrayID = parseCall(args[1], null, Integer.class); Integer index = parseCall(args[2], null, Integer.class); - Object ret = Array.get(store.getObject(arrayID), index); - Class retClass = store.getObject(arrayID).getClass().getComponentType(); // prevent auto-boxing influence + Object array = store.getObject(arrayID); + Object ret = Array.get(array, index); + Class<?> retClass = array.getClass().getComponentType(); // prevent auto-boxing influence if (ret == null) { write(reference, "GetObjectArrayElement literalreturn null"); diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java index c98899a..3a56133 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java @@ -1014,9 +1014,10 @@ public class PluginAppletViewer extends XEmbeddedFrame } public static void setMember(long internal, String name, Object value) { - System.err.println("Setting to class " + value.getClass() + ":" + value.getClass().isPrimitive()); - AppletSecurityContextManager.getSecurityContext(0).store(name); - int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name); + PluginDebug.debug("Setting to class " + value.getClass() + ":" + value.getClass().isPrimitive()); + PluginAppletSecurityContext securityContext = AppletSecurityContextManager.getSecurityContext(0); + securityContext.store(name); + int nameID = securityContext.getIdentifier(name); Long reference = getRequestIdentifier(); // work on a copy of value, as we don't want to be manipulating @@ -1072,7 +1073,8 @@ public class PluginAppletViewer extends XEmbeddedFrame // FIXME: handle long index as well. public static void setSlot(long internal, int index, Object value) { - AppletSecurityContextManager.getSecurityContext(0).store(value); + PluginAppletSecurityContext securityContext = AppletSecurityContextManager.getSecurityContext(0); + securityContext.store(value); Long reference = getRequestIdentifier(); // work on a copy of value, as we don't want to be manipulating diff --git a/tests/reproducers/simple/JSObjectFromEval/srcs/JSObjectFromEval.java b/tests/reproducers/simple/JSObjectFromEval/srcs/JSObjectFromEval.java index 2aa42d2..370d94d 100644 --- a/tests/reproducers/simple/JSObjectFromEval/srcs/JSObjectFromEval.java +++ b/tests/reproducers/simple/JSObjectFromEval/srcs/JSObjectFromEval.java @@ -55,8 +55,6 @@ public class JSObjectFromEval extends Applet { } public void setJSMember(JSObject js, String memb, Object val) { - String typeName = val.getClass().getName(); - System.out.println("setJSMember: passed '" + typeName + "'"); js.setMember(memb, val); } }
\ No newline at end of file diff --git a/tests/reproducers/simple/JSObjectFromEval/testcases/JSObjectFromEvalTest.java b/tests/reproducers/simple/JSObjectFromEval/testcases/JSObjectFromEvalTest.java index 42c1b07..a50c87d 100644 --- a/tests/reproducers/simple/JSObjectFromEval/testcases/JSObjectFromEvalTest.java +++ b/tests/reproducers/simple/JSObjectFromEval/testcases/JSObjectFromEvalTest.java @@ -37,10 +37,11 @@ exception statement from your version. import static org.junit.Assert.assertTrue; +import net.sourceforge.jnlp.annotations.KnownToFail; + import net.sourceforge.jnlp.ProcessResult; import net.sourceforge.jnlp.ServerAccess.AutoClose; 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 net.sourceforge.jnlp.browsertesting.BrowserTest; @@ -51,40 +52,38 @@ import org.junit.Test; public class JSObjectFromEvalTest extends BrowserTest { - private static final String END_STRING = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING; - - private static final String JAVA_CREATE = "Java create\n"; - private static final String JS_CREATE = "JS create\n"; - private static final String JAVA_SET = "Java set\n"; - private static final String PASSED_INTEGER = "setJSMember: passed 'java.lang.Integer'\n"; - private static final String CORRECT_VALUE = "obj.test = 0"; - - @Test - @TestInBrowsers(testIn = { Browsers.all }) - @NeedsDisplay - @Bug(id = { "PR1198" }) - @KnownToFail - public void testJSObjectSetMemberIsSet() throws Exception { - ProcessResult pr = server.executeBrowser("/JSObjectFromEval.html", - AutoClose.CLOSE_ON_BOTH); - - String expectedJSCreateOutput = JS_CREATE + JAVA_SET + PASSED_INTEGER - + CORRECT_VALUE; - String expectedJavaCreateOutput = JAVA_CREATE + JAVA_SET - + PASSED_INTEGER + CORRECT_VALUE; - - // No reason JS create should fail, this is mostly a sanity check: - assertTrue("stdout should contain 'JS create [...] " + CORRECT_VALUE - + "' but did not.", pr.stdout.contains(expectedJSCreateOutput)); - - // Demonstrates PR1198: - assertTrue("stdout should contain 'Java create [...] " + CORRECT_VALUE - + "' but did not.", - pr.stdout.contains(expectedJavaCreateOutput)); - - // Make sure we got to the end of the script - assertTrue("stdout should contain '" + END_STRING + "' but did not.", - pr.stdout.contains(END_STRING)); - } + private static final String END_STRING = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING; + + private static final String JAVA_CREATE = "Java create\n"; + private static final String JS_CREATE = "JS create\n"; + private static final String JAVA_SET = "Java set\n"; + private static final String CORRECT_VALUE = "obj.test = 0"; + + @Test + @TestInBrowsers(testIn = { Browsers.all }) + @NeedsDisplay + @KnownToFail + @Bug(id = { "PR1198" }) + public void testJSObjectSetMemberIsSet() throws Exception { + ProcessResult pr = server.executeBrowser("/JSObjectFromEval.html", + AutoClose.CLOSE_ON_BOTH); + + String expectedJSCreateOutput = JS_CREATE + JAVA_SET + CORRECT_VALUE; + String expectedJavaCreateOutput = JAVA_CREATE + JAVA_SET + + CORRECT_VALUE; + + // No reason JS create should fail, this is mostly a sanity check: + assertTrue("stdout should contain 'JS create [...] " + CORRECT_VALUE + + "' but did not.", pr.stdout.contains(expectedJSCreateOutput)); + + // Demonstrates PR1198: + assertTrue("stdout should contain 'Java create [...] " + CORRECT_VALUE + + "' but did not.", + pr.stdout.contains(expectedJavaCreateOutput)); + + // Make sure we got to the end of the script + assertTrue("stdout should contain '" + END_STRING + "' but did not.", + pr.stdout.contains(END_STRING)); + } } |