diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ New in release 1.3 (2012-XX-XX): - PR863: Error passing strings to applet methods in Chromium - PR895: IcedTea-Web searches for missing classes on each loadClass or findClass - PR861: Allow loading from non codebase hosts. Allow code to connect to hosting server + - PR855: AppletStub getDocumentBase() doesn't return full URL * Common - PR918: java applet windows uses a low resulution black/white icon diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc --- a/plugin/icedteanp/IcedTeaNPPlugin.cc +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc @@ -1094,24 +1094,11 @@ plugin_get_documentbase (NPP instance) href_id, &href); std::string href_str = IcedTeaPluginUtilities::NPVariantAsString(href); - - // Strip everything after the last "/" - gchar** parts = g_strsplit (href_str.c_str(), "/", -1); - guint parts_sz = g_strv_length (parts); - - std::string location_str; - for (int i=0; i < parts_sz - 1; i++) - { - location_str += parts[i]; - location_str += "/"; - } - - documentbase_copy = g_strdup (location_str.c_str()); + documentbase_copy = g_strdup (href_str.c_str()); // Release references. browser_functions.releasevariantvalue(&href); browser_functions.releasevariantvalue(&location); - g_strfreev(parts); cleanup_done: PLUGIN_DEBUG ("plugin_get_documentbase return\n"); PLUGIN_DEBUG("plugin_get_documentbase returning: %s\n", documentbase_copy); diff --git a/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html new file mode 100644 --- /dev/null +++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html @@ -0,0 +1,48 @@ +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + + --> +<html> + <head></head> + <body> + <applet code="AppletBaseURL.class" + archive="AppletBaseURLTest.jar" + codebase="." + width=800 + height=600> + </applet> + </body> +</html> diff --git a/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp new file mode 100644 --- /dev/null +++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp @@ -0,0 +1,61 @@ +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + + --> +<?xml version="1.0" encoding="utf-8"?> +<jnlp spec="1.0" href="AppletBaseURLTest.jnlp" codebase="."> + <information> + <title>AppletBaseURL</title> + <vendor>IcedTea</vendor> + <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/> + <description>AppletBaseURL</description> + <offline/> + </information> + <resources> + <j2se version="1.4+"/> + <jar href="AppletBaseURLTest.jar"/> + </resources> + <applet-desc + documentBase="." + name="AppletBaseURL" + main-class="AppletBaseURL" + width="100" + height="100"> + </applet-desc> +</jnlp> + + +</applet-desc> diff --git a/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html new file mode 100644 --- /dev/null +++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html @@ -0,0 +1,46 @@ +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + +--> +<html> + <head></head> + <body> + <applet code="AppletBaseURL.class" width=800 height=600> + <param name="jnlp_href" value="AppletBaseURLTest.jnlp"> + </applet> + </body> +</html> + diff --git a/tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java b/tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java new file mode 100644 --- /dev/null +++ b/tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java @@ -0,0 +1,64 @@ +/* AppletBaseURL.java +Copyright (C) 2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + +import java.applet.Applet; +public class AppletBaseURL extends Applet { + + private class Killer extends Thread { + + public int n = 1000; + + @Override + public void run() { + try { + Thread.sleep(n); + System.out.println("Aplet killing himself after " + n + " ms of life"); + System.exit(0); + } catch (Exception ex) { + } + } + } + private Killer killer; + + @Override + public void init() { + System.out.println("Document base is " + getDocumentBase() + " for this applet"); + System.out.println("Codebase is " + getCodeBase() + " for this applet"); + killer = new Killer(); + killer.start(); + } +} diff --git a/tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java b/tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java new file mode 100644 --- /dev/null +++ b/tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java @@ -0,0 +1,86 @@ +/* AppletBaseURLTest.java +Copyright (C) 2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerAccess.ProcessResult; +import org.junit.Assert; + +import org.junit.Test; + +public class AppletBaseURLTest { + + private static ServerAccess server = new ServerAccess(); + + private void evaluateApplet(ProcessResult pr, String baseName) { + String s8 = "(?s).*Codebase is http://localhost:[0-9]{5}/ for this applet(?s).*"; + Assert.assertTrue("AppletBaseURL stdout should match" + s8 + " but didn't", pr.stdout.matches(s8)); + String s9 = "(?s).*Document base is http://localhost:[0-9]{5}/" + baseName + " for this applet(?s).*"; + Assert.assertTrue("AppletBaseURL stdout should match" + s9 + " but didn't", pr.stdout.matches(s9)); + String ss = "xception"; + Assert.assertFalse("AppletBaseURL stderr should not contain" + ss + " but did", pr.stderr.contains(ss)); + } + + @Bug(id="PR855") + @NeedsDisplay + @Test + public void AppletWebstartBaseURLTest() throws Exception { + ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/AppletBaseURLTest.jnlp"); + evaluateApplet(pr, ""); + Assert.assertFalse(pr.wasTerminated); + Assert.assertEquals((Integer) 0, pr.returnValue); + } + + @Bug(id="PR855") + @NeedsDisplay + @Test + public void AppletInFirefoxTest() throws Exception { + ServerAccess.ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html"); + pr.process.destroy(); + evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html"); + Assert.assertTrue(pr.wasTerminated); + } + + @Bug(id="PR855") + @NeedsDisplay + @Test + public void AppletWithJNLPHrefTest() throws Exception { + ServerAccess.ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html"); + pr.process.destroy(); + evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html"); + Assert.assertTrue(pr.wasTerminated); + } +}