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

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

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

rbri
Revision: 13817
          http://sourceforge.net/p/htmlunit/code/13817
Author:   rbri
Date:     2017-03-18 12:43:23 +0000 (Sat, 18 Mar 2017)
Log Message:
-----------
object tag now has some applet support

Modified Paths:
--------------
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/AppletConfirmHandler.java
    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/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/applets/AppletStubImpl.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLObjectElement.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java
    trunk/htmlunit/src/test/resources/applets/simpleAppletDoIt.html

Added Paths:
-----------
    trunk/htmlunit/src/test/resources/objects/
    trunk/htmlunit/src/test/resources/objects/codebaseApplet.html
    trunk/htmlunit/src/test/resources/objects/emptyApplet.html
    trunk/htmlunit/src/test/resources/objects/emptyApplet.jar
    trunk/htmlunit/src/test/resources/objects/ignoreUnknownArchiveApplet.html
    trunk/htmlunit/src/test/resources/objects/readme.txt
    trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.html
    trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar
    trunk/htmlunit/src/test/resources/objects/subdir/
    trunk/htmlunit/src/test/resources/objects/subdir/archiveRelativeApplet.html
    trunk/htmlunit/src/test/resources/objects/subdir/codebaseApplet.html
    trunk/htmlunit/src/test/resources/objects/subdir/codebaseParamApplet.html
    trunk/htmlunit/src/test/resources/objects/unknownArchiveApplet.html

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/changes/changes.xml 2017-03-18 12:43:23 UTC (rev 13817)
@@ -8,6 +8,9 @@
 
     <body>
         <release version="2.26" date="???" description="Bugfixes">
+            <action type="add" dev="rbri">
+                Object tag now has some applet support.
+            </action>
             <action type="fix" dev="asashour" system="htmlunitdriver" issue="46">
                 CSS: fix handling :target pseudo class.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/AppletConfirmHandler.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/AppletConfirmHandler.java 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/AppletConfirmHandler.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -15,6 +15,7 @@
 package com.gargoylesoftware.htmlunit;
 
 import com.gargoylesoftware.htmlunit.html.HtmlApplet;
+import com.gargoylesoftware.htmlunit.html.HtmlObject;
 
 /**
  * A handler for Applets. Like in real browsers, you have to confirm
@@ -30,4 +31,11 @@
      * @return true if starting is allowed
      */
     boolean confirm(HtmlApplet applet);
+
+    /**
+     * Handles a confirm for the specified page.
+     * @param applet the applet the browser likes to start
+     * @return true if starting is allowed
+     */
+    boolean confirm(HtmlObject applet);
 }

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 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlApplet.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -216,6 +216,10 @@
      */
     @SuppressWarnings("unchecked")
     private synchronized void setupAppletIfNeeded() throws IOException {
+        if (applet_ != null) {
+            return;
+        }
+
         final HashMap<String, String> params = new HashMap<>();
         params.put("name", getNameAttribute());
 
@@ -250,75 +254,72 @@
             return;
         }
 
-        if (null == applet_) {
+        String appletClassName = getCodeAttribute();
+        if (appletClassName.endsWith(".class")) {
+            appletClassName = appletClassName.substring(0, appletClassName.length() - 6);
+        }
 
-            String appletClassName = getCodeAttribute();
-            if (appletClassName.endsWith(".class")) {
-                appletClassName = appletClassName.substring(0, appletClassName.length() - 6);
-            }
+        appletClassLoader_ = new AppletClassLoader();
 
-            appletClassLoader_ = new AppletClassLoader();
+        final String documentUrl = page.getUrl().toExternalForm();
+        String baseUrl = UrlUtils.resolveUrl(documentUrl, ".");
+        if (StringUtils.isNotEmpty(codebaseProperty)) {
+            // codebase can be relative to the page
+            baseUrl = UrlUtils.resolveUrl(baseUrl, codebaseProperty);
+        }
+        if (!baseUrl.endsWith("/")) {
+            baseUrl = baseUrl + "/";
+        }
 
-            final String documentUrl = page.getUrl().toExternalForm();
-            String baseUrl = UrlUtils.resolveUrl(documentUrl, ".");
-            if (StringUtils.isNotEmpty(codebaseProperty)) {
-                // codebase can be relative to the page
-                baseUrl = UrlUtils.resolveUrl(baseUrl, codebaseProperty);
-            }
-            if (!baseUrl.endsWith("/")) {
-                baseUrl = baseUrl + "/";
-            }
+        // check archive
+        archiveUrls_ = new LinkedList<>();
+        final String[] archives = StringUtils.split(params.get(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);
 
-            // check archive
-            archiveUrls_ = new LinkedList<>();
-            final String[] archives = StringUtils.split(params.get(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);
-                }
+                appletClassLoader_.addArchiveToClassPath(archiveUrl);
+                archiveUrls_.add(archiveUrl);
             }
-            archiveUrls_ = Collections.unmodifiableList(archiveUrls_);
+        }
+        archiveUrls_ = Collections.unmodifiableList(archiveUrls_);
 
-            // no archive attribute, single class
-            if (null == archives || archives.length == 0) {
-                final String tempUrl = UrlUtils.resolveUrl(baseUrl, getCodeAttribute());
-                final URL classUrl = UrlUtils.toUrlUnsafe(tempUrl);
+        // no archive attribute, single class
+        if (null == archives || archives.length == 0) {
+            final String tempUrl = UrlUtils.resolveUrl(baseUrl, getCodeAttribute());
+            final URL classUrl = UrlUtils.toUrlUnsafe(tempUrl);
 
-                final WebResponse response = webclient.loadWebResponse(new WebRequest(classUrl));
-                try {
-                    webclient.throwFailingHttpStatusCodeExceptionIfNecessary(response);
-                    appletClassLoader_.addClassToClassPath(appletClassName, response);
-                }
-                catch (final FailingHttpStatusCodeException e) {
-                    // that is what the browser does, the applet only fails, if
-                    // the main class is not loadable
-                    LOG.error(e.getMessage(), e);
-                }
-            }
-
+            final WebResponse response = webclient.loadWebResponse(new WebRequest(classUrl));
             try {
-                final Class<Applet> appletClass = (Class<Applet>) appletClassLoader_.loadClass(appletClassName);
-                applet_ = appletClass.newInstance();
-                applet_.setStub(new AppletStubImpl(this, params,
-                        UrlUtils.toUrlUnsafe(baseUrl), UrlUtils.toUrlUnsafe(documentUrl)));
-                applet_.init();
-                applet_.start();
+                webclient.throwFailingHttpStatusCodeExceptionIfNecessary(response);
+                appletClassLoader_.addClassToClassPath(appletClassName, response);
             }
-            catch (final ClassNotFoundException e) {
-                throw new RuntimeException(e);
+            catch (final FailingHttpStatusCodeException e) {
+                // that is what the browser does, the applet only fails, if
+                // the main class is not loadable
+                LOG.error(e.getMessage(), e);
             }
-            catch (final InstantiationException e) {
-                throw new RuntimeException(e);
-            }
-            catch (final IllegalAccessException e) {
-                throw new RuntimeException(e);
-            }
         }
+
+        try {
+            final Class<Applet> appletClass = (Class<Applet>) appletClassLoader_.loadClass(appletClassName);
+            applet_ = appletClass.newInstance();
+            applet_.setStub(new AppletStubImpl(getHtmlPageOrNull(), params,
+                    UrlUtils.toUrlUnsafe(baseUrl), UrlUtils.toUrlUnsafe(documentUrl)));
+            applet_.init();
+            applet_.start();
+        }
+        catch (final ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+        catch (final InstantiationException e) {
+            throw new RuntimeException(e);
+        }
+        catch (final IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     /**

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 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlObject.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -14,13 +14,29 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
+import java.applet.Applet;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import com.gargoylesoftware.htmlunit.AppletConfirmHandler;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
 import com.gargoylesoftware.htmlunit.SgmlPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebRequest;
+import com.gargoylesoftware.htmlunit.WebResponse;
+import com.gargoylesoftware.htmlunit.html.applets.AppletClassLoader;
+import com.gargoylesoftware.htmlunit.html.applets.AppletStubImpl;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLObjectElement;
+import com.gargoylesoftware.htmlunit.util.UrlUtils;
 import com.gargoylesoftware.htmlunit.xml.XmlPage;
 
 /**
@@ -37,9 +53,17 @@
 
     private static final Log LOG = LogFactory.getLog(HtmlObject.class);
 
+    private static final String APPLET_TYPE = "application/x-java-applet";
+    private static final String ARCHIVE = "archive";
+    private static final String CODEBASE = "codebase";
+
     /** The HTML tag represented by this element. */
     public static final String TAG_NAME = "object";
 
+    private Applet applet_;
+    private AppletClassLoader appletClassLoader_;
+    private List<URL> archiveUrls_;
+
     /**
      * Creates an instance of HtmlObject
      *
@@ -283,4 +307,133 @@
     public DisplayStyle getDefaultStyleDisplay() {
         return DisplayStyle.INLINE;
     }
+
+    /**
+     * Gets the applet referenced by this tag. Instantiates it if necessary.
+     *
+     * @return the applet or null, if the installed AppletConfirmHandler
+     * prohibits this applet
+     * @throws IOException in case of problem
+     */
+    public Applet getApplet() throws IOException {
+        setupAppletIfNeeded();
+        return applet_;
+    }
+
+    /**
+     * Download the associated content specified in the code attribute.
+     *
+     * @throws IOException if an error occurs while downloading the content
+     */
+    @SuppressWarnings("unchecked")
+    private synchronized void setupAppletIfNeeded() throws IOException {
+        if (applet_ != null) {
+            return;
+        }
+
+        if (StringUtils.isBlank(getTypeAttribute()) || !getTypeAttribute().startsWith(APPLET_TYPE)) {
+            return;
+        }
+
+        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("height", getHeightAttribute());
+//        params.put("hspace", getHspaceAttribute());
+//        params.put("vspace", getVspaceAttribute());
+        params.put("width", getWidthAttribute());
+
+        final DomNodeList<HtmlElement> paramTags = getElementsByTagName("param");
+        for (final HtmlElement paramTag : paramTags) {
+            final HtmlParameter parameter = (HtmlParameter) paramTag;
+            params.put(parameter.getNameAttribute(), parameter.getValueAttribute());
+        }
+
+        if (StringUtils.isEmpty(params.get(CODEBASE)) && StringUtils.isNotEmpty(getCodebaseAttribute())) {
+            params.put(CODEBASE, getCodebaseAttribute());
+        }
+        final String codebaseProperty = params.get(CODEBASE);
+
+        if (StringUtils.isEmpty(params.get(ARCHIVE)) && StringUtils.isNotEmpty(getArchiveAttribute())) {
+            params.put(ARCHIVE, getArchiveAttribute());
+        }
+
+        final HtmlPage page = (HtmlPage) getPage();
+        final WebClient webclient = page.getWebClient();
+
+        final AppletConfirmHandler handler = webclient.getAppletConfirmHandler();
+        if (null != handler && !handler.confirm(this)) {
+            return;
+        }
+
+        String appletClassName = getAttribute("code");
+        if (appletClassName.endsWith(".class")) {
+            appletClassName = appletClassName.substring(0, appletClassName.length() - 6);
+        }
+
+        appletClassLoader_ = new AppletClassLoader();
+
+        final String documentUrl = page.getUrl().toExternalForm();
+        String baseUrl = UrlUtils.resolveUrl(documentUrl, ".");
+        if (StringUtils.isNotEmpty(codebaseProperty)) {
+            // codebase can be relative to the page
+            baseUrl = UrlUtils.resolveUrl(baseUrl, codebaseProperty);
+        }
+        if (!baseUrl.endsWith("/")) {
+            baseUrl = baseUrl + "/";
+        }
+
+        // check archive
+        archiveUrls_ = new LinkedList<>();
+        final String[] archives = StringUtils.split(params.get(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
+        if (null == archives || archives.length == 0) {
+            final String tempUrl = UrlUtils.resolveUrl(baseUrl, getAttribute("code"));
+            final URL classUrl = UrlUtils.toUrlUnsafe(tempUrl);
+
+            final WebResponse response = webclient.loadWebResponse(new WebRequest(classUrl));
+            try {
+                webclient.throwFailingHttpStatusCodeExceptionIfNecessary(response);
+                appletClassLoader_.addClassToClassPath(appletClassName, response);
+            }
+            catch (final FailingHttpStatusCodeException e) {
+                // that is what the browser does, the applet only fails, if
+                // the main class is not loadable
+                LOG.error(e.getMessage(), e);
+            }
+        }
+
+        try {
+            final Class<Applet> appletClass = (Class<Applet>) appletClassLoader_.loadClass(appletClassName);
+            applet_ = appletClass.newInstance();
+            applet_.setStub(new AppletStubImpl(getHtmlPageOrNull(), params,
+                    UrlUtils.toUrlUnsafe(baseUrl), UrlUtils.toUrlUnsafe(documentUrl)));
+            applet_.init();
+            applet_.start();
+        }
+        catch (final ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+        catch (final InstantiationException e) {
+            throw new RuntimeException(e);
+        }
+        catch (final IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -1738,9 +1738,11 @@
         // first try real attributes
         String value = element.getAttribute(attribute);
 
-        if (DomElement.ATTRIBUTE_NOT_DEFINED == value && !(element instanceof HtmlApplet)) {
+        if (DomElement.ATTRIBUTE_NOT_DEFINED == value
+                && !(element instanceof HtmlApplet)
+                && !(element instanceof HtmlObject)) {
             // second try are JavaScript attributes
-            // ...but applets are a bit special so ignore them
+            // ...but applets/objects are a bit special so ignore them
             final ScriptableObject scriptObject = element.getScriptableObject();
             // we have to make sure the scriptObject has a slot for the given attribute.
             // just using get() may use e.g. getWithPreemption().

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/applets/AppletStubImpl.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/applets/AppletStubImpl.java 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/applets/AppletStubImpl.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -19,7 +19,6 @@
 import java.net.URL;
 import java.util.HashMap;
 
-import com.gargoylesoftware.htmlunit.html.HtmlApplet;
 import com.gargoylesoftware.htmlunit.html.HtmlPage;
 
 /**
@@ -37,14 +36,14 @@
 
     /**
      * Constructs a stub for an applet node.
-     * @param htmlApplet the applet node
+     * @param htmlPage the containing page
      * @param parameters app parameters of the applet
      * @param codebase codebase of the applet
      * @param documentbase documentbase of the applet
      */
-    public AppletStubImpl(final HtmlApplet htmlApplet,
+    public AppletStubImpl(final HtmlPage htmlPage,
             final HashMap<String, String> parameters, final URL codebase, final URL documentbase) {
-        appletContextImpl_ = new AppletContextImpl((HtmlPage) htmlApplet.getPage());
+        appletContextImpl_ = new AppletContextImpl(htmlPage);
         parameters_ = parameters;
         codebase_ = codebase;
         documentbase_ = documentbase;

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLObjectElement.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLObjectElement.java 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLObjectElement.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -20,9 +20,12 @@
 import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE;
 
+import java.applet.Applet;
+import java.lang.reflect.Method;
 import java.util.Map;
 
 import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.DomNode;
 import com.gargoylesoftware.htmlunit.html.HtmlForm;
 import com.gargoylesoftware.htmlunit.html.HtmlObject;
 import com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory;
@@ -33,9 +36,12 @@
 import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser;
 import com.gargoylesoftware.htmlunit.javascript.host.ActiveXObjectImpl;
 
+import net.sourceforge.htmlunit.corejs.javascript.BaseFunction;
 import net.sourceforge.htmlunit.corejs.javascript.Context;
+import net.sourceforge.htmlunit.corejs.javascript.Function;
 import net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject;
 import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
+import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
 import net.sourceforge.htmlunit.corejs.javascript.Wrapper;
 
 /**
@@ -58,6 +64,60 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDomNode(final DomNode domNode) {
+        super.setDomNode(domNode);
+
+        if (domNode.getPage().getWebClient().getOptions().isAppletEnabled()) {
+            try {
+                createAppletMethodAndProperties();
+            }
+            catch (final Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    private void createAppletMethodAndProperties() throws Exception {
+        final HtmlObject appletNode = (HtmlObject) getDomNodeOrDie();
+        final Applet applet = appletNode.getApplet();
+        if (applet == null) {
+            return;
+        }
+
+        // Rhino should provide the possibility to declare delegate for Functions as it does for properties!!!
+        for (final Method method : applet.getClass().getMethods()) {
+            final Function f = new BaseFunction() {
+                @Override
+                public Object call(final Context cx, final Scriptable scope,
+                        final Scriptable thisObj, final Object[] args) {
+
+                    final Object[] realArgs = new Object[method.getParameterTypes().length];
+                    for (int i = 0; i < realArgs.length; i++) {
+                        final Object arg;
+                        if (i > args.length) {
+                            arg = null;
+                        }
+                        else {
+                            arg = Context.jsToJava(args[i], method.getParameterTypes()[i]);
+                        }
+                        realArgs[i] = arg;
+                    }
+                    try {
+                        return method.invoke(applet, realArgs);
+                    }
+                    catch (final Exception e) {
+                        throw Context.throwAsScriptRuntimeEx(e);
+                    }
+                }
+            };
+            ScriptableObject.defineProperty(this, method.getName(), f, ScriptableObject.READONLY);
+        }
+    }
+
+    /**
      * Returns the value of the {@code alt} property.
      * @return the value of the {@code alt} property
      */

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 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAppletTest.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -46,7 +46,7 @@
     public void asText_appletDisabled() throws Exception {
         final String html = "<html><head>\n"
             + "</head><body>\n"
-            + "  <applet id='myId'>Your browser doesn't support applets</object>\n"
+            + "  <applet id='myId'>Your browser doesn't support applets</applet>\n"
             + "</body></html>";
 
         final HtmlPage page = loadPageWithAlerts(html);
@@ -62,7 +62,7 @@
     public void asText_appletEnabled() throws Exception {
         final String html = "<html><head>\n"
             + "</head><body>\n"
-            + "  <applet id='myId'>Your browser doesn't support applets</object>\n"
+            + "  <applet id='myId'>Your browser doesn't support applets</applet>\n"
             + "</body></html>";
 
         final WebClient client = getWebClientWithMockWebConnection();
@@ -424,6 +424,11 @@
                 assertEquals("simpleAppletDoIt.jar", applet.getArchiveAttribute());
                 return true;
             }
+
+            @Override
+            public boolean confirm(final HtmlObject applet) {
+                return false;
+            }
         });
 
         final HtmlPage page = webClient.getPage(url);
@@ -462,6 +467,11 @@
                 assertEquals("simpleAppletDoIt.jar", applet.getArchiveAttribute());
                 return false;
             }
+
+            @Override
+            public boolean confirm(final HtmlObject applet) {
+                return false;
+            }
         });
 
         final HtmlPage page = webClient.getPage(url);

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 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlObjectTest.java 2017-03-18 12:43:23 UTC (rev 13817)
@@ -14,6 +14,7 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -20,11 +21,14 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.gargoylesoftware.htmlunit.AppletConfirmHandler;
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
 import com.gargoylesoftware.htmlunit.CollectingAlertHandler;
 import com.gargoylesoftware.htmlunit.MockWebConnection;
+import com.gargoylesoftware.htmlunit.Page;
 import com.gargoylesoftware.htmlunit.SimpleWebTestCase;
+import com.gargoylesoftware.htmlunit.StatusHandler;
 import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.javascript.host.ActiveXObjectTest;
 
@@ -32,6 +36,7 @@
  * Tests for {@link HtmlObject}.
  *
  * @author Ahmed Ashour
+ * @author Ronald Brill
  */
 @RunWith(BrowserRunner.class)
 public class HtmlObjectTest extends SimpleWebTestCase {
@@ -69,4 +74,413 @@
         client.getPage(getDefaultUrl());
         assertEquals(getExpectedAlerts(), collectedAlerts);
     }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void simpleInstantiation() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/emptyApplet.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
+     */
+    @Test
+    public void checkAppletBaseWithoutCodebase() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/simpleAppletDoIt.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
+        button.click();
+        button = page.getHtmlElementById("buttonShowDocumentBase");
+        button.click();
+
+        assertEquals(2, collectedStatus.size());
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/'"));
+
+        assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
+        assertTrue(collectedStatus.get(1),
+                collectedStatus.get(1).endsWith("target/test-classes/objects/simpleAppletDoIt.html'"));
+    }
+
+    /**
+     * Tests the codebase and documentbase properties.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkAppletBase() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/codebaseApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
+        button.click();
+        button = page.getHtmlElementById("buttonShowDocumentBase");
+        button.click();
+
+        assertEquals(2, collectedStatus.size());
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/'"));
+
+        assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
+        assertTrue(collectedStatus.get(1),
+                collectedStatus.get(1).endsWith("target/test-classes/objects/codebaseApplet.html'"));
+    }
+
+    /**
+     * Tests the codebase and documentbase properties.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkSubdirAppletBase() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/subdir/codebaseApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
+        button.click();
+        button = page.getHtmlElementById("buttonShowDocumentBase");
+        button.click();
+
+        assertEquals(2, collectedStatus.size());
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/'"));
+
+        assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
+        assertTrue(collectedStatus.get(1),
+                collectedStatus.get(1).endsWith("target/test-classes/objects/subdir/codebaseApplet.html'"));
+    }
+
+    /**
+     * Tests the codebase and documentbase properties.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkSubdirRelativeAppletBase() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/subdir/archiveRelativeApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
+        button.click();
+        button = page.getHtmlElementById("buttonShowDocumentBase");
+        button.click();
+
+        assertEquals(2, collectedStatus.size());
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
+        assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/subdir/'"));
+
+        assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
+        assertTrue(collectedStatus.get(1),
+                collectedStatus.get(1).endsWith("target/test-classes/objects/subdir/archiveRelativeApplet.html'"));
+    }
+
+    /**
+     * Tests the handling of parameters.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkAppletParams() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/simpleAppletDoIt.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonParam1");
+        button.click();
+        button = page.getHtmlElementById("buttonParam2");
+        button.click();
+        button = page.getHtmlElementById("buttonParamCodebase");
+        button.click();
+        button = page.getHtmlElementById("buttonParamArchive");
+        button.click();
+
+        assertEquals(4, collectedStatus.size());
+        assertEquals("param1: 'value1'", collectedStatus.get(0));
+        assertEquals("param2: 'value2'", collectedStatus.get(1));
+        assertEquals("codebase: 'null'", collectedStatus.get(2));
+        assertEquals("archive: 'simpleAppletDoIt.jar'", collectedStatus.get(3));
+    }
+
+    /**
+     * Tests the handling of parameters.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkAppletOverwriteArchive() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/subdir/codebaseParamApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+
+        HtmlButton button = page.getHtmlElementById("buttonParam1");
+        button.click();
+        button = page.getHtmlElementById("buttonParam2");
+        button.click();
+        button = page.getHtmlElementById("buttonParamCodebase");
+        button.click();
+        button = page.getHtmlElementById("buttonParamArchive");
+        button.click();
+
+        assertEquals(4, collectedStatus.size());
+        assertEquals("param1: 'value1'", collectedStatus.get(0));
+        assertEquals("param2: 'value2'", collectedStatus.get(1));
+        assertEquals("codebase: '..'", collectedStatus.get(2));
+        assertEquals("archive: 'simpleAppletDoIt.jar'", collectedStatus.get(3));
+    }
+
+    /**
+     * Tests the processing of an applet definition with wrong archive.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkAppletUnknownArchive() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/unknownArchiveApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+        final DomNodeList<DomElement> objects = page.getElementsByTagName("object");
+        assertEquals(1, objects.size());
+
+        final HtmlObject htmlObject = (HtmlObject) objects.get(0);
+        try {
+            htmlObject.getApplet();
+        }
+        catch (final Exception e) {
+            assertEquals("java.lang.ClassNotFoundException: net.sourceforge.htmlunit.testapplets.EmptyApplet",
+                e.getMessage());
+        }
+    }
+
+    /**
+     * Tests the processing of an applet definition with one valid and one wrong archive.
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void checkAppletIgnoreUnknownArchive() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/ignoreUnknownArchiveApplet.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        final HtmlPage page = webClient.getPage(url);
+        final DomNodeList<DomElement> objects = page.getElementsByTagName("object");
+        assertEquals(1, objects.size());
+
+        final HtmlObject htmlObject = (HtmlObject) objects.get(0);
+        htmlObject.getApplet();
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void appletConfirmHandler() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/simpleAppletDoIt.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        webClient.setAppletConfirmHandler(new AppletConfirmHandler() {
+            @Override
+            public boolean confirm(final HtmlApplet applet) {
+                return false;
+            }
+
+            @Override
+            public boolean confirm(final HtmlObject applet) {
+                assertEquals("simpleAppletDoIt.jar", applet.getArchiveAttribute());
+                return true;
+            }
+        });
+
+        final HtmlPage page = webClient.getPage(url);
+        final DomNodeList<DomElement> objects = page.getElementsByTagName("object");
+        assertEquals(1, objects.size());
+
+        final HtmlObject htmlObject = (HtmlObject) objects.get(0);
+        assertTrue(htmlObject.getApplet() != null);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void appletConfirmHandlerPermit() throws Exception {
+        if (getBrowserVersion().isChrome()) {
+            return;
+        }
+
+        final URL url = getClass().getResource("/objects/simpleAppletDoIt.html");
+
+        final WebClient webClient = getWebClient();
+        final List<String> collectedStatus = new ArrayList<>();
+        final StatusHandler statusHandler = new StatusHandler() {
+            @Override
+            public void statusMessageChanged(final Page page, final String message) {
+                collectedStatus.add(message);
+            }
+        };
+        webClient.setStatusHandler(statusHandler);
+        webClient.getOptions().setAppletEnabled(true);
+
+        webClient.setAppletConfirmHandler(new AppletConfirmHandler() {
+            @Override
+            public boolean confirm(final HtmlApplet applet) {
+                return true;
+            }
+
+            @Override
+            public boolean confirm(final HtmlObject applet) {
+                assertEquals("simpleAppletDoIt.jar", applet.getArchiveAttribute());
+                return false;
+            }
+        });
+
+        final HtmlPage page = webClient.getPage(url);
+        final DomNodeList<DomElement> objects = page.getElementsByTagName("object");
+        assertEquals(1, objects.size());
+
+        final HtmlObject htmlObject = (HtmlObject) objects.get(0);
+        assertTrue(htmlObject.getApplet() == null);
+    }
 }

Modified: trunk/htmlunit/src/test/resources/applets/simpleAppletDoIt.html
===================================================================
--- trunk/htmlunit/src/test/resources/applets/simpleAppletDoIt.html 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/test/resources/applets/simpleAppletDoIt.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -11,7 +11,7 @@
    <param name='param1' value='value1'>
    <param name='param2' value='value2'>
  Your browser does not support the applet tag.
-</applet>
+ </applet>
 
 <button onclick="document.applets[0].doIt('hello')" id="button1">call applet's doIt('hello')</button>
 <button onclick="document.applets[0].doIt(12345)" id="button2">call applet's doIt(12345)</button>

Added: trunk/htmlunit/src/test/resources/objects/codebaseApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/codebaseApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/codebaseApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,22 @@
+<html>
+<head>
+<title>simple applet test</title>
+</head>
+<body>
+A simple applet (without display) with a method called doIt(String message) that shows "Called: doIt(#message#)" in the status bar of the window.
+ <object id='myApplet'
+   type='application/x-java-applet;version=1.4.1'
+   codebase='.'
+   archive='simpleAppletDoIt.jar'
+   code='net.sourceforge.htmlunit.testapplets.AppletDoIt'
+   width='50' height='50'>
+ Your browser does not support the applet tag.
+</object>
+
+<button onclick="document.getElementById('myApplet').doIt('hello')" id="button1">call applet's doIt('hello')</button>
+<button onclick="document.getElementById('myApplet').doIt(12345)" id="button2">call applet's doIt(12345)</button>
+
+<button onclick="document.getElementById('myApplet').showCodeBase()" id="buttonShowCodeBase">ShowCodeBase</button>
+<button onclick="document.getElementById('myApplet').showDocumentBase()" id="buttonShowDocumentBase">ShowDocumentBase</button>
+
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/emptyApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/emptyApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/emptyApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,15 @@
+<html>
+<head>
+</head>
+<body>
+An applet that does absolutely nothing:
+ <object id='myApp'
+   type='application/x-java-applet;version=1.4.1'
+   archive='emptyApplet.jar'
+   code='net.sourceforge.htmlunit.testapplets.EmptyApplet'
+   width='200' height='300'>
+     <param value="emptyApplet.jar" name="cache_archive">
+     <param value="net.sourceforge.htmlunit.testapplets.EmptyApplet" name="code">
+  Your browser does not support the applets.
+ </object>
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/emptyApplet.jar
===================================================================
(Binary files differ)

Index: trunk/htmlunit/src/test/resources/objects/emptyApplet.jar
===================================================================
--- trunk/htmlunit/src/test/resources/objects/emptyApplet.jar 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/test/resources/objects/emptyApplet.jar 2017-03-18 12:43:23 UTC (rev 13817)

Property changes on: trunk/htmlunit/src/test/resources/objects/emptyApplet.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/htmlunit/src/test/resources/objects/ignoreUnknownArchiveApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/ignoreUnknownArchiveApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/ignoreUnknownArchiveApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,13 @@
+<html>
+<head>
+</head>
+<body>
+An applet that does absolutely nothing:
+ <object id='myApp'
+   type='application/x-java-applet'
+   archive='unknown.jar, emptyApplet.jar'
+   code='net.sourceforge.htmlunit.testapplets.EmptyApplet'
+   width='200' height='300'>
+ Your browser does not support the applet tag.
+ </object>
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/readme.txt
===================================================================
--- trunk/htmlunit/src/test/resources/objects/readme.txt                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/readme.txt 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,6 @@
+The jar files of the applets contained in this folder are generated using
+mvn compile jar:jar
+in the testApplets module (same level than htmlunit and core-js in SVN repository) and then copied here.
+
+Applets' sources can't be in the same source tree than HtmlUnit's tests or main classes otherwise
+the classes would already be available in the classpath during test execution.
\ No newline at end of file

Added: trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>simple applet test</title>
+</head>
+<body>
+A simple applet (without display) with a method called doIt(String message) that shows "Called: doIt(#message#)" in the status bar of the window.
+ <object id='myApplet'
+   type='application/x-java-applet;version=1.4.1'
+   archive='simpleAppletDoIt.jar'
+   code='net.sourceforge.htmlunit.testapplets.AppletDoIt'
+   width='50' height='50'>
+   <param name='param1' value='value1'>
+   <param name='param2' value='value2'>
+ Your browser does not support the applet tag.
+ </object>
+
+<button onclick="document.getElementById('myApplet').doIt('hello')" id="button1">call applet's doIt('hello')</button>
+<button onclick="document.getElementById('myApplet').doIt(12345)" id="button2">call applet's doIt(12345)</button>
+
+<button onclick="document.getElementById('myApplet').showCodeBase()" id="buttonShowCodeBase">ShowCodeBase</button>
+<button onclick="document.getElementById('myApplet').showDocumentBase()" id="buttonShowDocumentBase">ShowDocumentBase</button>
+
+<button onclick="document.getElementById('myApplet').showParam('param1')" id="buttonParam1">ShowParam1</button>
+<button onclick="document.getElementById('myApplet').showParam('param2')" id="buttonParam2">ShowParam2</button>
+<button onclick="document.getElementById('myApplet').showParam('codebase')" id="buttonParamCodebase">ShowParamCodebase</button>
+<button onclick="document.getElementById('myApplet').showParam('archive')" id="buttonParamArchive">ShowParamArchive</button>
+
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar
===================================================================
(Binary files differ)

Index: trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar
===================================================================
--- trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar 2017-03-18 10:46:05 UTC (rev 13816)
+++ trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar 2017-03-18 12:43:23 UTC (rev 13817)

Property changes on: trunk/htmlunit/src/test/resources/objects/simpleAppletDoIt.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/htmlunit/src/test/resources/objects/subdir/archiveRelativeApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/subdir/archiveRelativeApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/subdir/archiveRelativeApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<title>simple applet test</title>
+</head>
+<body>
+A simple applet (without display) with a method called doIt(String message) that shows "Called: doIt(#message#)" in the status bar of the window.
+ <object id='myApplet'
+   type='application/x-java-applet'
+   archive='../simpleAppletDoIt.jar'
+   code='net.sourceforge.htmlunit.testapplets.AppletDoIt'
+   width='50' height='50'>
+ Your browser does not support the applet tag.
+ </object>
+
+<button onclick="document.getElementById('myApplet').doIt('hello')" id="button1">call applet's doIt('hello')</button>
+<button onclick="document.getElementById('myApplet').doIt(12345)" id="button2">call applet's doIt(12345)</button>
+
+<button onclick="document.getElementById('myApplet').showCodeBase()" id="buttonShowCodeBase">ShowCodeBase</button>
+<button onclick="document.getElementById('myApplet').showDocumentBase()" id="buttonShowDocumentBase">ShowDocumentBase</button>
+
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/subdir/codebaseApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/subdir/codebaseApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/subdir/codebaseApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,22 @@
+<html>
+<head>
+<title>simple applet test</title>
+</head>
+<body>
+A simple applet (without display) with a method called doIt(String message) that shows "Called: doIt(#message#)" in the status bar of the window.
+ <object id='myApplet'
+   type='application/x-java-applet'
+   codebase='..'
+   archive='simpleAppletDoIt.jar'
+   code='net.sourceforge.htmlunit.testapplets.AppletDoIt'
+   width='50' height='50'>
+ Your browser does not support the applet tag.
+ </object>
+
+<button onclick="document.getElementById('myApplet').doIt('hello')" id="button1">call applet's doIt('hello')</button>
+<button onclick="document.getElementById('myApplet').doIt(12345)" id="button2">call applet's doIt(12345)</button>
+
+<button onclick="document.getElementById('myApplet').showCodeBase()" id="buttonShowCodeBase">ShowCodeBase</button>
+<button onclick="document.getElementById('myApplet').showDocumentBase()" id="buttonShowDocumentBase">ShowDocumentBase</button>
+
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/subdir/codebaseParamApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/subdir/codebaseParamApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/subdir/codebaseParamApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,33 @@
+<html>
+<head>
+<title>simple applet test</title>
+</head>
+<body>
+A simple applet (without display) with a method called doIt(String message) that shows "Called: doIt(#message#)" in the status bar of the window.
+ <object id='myApplet'
+   type='application/x-java-applet'
+   codebase='.'
+   archive='somewhere.jar'
+   code='net.sourceforge.htmlunit.testapplets.AppletDoIt'
+   width='50' height='50'>
+
+   <param name='archive' value='simpleAppletDoIt.jar'>
+   <param name='codebase' value='..'>
+
+   <param name='param1' value='value1'>
+   <param name='param2' value='value2'>
+ Your browser does not support the applet tag.
+ </object>
+
+<button onclick="document.getElementById('myApplet').doIt('hello')" id="button1">call applet's doIt('hello')</button>
+<button onclick="document.getElementById('myApplet').doIt(12345)" id="button2">call applet's doIt(12345)</button>
+
+<button onclick="document.getElementById('myApplet').showCodeBase()" id="buttonShowCodeBase">ShowCodeBase</button>
+<button onclick="document.getElementById('myApplet').showDocumentBase()" id="buttonShowDocumentBase">ShowDocumentBase</button>
+
+<button onclick="document.getElementById('myApplet').showParam('param1')" id="buttonParam1">ShowParam1</button>
+<button onclick="document.getElementById('myApplet').showParam('param2')" id="buttonParam2">ShowParam2</button>
+<button onclick="document.getElementById('myApplet').showParam('codebase')" id="buttonParamCodebase">ShowParamCodebase</button>
+<button onclick="document.getElementById('myApplet').showParam('archive')" id="buttonParamArchive">ShowParamArchive</button>
+
+</body></html>

Added: trunk/htmlunit/src/test/resources/objects/unknownArchiveApplet.html
===================================================================
--- trunk/htmlunit/src/test/resources/objects/unknownArchiveApplet.html                        (rev 0)
+++ trunk/htmlunit/src/test/resources/objects/unknownArchiveApplet.html 2017-03-18 12:43:23 UTC (rev 13817)
@@ -0,0 +1,13 @@
+<html>
+<head>
+</head>
+<body>
+An applet that does absolutely nothing:
+ <object id='myApp'
+   type='application/x-java-applet'
+   archive='unknown.jar'
+   code='net.sourceforge.htmlunit.testapplets.EmptyApplet'
+   width='200' height='300'>
+ Your browser does not support the applet tag.
+ </object>
+</body></html>


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