From: <rb...@us...> - 2018-06-27 18:56:49
|
Revision: 15393 http://sourceforge.net/p/htmlunit/code/15393 Author: rbri Date: 2018-06-27 18:56:45 +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/html/HTMLAnchorElement.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:35:57 UTC (rev 15392) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-06-27 18:56:45 UTC (rev 15393) @@ -357,6 +357,12 @@ @BrowserFeature(IE) HTMLDOCUMENT_COLOR, + /** + /** {@code document.getElementsByName} returns an empty list if called with the empty string. + */ + @BrowserFeature(FF60) + HTMLDOCUMENT_ELEMENTS_BY_NAME_EMPTY, + /** We can used function in detached documents. */ @BrowserFeature(IE) HTMLDOCUMENT_FUNCTION_DETACHED, @@ -370,12 +376,6 @@ 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>. */ @@ -554,7 +554,7 @@ JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL, /** The anchor pathname property returns nothing for broken http(s) url's. */ - @BrowserFeature(CHROME) + @BrowserFeature({CHROME, FF60}) JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL, /** The anchor pathname property returns nothing for none http(s) url's. */ @@ -573,6 +573,10 @@ @BrowserFeature(CHROME) JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS, + /** The anchor protocol property returns 'http' for broken http(s) url's. */ + @BrowserFeature(FF60) + JS_ANCHOR_PROTOCOL_HTTP_FOR_BROKEN_URL, + /** Indicates that "someFunction.arguments" is a read-only view of the function's argument. */ @BrowserFeature({CHROME, FF}) JS_ARGUMENTS_READ_ONLY_ACCESSED_FROM_FUNCTION, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java 2018-06-27 18:35:57 UTC (rev 15392) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java 2018-06-27 18:56:45 UTC (rev 15393) @@ -20,10 +20,10 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_HTTP_FOR_BROKEN_URL; 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.IE; import java.net.MalformedURLException; @@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils; +import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.SgmlPage; import com.gargoylesoftware.htmlunit.html.DomElement; @@ -229,7 +230,7 @@ * Sets the rev property. * @param referrerPolicy referrerPolicy attribute value */ - @JsxSetter({CHROME, FF52}) + @JsxSetter({CHROME, FF}) public void setReferrerPolicy(final String referrerPolicy) { getDomNodeOrDie().setAttribute("referrerPolicy", referrerPolicy); } @@ -464,8 +465,9 @@ */ @JsxGetter public String getProtocol() { + final BrowserVersion browser = getBrowserVersion(); try { - if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) { + if (browser.hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); final String href = anchor.getHrefAttribute().toLowerCase(Locale.ROOT); if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) { @@ -477,9 +479,13 @@ } catch (final MalformedURLException e) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); - if (anchor.getHrefAttribute().startsWith("http") - && getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL)) { - return ":"; + if (anchor.getHrefAttribute().startsWith("http")) { + if (browser.hasFeature(JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL)) { + return ":"; + } + if (browser.hasFeature(JS_ANCHOR_PROTOCOL_HTTP_FOR_BROKEN_URL)) { + return "http:"; + } } return StringUtils.substringBefore(anchor.getHrefAttribute(), "/"); } |