From: <rb...@us...> - 2018-04-22 07:11:25
|
Revision: 15246 http://sourceforge.net/p/htmlunit/code/15246 Author: rbri Date: 2018-04-22 07:11:19 +0000 (Sun, 22 Apr 2018) Log Message: ----------- latest chrome (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSlot.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/AbstractList.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollection.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollectionTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -305,10 +305,6 @@ @BrowserFeature(IE) HTMLALLCOLLECTION_NO_COLLECTION_FOR_MANY_HITS, - /** HtmlAllCollection.item returns null instead of undefined if an element was not found. */ - @BrowserFeature({IE, FF}) - HTMLALLCOLLECTION_NULL_IF_ITEM_NOT_FOUND, - /** HtmlAllCollection.namedItem returns null instead of undefined if an element was not found. */ @BrowserFeature({CHROME, FF}) HTMLALLCOLLECTION_NULL_IF_NAMED_ITEM_NOT_FOUND, @@ -338,7 +334,7 @@ HTMLCOLLECTION_NAMED_ITEM_ID_FIRST, /** HtmlCollection.item returns null instead of undefined if an element was not found. */ - @BrowserFeature(IE) + @BrowserFeature({CHROME, IE}) HTMLCOLLECTION_NULL_IF_ITEM_NOT_FOUND, /** HtmlCollection returns null instead of undefined if an element was not found. */ @@ -1492,6 +1488,10 @@ @BrowserFeature({CHROME, FF52, IE}) SELECT_DESELECT_ALL_IF_SWITCHING_UNKNOWN, + /** The default display style of slot is 'content'. */ + @BrowserFeature(CHROME) + SLOT_CONTENTS, + /** Indicates that string.contains() is supported. */ @BrowserFeature(FF45) STRING_CONTAINS, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -81,6 +81,8 @@ NONE("none"), /** block. */ BLOCK("block"), + /** contents. */ + CONTENTS("contents"), /** inline. */ INLINE("inline"), /** inline-block. */ @@ -222,7 +224,7 @@ protected static void notifyAttributeChangeListeners(final HtmlAttributeChangeEvent event, final HtmlElement element, final String oldAttributeValue, final boolean notifyMutationObservers) { final Collection<HtmlAttributeChangeListener> listeners = element.attributeListeners_; - if (oldAttributeValue == ATTRIBUTE_NOT_DEFINED) { + if (ATTRIBUTE_NOT_DEFINED == oldAttributeValue) { synchronized (listeners) { for (final HtmlAttributeChangeListener listener : listeners) { if (notifyMutationObservers || !(listener instanceof MutationObserver)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSlot.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSlot.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSlot.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.SLOT_CONTENTS; + import java.util.Map; import com.gargoylesoftware.htmlunit.SgmlPage; @@ -22,6 +24,7 @@ * Wrapper for the HTML element "slot". * * @author Ahmed Ashour + * @author Ronald Brill */ public class HtmlSlot extends HtmlElement { @@ -45,6 +48,9 @@ */ @Override public DisplayStyle getDefaultStyleDisplay() { + if (getPage().getWebClient().getBrowserVersion().hasFeature(SLOT_CONTENTS)) { + return DisplayStyle.CONTENTS; + } return DisplayStyle.INLINE; } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/AbstractList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/AbstractList.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/AbstractList.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_NULL_IF_ITEM_NOT_FOUND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_NULL_IF_NOT_FOUND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_NODE_LIST_ENUMERATE_CHILDREN; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_NODE_LIST_ENUMERATE_FUNCTIONS; @@ -400,10 +399,7 @@ public Object item(final Object index) { final Object object = getIt(index); if (object == NOT_FOUND) { - if (getBrowserVersion().hasFeature(HTMLCOLLECTION_NULL_IF_ITEM_NOT_FOUND)) { - return null; - } - return Undefined.instance; + return null; } return object; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollection.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollection.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -18,10 +18,8 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLALLCOLLECTION_DO_NOT_SUPPORT_PARANTHESES; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLALLCOLLECTION_INTEGER_INDEX; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLALLCOLLECTION_NO_COLLECTION_FOR_MANY_HITS; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLALLCOLLECTION_NULL_IF_ITEM_NOT_FOUND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLALLCOLLECTION_NULL_IF_NAMED_ITEM_NOT_FOUND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_ITEM_FUNCT_SUPPORTS_DOUBLE_INDEX_ALSO; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_NAMED_ITEM_ID_FIRST; 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; @@ -88,7 +86,7 @@ numb = ScriptRuntime.toNumber(index); } if (numb.isNaN()) { - return itemNotFound(browser); + return null; } } else { @@ -97,12 +95,12 @@ } if (numb < 0) { - return itemNotFound(browser); + return null; } if (!browser.hasFeature(HTMLCOLLECTION_ITEM_FUNCT_SUPPORTS_DOUBLE_INDEX_ALSO) && (Double.isInfinite(numb) || numb != Math.floor(numb))) { - return itemNotFound(browser); + return null; } final Object object = get(numb.intValue(), this); @@ -112,13 +110,6 @@ return object; } - private static Object itemNotFound(final BrowserVersion browser) { - if (browser.hasFeature(HTMLALLCOLLECTION_NULL_IF_ITEM_NOT_FOUND)) { - return null; - } - return Undefined.instance; - } - /** * {@inheritDoc} */ @@ -130,24 +121,11 @@ final List<DomElement> matching = new ArrayList<>(); final BrowserVersion browser = getBrowserVersion(); - - final boolean idFirst = browser.hasFeature(HTMLCOLLECTION_NAMED_ITEM_ID_FIRST); - if (idFirst) { - for (final Object next : elements) { - if (next instanceof DomElement) { - final DomElement elem = (DomElement) next; - if (name.equals(elem.getId())) { - matching.add(elem); - } - } - } - } - for (final DomNode next : elements) { if (next instanceof DomElement) { final DomElement elem = (DomElement) next; if (name.equals(elem.getAttributeDirect("name")) - || (!idFirst && name.equals(elem.getId()))) { + || name.equals(elem.getId())) { matching.add(elem); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -1356,7 +1356,6 @@ */ @Test @Alerts(DEFAULT = {"coll 2", "f6<->form6", "form6<->form6_2"}, - CHROME = {"coll 2", "form6<->form6_2", "f6<->form6"}, IE = "f6<->form6") public void all_NamedItem_DuplicateIdName() throws Exception { namedItem("form6"); @@ -1471,8 +1470,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = {"undefined", "undefined", "null"}, - FF = {"null", "null", "null"}, + @Alerts(DEFAULT = {"null", "null", "null"}, IE = {"undefined", "null", "undefined"}) public void all_NotExisting() throws Exception { final String html = "<html><head><title>First</title><script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollectionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollectionTest.java 2018-04-21 16:25:05 UTC (rev 15245) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAllCollectionTest.java 2018-04-22 07:11:19 UTC (rev 15246) @@ -96,7 +96,6 @@ */ @Test @Alerts(DEFAULT = {"coll 2", "b6-button6", "button6-button6_2"}, - CHROME = {"coll 2", "button6-button6_2", "b6-button6"}, IE = "b6-button6") public void namedItem_DuplicateIdName() throws Exception { namedItem("'button6'"); @@ -207,8 +206,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "null", - CHROME = "undefined") + @Alerts("null") public void item_Unknown() throws Exception { item("'foo'"); } @@ -235,8 +233,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "null", - CHROME = "undefined") + @Alerts("null") public void item_NegativIndex() throws Exception { item("-1"); } @@ -264,7 +261,7 @@ */ @Test @Alerts(DEFAULT = "myHead-undefined", - CHROME = "undefined") + CHROME = "null") public void item_DoubleIndex() throws Exception { item("1.1"); } @@ -292,8 +289,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "null", - CHROME = "undefined") + @Alerts("null") public void item_IndexDoubleAsString() throws Exception { item("'1.1'"); } @@ -452,8 +448,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "undefined", - FF = "null") + @Alerts(DEFAULT = "null", + IE = "undefined") public void functionIndex_Unknown() throws Exception { functionIndex("'foo'"); } @@ -480,8 +476,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "undefined", - FF = "null") + @Alerts(DEFAULT = "null", + IE = "undefined") public void functionIndex_NegativIndex() throws Exception { functionIndex("-1"); } @@ -511,7 +507,6 @@ */ @Test @Alerts(DEFAULT = "null", - CHROME = "undefined", IE = "myHead-undefined") public void functionIndex_DoubleIndex() throws Exception { functionIndex("1.1"); |