diff --git a/test/nashorn/script/basic/JDK-8010946-privileged.js b/test/nashorn/script/basic/JDK-8010946-privileged.js deleted file mode 100644 index 2e04f542..00000000 --- a/test/nashorn/script/basic/JDK-8010946-privileged.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JDK-8010946: AccessController.doPrivileged() doesn't work as expected. - * This is actually a broader issue of having Dynalink correctly handle - * caller-sensitive methods. - * - * NOTE: This is not a standalone test file, it is loaded by JDK-801946.js - * @subtest - */ - -(function() { - var getProperty = java.lang.System.getProperty - var doPrivileged = java.security.AccessController["doPrivileged(PrivilegedAction)"] - - this.executeUnprivileged = function() { - var x = getProperty("java.security.policy") - if(x != null) { - print("Successfully retrieved restricted system property.") - } - } - - this.executePrivileged = function() { - doPrivileged(executeUnprivileged) - } -})(); diff --git a/test/nashorn/script/basic/JDK-8010946.js b/test/nashorn/script/basic/JDK-8010946.js deleted file mode 100644 index 290d60ea..00000000 --- a/test/nashorn/script/basic/JDK-8010946.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JDK-8010946: AccessController.doPrivileged() doesn't work as expected. - * This is actually a broader issue of having Dynalink correctly handle - * caller-sensitive methods. - * - * @test - * @run - */ - -// This is unprivileged code that loads privileged code. -load(__DIR__ + "JDK-8010946-privileged.js") - -try { - // This should fail, even though the code itself resides in the - // privileged script, as we're invoking it without going through - // doPrivileged() - print("Attempting unprivileged execution...") - executeUnprivileged() - print("FAIL: Unprivileged execution succeeded!") -} catch(e) { - print("Unprivileged execution failed with " + e) -} - -print() - -// This should succeed, as it's going through doPrivileged(). -print("Attempting privileged execution...") -executePrivileged() diff --git a/test/nashorn/script/basic/JDK-8010946.js.EXPECTED b/test/nashorn/script/basic/JDK-8010946.js.EXPECTED deleted file mode 100644 index f78956a8..00000000 --- a/test/nashorn/script/basic/JDK-8010946.js.EXPECTED +++ /dev/null @@ -1,5 +0,0 @@ -Attempting unprivileged execution... -Unprivileged execution failed with java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.security.policy" "read") - -Attempting privileged execution... -Successfully retrieved restricted system property. diff --git a/test/nashorn/script/basic/JDK-8020508.js b/test/nashorn/script/basic/JDK-8020508.js deleted file mode 100644 index 3499e174..00000000 --- a/test/nashorn/script/basic/JDK-8020508.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JDK-8020508: Enforce reflection check on - * Object.bindProperties(target, source) for beans - * - * @test - * @run - */ - -var x = {} -try { - Object.bindProperties(x, java.util.Vector.class) -} catch(e) { - print(e) -} diff --git a/test/nashorn/script/basic/JDK-8020508.js.EXPECTED b/test/nashorn/script/basic/JDK-8020508.js.EXPECTED deleted file mode 100644 index 356053d4..00000000 --- a/test/nashorn/script/basic/JDK-8020508.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") diff --git a/test/nashorn/script/basic/JDK-8158467.js b/test/nashorn/script/basic/JDK-8158467.js index 51eda1ee..28d3a195 100644 --- a/test/nashorn/script/basic/JDK-8158467.js +++ b/test/nashorn/script/basic/JDK-8158467.js @@ -60,20 +60,6 @@ EOF); print(obj.hashCode()); print(obj.toString()); -// should throw SecurityException! -try { - e.eval("Packages.jdk.internal"); -} catch (ex) { - print(ex); -} - -// should throw SecurityException! -try { - e.eval("Java.type('jdk.internal.misc.Unsafe')"); -} catch (ex) { - print(ex); -} - // should throw ClassNotFoundException! try { e.eval("Java.type('org.openjdk.nashorn.internal.runtime.Context')"); diff --git a/test/nashorn/script/basic/JDK-8158467.js.EXPECTED b/test/nashorn/script/basic/JDK-8158467.js.EXPECTED index 63c41c28..12c61251 100644 --- a/test/nashorn/script/basic/JDK-8158467.js.EXPECTED +++ b/test/nashorn/script/basic/JDK-8158467.js.EXPECTED @@ -4,7 +4,5 @@ hello Runnable 33 I'm object -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.jdk.internal") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.jdk.internal.misc") java.lang.RuntimeException: java.lang.ClassNotFoundException: org.openjdk.nashorn.internal.runtime.Context java.lang.ClassNotFoundException: org.openjdk.nashorn.api.scripting.JSObject diff --git a/test/nashorn/script/basic/classloader.js b/test/nashorn/script/basic/classloader.js deleted file mode 100644 index b46d23e4..00000000 --- a/test/nashorn/script/basic/classloader.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to extend ClassLoader. - * - * @test - * @security - */ - -try { - var l = new (Java.extend(java.lang.ClassLoader))({}); - fail("should have thrown SecurityException"); -} catch (e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - diff --git a/test/nashorn/script/basic/classloader.js.EXPECTED b/test/nashorn/script/basic/classloader.js.EXPECTED deleted file mode 100644 index e08cc9f8..00000000 --- a/test/nashorn/script/basic/classloader.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createClassLoader") diff --git a/test/nashorn/script/sandbox/JDK-8031106.js b/test/nashorn/script/sandbox/JDK-8031106.js deleted file mode 100644 index 26d15a2a..00000000 --- a/test/nashorn/script/sandbox/JDK-8031106.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JDK-8031106: Nashorn: IndexOutOfBoundsException in NashornCallSiteDescriptor.getNameToken() - * - * @test - * @run - */ - -var cl = new java.lang.Object().getClass(); -try { - cl["forName"]; - fail("Should have thrown exception!"); -} catch (e) { - if (! (e instanceof java.lang.SecurityException)) { - fail("SecurityException expected, got " + e); - } -} diff --git a/test/nashorn/script/sandbox/classbind.js b/test/nashorn/script/sandbox/classbind.js deleted file mode 100644 index 05e12928..00000000 --- a/test/nashorn/script/sandbox/classbind.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to bind properties of StaticClass representing Class. - * - * @test - * @bug JDK-8032943: Improve reflection in Nashorn - */ - - -var obj = {} - -try { - Object.bindProperties(obj, Java.type("java.lang.Class")); - fail("SecurityException should have been thrown"); -} catch (e) { - if (! (e instanceof java.lang.SecurityException)) { - fail("SecurityException expected, got " + e); - } -} diff --git a/test/nashorn/script/sandbox/classloader.js b/test/nashorn/script/sandbox/classloader.js deleted file mode 100644 index 36cf464c..00000000 --- a/test/nashorn/script/sandbox/classloader.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to extend ClassLoader. - * - * @test - * @security - * @bug JDK-8032954: Nashorn: extend Java.extend - */ - -try { - var l = new (Java.extend(java.lang.ClassLoader))({}); - fail("should have thrown SecurityException"); -} catch (e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - Java.extend(Java.type('java.lang.ClassLoader')); - fail("should have thrown SecurityException"); -} catch (e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - Java.extend(Java.type("javax.management.loading.MLet")); - fail("should have thrown SecurityException"); -} catch (e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} diff --git a/test/nashorn/script/sandbox/classloader.js.EXPECTED b/test/nashorn/script/sandbox/classloader.js.EXPECTED deleted file mode 100644 index 8c241912..00000000 --- a/test/nashorn/script/sandbox/classloader.js.EXPECTED +++ /dev/null @@ -1,3 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") diff --git a/test/nashorn/script/sandbox/doprivileged.js b/test/nashorn/script/sandbox/doprivileged.js deleted file mode 100644 index 5b08361f..00000000 --- a/test/nashorn/script/sandbox/doprivileged.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * doPrivileged checks. - * - * @test - * @security - */ - -function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -var AccessController = java.security.AccessController; -var PrivilegedAction = java.security.PrivilegedAction; - -AccessController.doPrivileged(new PrivilegedAction() { - run: function() { - // try something sensitive - try { - java.lang.System.exit(0); - } catch(e) { - check(e); - } - - try { - var prop = java.lang.System.getProperty("user.dir"); - fail("can get user.dir " + prop); - } catch(e) { - print(e); - } - } -}); diff --git a/test/nashorn/script/sandbox/doprivileged.js.EXPECTED b/test/nashorn/script/sandbox/doprivileged.js.EXPECTED deleted file mode 100644 index 0730cdd4..00000000 --- a/test/nashorn/script/sandbox/doprivileged.js.EXPECTED +++ /dev/null @@ -1,2 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0") -java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read") diff --git a/test/nashorn/script/sandbox/env.js b/test/nashorn/script/sandbox/env.js deleted file mode 100644 index 5ef40a2d..00000000 --- a/test/nashorn/script/sandbox/env.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to get env object - * - * @test - * @security - * @option -scripting - */ - -var env = $ENV; -// should be empty!! -for (i in env) { - print("FAILED: can get: " + i + " = " + env[i]); -} diff --git a/test/nashorn/script/sandbox/exec.js b/test/nashorn/script/sandbox/exec.js deleted file mode 100644 index 0f32938e..00000000 --- a/test/nashorn/script/sandbox/exec.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to get exec - * - * @test - * @security - * @option -scripting - */ - -try { - var ans = `java -version`; - fail("should have thrown exception!"); -} catch (e) { - if (! (e instanceof java.lang.SecurityException)) { - fail("SecurityException expected, got " + e); - } -} diff --git a/test/nashorn/script/sandbox/exit.js b/test/nashorn/script/sandbox/exit.js deleted file mode 100644 index b807c976..00000000 --- a/test/nashorn/script/sandbox/exit.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to call System.exit, quit and exit. - * - * @test - * @security - */ - -function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - java.lang.System.exit(0); - // will not reach here regardless of outcome.. -} catch (e) { - check(e); -} - -try { - quit(); - // will not reach here regardless of outcome.. -} catch (e) { - check(e); -} - -try { - exit(0); - // will not reach here regardless of outcome.. -} catch (e) { - check(e); -} - -print("Success, didn't exit!"); diff --git a/test/nashorn/script/sandbox/exit.js.EXPECTED b/test/nashorn/script/sandbox/exit.js.EXPECTED deleted file mode 100644 index c1411eb8..00000000 --- a/test/nashorn/script/sandbox/exit.js.EXPECTED +++ /dev/null @@ -1,4 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0") -Success, didn't exit! diff --git a/test/nashorn/script/sandbox/file.js b/test/nashorn/script/sandbox/file.js deleted file mode 100644 index 3aaa8978..00000000 --- a/test/nashorn/script/sandbox/file.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * try file system activities. - * - * @test - * @security - */ - -function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - new java.io.File(".").getCanonicalPath(); -} catch (e) { - check(e); -} - -try { - new java.io.FileInputStream("foo"); -} catch (e) { - check(e); -} - -try { - new java.io.FileOutputStream("foo"); -} catch (e) { - check(e); -} diff --git a/test/nashorn/script/sandbox/file.js.EXPECTED b/test/nashorn/script/sandbox/file.js.EXPECTED deleted file mode 100644 index 5a1e0e45..00000000 --- a/test/nashorn/script/sandbox/file.js.EXPECTED +++ /dev/null @@ -1,3 +0,0 @@ -java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read") -java.security.AccessControlException: access denied ("java.io.FilePermission" "foo" "read") -java.security.AccessControlException: access denied ("java.io.FilePermission" "foo" "write") diff --git a/test/nashorn/script/sandbox/loadLibrary.js b/test/nashorn/script/sandbox/loadLibrary.js deleted file mode 100644 index e693d222..00000000 --- a/test/nashorn/script/sandbox/loadLibrary.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to call System.loadLibrary - * - * @test - * @security - */ - -function check(e) { - if (! (e instanceof java.lang.SecurityException)) { - fail("expected SecurityException, got " + e); - } -} - -try { - java.lang.System.loadLibrary("foo"); - fail("should have thrown exception"); -} catch (e) { - check(e); -} - diff --git a/test/nashorn/script/sandbox/net.js b/test/nashorn/script/sandbox/net.js deleted file mode 100644 index c7fd8d01..00000000 --- a/test/nashorn/script/sandbox/net.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try network activity. - * - * @test - * @security - */ - -function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - new java.net.URL("http://www.acme.com").openStream(); -} catch (e) { - check(e); -} diff --git a/test/nashorn/script/sandbox/net.js.EXPECTED b/test/nashorn/script/sandbox/net.js.EXPECTED deleted file mode 100644 index dfa7334a..00000000 --- a/test/nashorn/script/sandbox/net.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.net.SocketPermission" "www.acme.com:80" "connect,resolve") diff --git a/test/nashorn/script/sandbox/property.js b/test/nashorn/script/sandbox/property.js deleted file mode 100644 index 8aeb499e..00000000 --- a/test/nashorn/script/sandbox/property.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Try to read sensitive System property. - * - * @test - * @security - */ - -function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { - fail("expected SecurityException, got " + e); - } -} - -try { - var prop = java.lang.System.getProperty("user.dir"); - fail("can read user.dir " + prop); -} catch (e) { - check(e); -} diff --git a/test/nashorn/script/sandbox/property.js.EXPECTED b/test/nashorn/script/sandbox/property.js.EXPECTED deleted file mode 100644 index 73c67af5..00000000 --- a/test/nashorn/script/sandbox/property.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read") diff --git a/test/nashorn/script/sandbox/unsafe.js b/test/nashorn/script/sandbox/unsafe.js index 9c6f1b82..457a69a9 100644 --- a/test/nashorn/script/sandbox/unsafe.js +++ b/test/nashorn/script/sandbox/unsafe.js @@ -35,27 +35,6 @@ function check(e) { } } -try { - var unsafe = java.lang.Class.forName("sun.misc.Unsafe"); - fail("No SecurityException for Class.forName sun.misc.Unsafe"); -} catch (e) { - check(e); -} - -try { - var unsafe = Java.type("sun.misc.Unsafe"); - fail("No SecurityException for Java.type sun.misc.Unsafe"); -} catch (e) { - check(e); -} - -try { - var unsafe = Packages.sun.misc.Unsafe; - fail("No SecurityException for Packages.sun.misc.Unsafe"); -} catch (e) { - check(e); -} - try { var cl = Packages.org.openjdk.nashorn.internal.runtime.Context.class; var unsafe = cl.getClassLoader().loadClass("sun.misc.Unsafe"); diff --git a/test/nashorn/script/trusted/JDK-8008305.js b/test/nashorn/script/trusted/JDK-8008305.js index 7bdd8456..3acd5bb5 100644 --- a/test/nashorn/script/trusted/JDK-8008305.js +++ b/test/nashorn/script/trusted/JDK-8008305.js @@ -49,11 +49,4 @@ if (! res.equals(new File(".").getAbsolutePath())) { } // try same subtest without URLReader and so it runs with null code source -try { - e.eval(new FileReader(scriptFile)); - fail("Expected SecurityException from script!"); -} catch (e) { - if (! (e instanceof SecurityException)) { - fail("Expected SecurityException, but got " + e); - } -} +e.eval(new FileReader(scriptFile)); diff --git a/test/nashorn/script/trusted/JDK-8021129.js b/test/nashorn/script/trusted/JDK-8021129.js index b55c48d3..69471655 100644 --- a/test/nashorn/script/trusted/JDK-8021129.js +++ b/test/nashorn/script/trusted/JDK-8021129.js @@ -37,7 +37,6 @@ print(r1.toString()) // Can execute public method from a superclass print(r1.restrictedRun === undefined) // Can't see method from a restricted interface print(r1.canNotInvokeThis === undefined) // Can't see any other public methods -print(r1.invisibleProperty === undefined) // Can't see any other properties print(r1.canSeeThisField === undefined) // Can't see fields from superclasses print(r1.canNotSeeThisField === undefined) // Can't see its own fields diff --git a/test/nashorn/script/trusted/JDK-8021129.js.EXPECTED b/test/nashorn/script/trusted/JDK-8021129.js.EXPECTED index df787933..6caa5de0 100644 --- a/test/nashorn/script/trusted/JDK-8021129.js.EXPECTED +++ b/test/nashorn/script/trusted/JDK-8021129.js.EXPECTED @@ -1,9 +1,8 @@ InternalRunnable.run() executed! InternalRunnable.toString() executed! +false +false true -true -true -true -true +false 19 diff --git a/test/nashorn/script/trusted/JDK-8021189.js b/test/nashorn/script/trusted/JDK-8021189.js deleted file mode 100644 index f7afd1a6..00000000 --- a/test/nashorn/script/trusted/JDK-8021189.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JDK-8021189: Prevent access to constructors of restricted classes - * - * @test - * @run - */ -var InternalRunnableSuperclass = Java.type("org.openjdk.nashorn.test.models.InternalRunnableSuperclass"); -try { - new (InternalRunnableSuperclass.getInternalRunnableType())(); -} catch(e) { - print(e) -} diff --git a/test/nashorn/script/trusted/JDK-8021189.js.EXPECTED b/test/nashorn/script/trusted/JDK-8021189.js.EXPECTED deleted file mode 100644 index 8aa5d69c..00000000 --- a/test/nashorn/script/trusted/JDK-8021189.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.org.openjdk.nashorn.internal.test.models") diff --git a/test/nashorn/script/trusted/classfilter_extends.js.EXPECTED b/test/nashorn/script/trusted/classfilter_extends.js.EXPECTED index b122020d..638a5392 100644 --- a/test/nashorn/script/trusted/classfilter_extends.js.EXPECTED +++ b/test/nashorn/script/trusted/classfilter_extends.js.EXPECTED @@ -12,5 +12,5 @@ java.lang.ClassNotFoundException: java.lang.String TypeError: Java.extend needs Java types as its arguments. in at line number 1 java.lang.NullPointerException java.lang.ClassNotFoundException: java.lang.NullPointerException -java.lang.NullPointerException: library can't be null -java.lang.NullPointerException: library can't be null +java.lang.NullPointerException +java.lang.NullPointerException diff --git a/test/nashorn/src/org/openjdk/nashorn/internal/performance/OctaneTest.java b/test/nashorn/src/org/openjdk/nashorn/internal/performance/OctaneTest.java index 4c3a04e8..a2e85882 100644 --- a/test/nashorn/src/org/openjdk/nashorn/internal/performance/OctaneTest.java +++ b/test/nashorn/src/org/openjdk/nashorn/internal/performance/OctaneTest.java @@ -108,15 +108,17 @@ public void splayTest() { genericTest("Splay"); } +/* @Test -/* public void typeScriptTest() { + public void typeScriptTest() { genericTest("TypeScript"); } @Test public void zlibTest() { genericTest("zlib"); - }/*/ + } +*/ public void genericTest(final String benchmark) { try { diff --git a/test/nashorn/src/org/openjdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java b/test/nashorn/src/org/openjdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java index ab41f8ba..850960da 100644 --- a/test/nashorn/src/org/openjdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java +++ b/test/nashorn/src/org/openjdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java @@ -36,6 +36,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptException; import org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -390,12 +391,20 @@ public class CodeStoreAndPathTest { " return object; \n" + " })(); \n" + "}()); "; - final static String codeCache = System.getProperty("build.dir", "build") + "/nashorn_code_cache"; + final static String codeCache = System.getProperty("build.dir", "build") + File.separator + "nashorn_code_cache"; final static String oldUserDir = System.getProperty("user.dir"); private static final String[] ENGINE_OPTIONS_OPT = new String[]{"--persistent-code-cache", "--optimistic-types=true"}; private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"}; + @BeforeMethod + public void emptyCache() { + File codeCacheDir = new File(codeCache); + if (codeCacheDir.isDirectory()) { + deleteDirectory(codeCacheDir); + } + } + @Test public void pathHandlingTest() { System.setProperty("nashorn.persistent.code.cache", codeCache); @@ -506,4 +515,19 @@ private static void checkCompiledScripts(final DirectoryStream stream, fin assertEquals(n, 0); } + public static void deleteDirectory(File dir) { + File[] files = dir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + deleteDirectory(file); + } else { + assertTrue(file.delete(), "Failed to delete file: " + file.getAbsolutePath()); + } + } + } + + // Delete the directory itself + assertTrue(dir.delete(), "Failed to delete directory: " + dir.getAbsolutePath()); + } } diff --git a/test/nashorn/src/org/openjdk/nashorn/internal/test/models/InternalRunnable.java b/test/nashorn/src/org/openjdk/nashorn/internal/test/models/InternalRunnable.java index 1a27260e..4a5ed185 100644 --- a/test/nashorn/src/org/openjdk/nashorn/internal/test/models/InternalRunnable.java +++ b/test/nashorn/src/org/openjdk/nashorn/internal/test/models/InternalRunnable.java @@ -63,9 +63,4 @@ public void canNotInvokeThis() { // This is a public method in a restricted class; scripts should not see it. throw new AssertionError(); } - - public void getInvisibleProperty() { - // This is a public method in a restricted class; scripts should not see it. - throw new AssertionError(); - } }