/hg/icedtea-web: Fixed PR855: AppletStub getDocumentBase() doesn...

ddadacha at icedtea.classpath.org ddadacha at icedtea.classpath.org
Thu Jun 14 08:11:34 PDT 2012


changeset 1819a9bbd922 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=1819a9bbd922
author: Danesh Dadachanji <ddadacha at redhat.com>
date: Thu Jun 14 11:11:01 2012 -0400

	Fixed PR855: AppletStub getDocumentBase() doesn't return full URL


diffstat:

 ChangeLog                                                                          |  15 +
 NEWS                                                                               |   1 +
 plugin/icedteanp/IcedTeaNPPlugin.cc                                                |  15 +-
 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html         |  48 +++++
 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp         |  58 ++++++
 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html |  46 +++++
 tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java                  |  64 +++++++
 tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java         |  87 ++++++++++
 8 files changed, 320 insertions(+), 14 deletions(-)

diffs (385 lines):

diff -r 2c788a60aa65 -r 1819a9bbd922 ChangeLog
--- a/ChangeLog	Wed Jun 13 17:46:31 2012 -0400
+++ b/ChangeLog	Thu Jun 14 11:11:01 2012 -0400
@@ -1,3 +1,18 @@
+2012-06-11  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.
+
 2012-06-13  Danesh Dadachanji  <ddadacha at redhat.com>
 
 	Update CheckServices reproducer to handle browser testcase.
diff -r 2c788a60aa65 -r 1819a9bbd922 NEWS
--- a/NEWS	Wed Jun 13 17:46:31 2012 -0400
+++ b/NEWS	Thu Jun 14 11:11:01 2012 -0400
@@ -19,6 +19,7 @@
   - PR861: Allow loading from non codebase hosts. Allow code to connect to hosting server
   - PR518: NPString.utf8characters not guaranteed to be nul-terminated
   - PR722: META-INF/ unsigned entries should be ignored in signing
+  - PR855: AppletStub getDocumentBase() doesn't return full URL
 * Common
   - PR918: java applet windows uses a low resulution black/white icon
 
diff -r 2c788a60aa65 -r 1819a9bbd922 plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Wed Jun 13 17:46:31 2012 -0400
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Thu Jun 14 11:11:01 2012 -0400
@@ -1094,24 +1094,11 @@
                                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 -r 2c788a60aa65 -r 1819a9bbd922 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.html	Thu Jun 14 11:11:01 2012 -0400
@@ -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 -r 2c788a60aa65 -r 1819a9bbd922 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletBaseURLTest.jnlp	Thu Jun 14 11:11:01 2012 -0400
@@ -0,0 +1,58 @@
+<!--
+
+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>
diff -r 2c788a60aa65 -r 1819a9bbd922 tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/AppletBaseURLTest/resources/AppletJNLPHrefBaseURLTest.html	Thu Jun 14 11:11:01 2012 -0400
@@ -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 -r 2c788a60aa65 -r 1819a9bbd922 tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/AppletBaseURLTest/srcs/AppletBaseURL.java	Thu Jun 14 11:11:01 2012 -0400
@@ -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 -r 2c788a60aa65 -r 1819a9bbd922 tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java	Thu Jun 14 11:11:01 2012 -0400
@@ -0,0 +1,87 @@
+/* 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 net.sourceforge.jnlp.annotations.Bug;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+
+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));
+    }
+
+    @NeedsDisplay
+    @Test
+    public void AppletWebstartBaseURLTest() throws Exception {
+        ProcessResult pr = server.executeJavaws(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 {
+        ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html");
+        pr.process.destroy();
+        evaluateApplet(pr, "AppletBaseURLTest.html");
+        Assert.assertTrue(pr.wasTerminated);
+    }
+
+    @Bug(id="PR855")
+    @NeedsDisplay
+    @Test
+    public void AppletWithJNLPHrefTest() throws Exception {
+        ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html");
+        pr.process.destroy();
+        evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html");
+        Assert.assertTrue(pr.wasTerminated);
+    }
+}



More information about the distro-pkg-dev mailing list