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

rbri--- via HtmlUnit-develop <[email protected]>
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID <[email protected]>
Revision: 15392
          http://sourceforge.net/p/htmlunit/code/15392
Author:   rbri
Date:     2018-06-27 18:35:57 +0000 (Wed, 27 Jun 2018)
Log Message:
-----------
ff60 support (wip)

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2018-06-27 18:04:10 UTC (rev 15391)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2018-06-27 18:35:57 UTC (rev 15392)
@@ -345,6 +345,10 @@
     @BrowserFeature(FF)
     HTMLDEFINITION_INLINE_IN_QUIRKS,
 
+    /** {@code document.applets} returns a NodeList. */
+    @BrowserFeature(FF60)
+    HTMLDOCUMENT_APPLETS_NODELIST,
+
     /** Is {@code document.charset} lower-case. */
     @BrowserFeature(IE)
     HTMLDOCUMENT_CHARSET_LOWERCASE,
@@ -366,6 +370,12 @@
     HTMLDOCUMENT_GET_FOR_ID_AND_OR_NAME,
 
     /**
+    /** {@code document.getElementsByName} returns an empty list if called with the empty string.
+     */
+    @BrowserFeature(FF60)
+    HTMLDOCUMENT_ELEMENTS_BY_NAME_EMPTY,
+
+    /**
      * Calls to <code>document.XYZ</code> should first look at standard functions before looking at elements
      * named <code>XYZ</code>.
      */

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java	2018-06-27 18:04:10 UTC (rev 15391)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java	2018-06-27 18:35:57 UTC (rev 15392)
@@ -20,6 +20,7 @@
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_KEY_EVENTS;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_POINTEREVENT;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_PROGRESSEVENT;
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_APPLETS_NODELIST;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_CHARSET_LOWERCASE;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHORS_REQUIRES_NAME_OR_ID;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_CREATE_ELEMENT_STRICT;
@@ -34,8 +35,8 @@
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
+import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF60;
-import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE;
 import static com.gargoylesoftware.htmlunit.util.StringUtils.parseHttpDate;
 
@@ -880,6 +881,14 @@
      */
     @JsxGetter({CHROME, IE})
     public Object getApplets() {
+        if (getBrowserVersion().hasFeature(HTMLDOCUMENT_APPLETS_NODELIST)) {
+            return new NodeList(getDomNodeOrDie(), false) {
+                @Override
+                protected boolean isMatching(final DomNode node) {
+                    return node instanceof HtmlApplet;
+                }
+            };
+        }
         return new HTMLCollection(getDomNodeOrDie(), false) {
             @Override
             protected boolean isMatching(final DomNode node) {

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java	2018-06-27 18:04:10 UTC (rev 15391)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java	2018-06-27 18:35:57 UTC (rev 15392)
@@ -15,6 +15,7 @@
 package com.gargoylesoftware.htmlunit.javascript.host.html;
 
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_COLOR;
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_ELEMENTS_BY_NAME_EMPTY;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_FUNCTION_DETACHED;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_GET_ALSO_FRAMES;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_GET_FOR_ID_AND_OR_NAME;
@@ -726,17 +727,17 @@
     @JsxFunction(FF)
     public HTMLCollection getElementsByName(final String elementName) {
         implicitCloseIfNecessary();
-        if ("null".equals(elementName)) {
+        if ("null".equals(elementName)
+                || (elementName.isEmpty()
+                    && getBrowserVersion().hasFeature(HTMLDOCUMENT_ELEMENTS_BY_NAME_EMPTY))) {
             return HTMLCollection.emptyCollection(getWindow().getDomNodeOrDie());
         }
-        // Null must me changed to '' for proper collection initialization.
-        final String expElementName = "null".equals(elementName) ? "" : elementName;
 
         final HtmlPage page = getPage();
         return new HTMLCollection(page, true) {
             @Override
             protected List<DomNode> computeElements() {
-                return new ArrayList<>(page.getElementsByName(expElementName));
+                return new ArrayList<>(page.getElementsByName(elementName));
             }
 
             @Override

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java	2018-06-27 18:04:10 UTC (rev 15391)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java	2018-06-27 18:35:57 UTC (rev 15392)
@@ -28,6 +28,7 @@
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
+import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF60;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE;
 
 import java.io.File;
@@ -806,7 +807,7 @@
      * Returns the labels associated with the element.
      * @return the labels associated with the element
      */
-    @JsxGetter(CHROME)
+    @JsxGetter({CHROME, FF60})
     public AbstractList getLabels() {
         if (labels_ == null) {
             labels_ = new LabelsHelper(getDomNodeOrDie());

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java	2018-06-27 18:04:10 UTC (rev 15391)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java	2018-06-27 18:35:57 UTC (rev 15392)
@@ -868,13 +868,14 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"2", "0"},
-            FF60 = {"0", "0"})
+    @Alerts(DEFAULT = {"2", "0", "0"},
+            FF60 = {"0", "0", "0"})
     public void getElementsByName_emptyName() throws Exception {
         final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
             + "<html><head><title>foo</title><script>\n"
             + "  function test() {\n"
             + "    alert(document.getElementsByName('').length);\n"
+            + "    alert(document.getElementsByName(' ').length);\n"
             + "    alert(document.getElementsByName(null).length);\n"
             + "  }\n"
             + "</script></head><body onload='test()'>\n"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.