[RFC][icedtea-web] Fix for PR855: AppletStub getDocumentBase() doesn't return full URL

Jiri Vanek jvanek at redhat.com
Wed Jun 13 07:13:52 PDT 2012


On 06/08/2012 06:23 PM, Danesh Dadachanji wrote:
> On 07/06/12 04:32 PM, Danesh Dadachanji wrote:
>> On 05/06/12 08:15 AM, Jiri Vanek wrote:
>>> On 06/04/2012 11:53 PM, Danesh Dadachanji wrote:
>>>> On 18/05/12 05:15 AM, Jiri Vanek wrote:
>>>>> On 05/17/2012 11:16 PM, Danesh Dadachanji wrote:
>>>>>>
>>>>>> On 16/04/12 01:18 PM, Deepak Bhole wrote:
...snip...
>>
>
>
> Realized I had not added a NEWS entry, patch updated.
>


Thanx for tests. They are passed, failed, failed before fix - assuming the nature of fox I think it
is correct (correct me if I'm wrong!)
Also according to the nature of patch I guess there is no need to test application+jnlp behaviour. 
If it should be tested please prepare another changeset of tests for this (you can reuse your applet)

four errors in code bellow please. After fixing, ensure all reproducers flow through testsuites and 
  push.

> Updated ChangeLog:
> +2012-06-07  Danesh Dadachanji <ddadacha at redhat.com>
> +
> +    PR855: AppletStub getDocumentBase() doesn't return full URL
> +    * NEWS: Added PR855 entry.
> +    * plugin/icedteanp/IcedTeaNPPlugin.cc (plugin_get_documentbase):
> +    Assign documentbase_copy directly to href's value instead of iterating
> +    through the segments to remove the file from the path.
> +    * tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java:
> +    * tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java:
> +    * tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html:
> +    * tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp:
> +    * tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html:
> +    New reproducer that checks the URLS that document and codebase
> +    point are correct.
> +
>
> Cheers,
> Danesh
>
> get-document-base-05.patch
>
>
> 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>

please add quotes. ^ and ^^
> +</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>

quotes too                                   ^         ^

The quotes generally does not matter in html, but :)

> +<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;
> +

doh! You are missing imports of annotations here!

> +import org.junit.Test;
> +
> +public class AppletBaseURLTest {
> +
> +    private static ServerAccess server = new ServerAccess();
> +
> +    private void evaluateApplet(ProcessResult pr, String baseName) {
> +        String s8 = "(?s).*Codebase ishttp://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 ishttp://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

NeedsDisplay+executeJavawsHeadless have no sense. But for applets you _should_ use just executeJavaws

Applets are always not-headless:(

> +    @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);
> +    }
> +}
>

Tahnx for it again. After fixing issues feel free for head.



More information about the distro-pkg-dev mailing list