[HtmlUnit] SVN: [13819] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[HtmlUnit] SVN: [13819] trunk/htmlunit/src

rbri
Revision: 13819
          http://sourceforge.net/p/htmlunit/code/13819
Author:   rbri
Date:     2017-03-18 13:35:04 +0000 (Sat, 18 Mar 2017)
Log Message:
-----------
more applet support

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlApplet.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlObject.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java

Added Paths:
-----------
    trunk/htmlunit/src/test/resources/applets/cacheArchiveApplet.html
    trunk/htmlunit/src/test/resources/objects/cacheArchiveApplet.html

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlApplet.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlApplet.java 2017-03-18 13:10:18 UTC (rev 13818)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlApplet.java 2017-03-18 13:35:04 UTC (rev 13819)
@@ -55,6 +55,7 @@
     private static final Log LOG = LogFactory.getLog(HtmlApplet.class);
 
     private static final String ARCHIVE = "archive";
+    private static final String CACHE_ARCHIVE = "cache_archive";
     private static final String CODEBASE = "codebase";
 
     /** The HTML tag represented by this element. */
@@ -273,7 +274,7 @@
 
         // check archive
         archiveUrls_ = new LinkedList<>();
-        final String[] archives = StringUtils.split(params.get(ARCHIVE), ',');
+        String[] archives = StringUtils.split(params.get(ARCHIVE), ',');
         if (null != archives) {
             for (int i = 0; i < archives.length; i++) {
                 final String tmpArchive = archives[i].trim();
@@ -284,6 +285,17 @@
                 archiveUrls_.add(archiveUrl);
             }
         }
+        archives = StringUtils.split(params.get(CACHE_ARCHIVE), ',');
+        if (null != archives) {
+            for (int i = 0; i < archives.length; i++) {
+                final String tmpArchive = archives[i].trim();
+                final String tempUrl = UrlUtils.resolveUrl(baseUrl, tmpArchive);
+                final URL archiveUrl = UrlUtils.toUrlUnsafe(tempUrl);
+
+                appletClassLoader_.addArchiveToClassPath(archiveUrl);
+                archiveUrls_.add(archiveUrl);
+            }
+        }
         archiveUrls_ = Collections.unmodifiableList(archiveUrls_);
 
         // no archive attribute, single class

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlObject.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlObject.java 2017-03-18 13:10:18 UTC (rev 13818)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlObject.java 2017-03-18 13:35:04 UTC (rev 13819)
@@ -55,6 +55,7 @@
 
     private static final String APPLET_TYPE = "application/x-java-applet";
     private static final String ARCHIVE = "archive";
+    private static final String CACHE_ARCHIVE = "cache_archive";
     private static final String CODEBASE = "codebase";
 
     /** The HTML tag represented by this element. */
@@ -336,14 +337,9 @@
         }
 
         final HashMap<String, String> params = new HashMap<>();
-//        params.put("name", getNameAttribute());
-//
-//        params.put("object", getObjectAttribute());
-//        params.put("align", getAlignAttribute());
-//        params.put("alt", getAltAttribute());
+        params.put("name", getNameAttribute());
+
         params.put("height", getHeightAttribute());
-//        params.put("hspace", getHspaceAttribute());
-//        params.put("vspace", getVspaceAttribute());
         params.put("width", getWidthAttribute());
 
         final DomNodeList<HtmlElement> paramTags = getElementsByTagName("param");
@@ -370,6 +366,9 @@
         }
 
         String appletClassName = getAttribute("code");
+        if (StringUtils.isEmpty(appletClassName)) {
+            appletClassName = params.get("code");
+        }
         if (appletClassName.endsWith(".class")) {
             appletClassName = appletClassName.substring(0, appletClassName.length() - 6);
         }
@@ -388,7 +387,7 @@
 
         // check archive
         archiveUrls_ = new LinkedList<>();
-        final String[] archives = StringUtils.split(params.get(ARCHIVE), ',');
+        String[] archives = StringUtils.split(params.get(ARCHIVE), ',');
         if (null != archives) {
             for (int i = 0; i < archives.length; i++) {
                 final String tmpArchive = archives[i].trim();
@@ -399,6 +398,17 @@
                 archiveUrls_.add(archiveUrl);
             }
         }
+        archives = StringUtils.split(params.get(CACHE_ARCHIVE), ',');
+        if (null != archives) {
+            for (int i = 0; i < archives.length; i++) {
+                final String tmpArchive = archives[i].trim();
+                final String tempUrl = UrlUtils.resolveUrl(baseUrl, tmpArchive);
+                final URL archiveUrl = UrlUtils.toUrlUnsafe(tempUrl);
+
+                appletClassLoader_.addArchiveToClassPath(archiveUrl);
+                archiveUrls_.add(archiveUrl);
+            }
+        }
         archiveUrls_ = Collections.unmodifiableList(archiveUrls_);
 
         // no archive attribute, single class

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java 2017-03-18 13:10:18 UTC (rev 13818)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java 2017-03-18 13:35:04 UTC (rev 13819)
@@ -91,6 +91,23 @@
     }
 
     /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void cacheArchive() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/cacheArchiveApplet.html");
+
+        final HtmlPage page = getWebClient().getPage(url);
+        final HtmlObject objectNode = page.getHtmlElementById("myApp");
+
+        assertEquals("net.sourceforge.htmlunit.testapplets.EmptyApplet", objectNode.getApplet().getClass().getName());
+    }
+
+    /**
      * Tests the codebase and documentbase properties.
      * @throws Exception if the test fails
      */

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java 2017-03-18 13:10:18 UTC (rev 13818)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java 2017-03-18 13:35:04 UTC (rev 13819)
@@ -93,6 +93,23 @@
     }
 
     /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void cacheArchive() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/cacheArchiveApplet.html");
+
+        final HtmlPage page = getWebClient().getPage(url);
+        final HtmlObject objectNode = page.getHtmlElementById("myApp");
+
+        assertEquals("net.sourceforge.htmlunit.testapplets.EmptyApplet", objectNode.getApplet().getClass().getName());
+    }
+
+    /**
      * Tests the codebase and documentbase properties.
      * @throws Exception if the test fails
      */

Added: trunk/htmlunit/src/test/resources/applets/cacheArchiveApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/applets/cacheArchiveApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/applets/cacheArchiveApplet.html 2017-03-18 13:35:04 UTC (rev 13819)
@@ -0,0 +1,13 @@
+<html>
+<head>
+</head>
+<body>
+An applet that does absolutely nothing:
+ <object id='myApp'
+   type='application/x-java-applet'
+   code='net.sourceforge.htmlunit.testapplets.EmptyApplet'
+   width='200' height='300'>
+   <param name="cache_archive" VALUE="emptyApplet.jar">
+ Your browser does not support the applet tag.
+ </object>
+</body></html>


Property changes on: trunk/htmlunit/src/test/resources/applets/cacheArchiveApplet.html
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/htmlunit/src/test/resources/objects/cacheArchiveApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/cacheArchiveApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/cacheArchiveApplet.html 2017-03-18 13:35:04 UTC (rev 13819)
@@ -0,0 +1,13 @@
+<html>
+<head>
+</head>
+<body>
+An applet that does absolutely nothing:
+ <object id='myApp'
+   type='application/x-java-applet'
+   code='net.sourceforge.htmlunit.testapplets.EmptyApplet'
+   width='200' height='300'>
+   <param name="cache_archive" VALUE="emptyApplet.jar">
+ Your browser does not support the applet tag.
+ </object>
+</body></html>


Property changes on: trunk/htmlunit/src/test/resources/objects/cacheArchiveApplet.html
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...