diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 71154a0b1f3..3536fd3b400 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: SARIF file path: results.sarif diff --git a/README.md b/README.md index c79b5c98e78..b61ad1fcc8b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ![HtmlUnit Logo](https://github.com/HtmlUnit/htmlunit/blob/master/src/site/resources/images/htmlunit.png) -Version 4.11.1 / March 26, 2025 +Version 4.12.0 / May 17, 2025 :heart: [Sponsor](https://github.com/sponsors/rbri) @@ -51,7 +51,7 @@ Add to your `pom.xml`: org.htmlunit htmlunit - 4.11.1 + 4.12.0 ``` @@ -60,7 +60,7 @@ Add to your `pom.xml`: Add to your `build.gradle`: ```groovy -implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.11.1' +implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.12.0' ``` ## Vulnerabilities @@ -172,7 +172,7 @@ Add the snapshot repository and dependency to your `pom.xml`: org.htmlunit htmlunit - 4.12.0-SNAPSHOT + 4.13.0-SNAPSHOT diff --git a/checkstyle.xml b/checkstyle.xml index 4440727915b..b6e52d0a9b1 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -134,7 +134,7 @@ - + @@ -264,7 +264,6 @@ - \ No newline at end of file diff --git a/pom.xml b/pom.xml index eb6c1e3338b..7f6ef3e52bc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,18 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 + org.htmlunit htmlunit - 4.11.1 + 4.12.0 + jar + HtmlUnit + + A headless browser intended for use in testing web-based applications. + Gargoyle Software Inc. http://www.GargoyleSoftware.com/ - jar - - A headless browser intended for use in testing web-based applications. - https://www.htmlunit.org @@ -25,37 +27,40 @@ 8 8 - 4.11.0 - 4.11.0 - 4.11.0 - 4.11.0 - 4.11.0 - 4.11.0 + 4.12.0 + 4.12.0 + 4.12.0 + 4.12.0 + 4.12.0 + 4.12.0 4.5.14 3.17.0 - 2.18.0 + 2.19.0 1.3.5 0.1.2 + + 4.32.0 + 4.32.0 + selenium-devtools-v136 - 4.30.0 - 4.30.0 - selenium-devtools-v134 - + + 4.13.2 9.4.57.v20241219 4.0.66 2.24.3 2.0.17 + 1.13.1 1.5 4.4.0 1.5.5 - 10.21.4 + + 10.23.1 4.9.3 - 7.11.0 - 4.13.2 - 1.4.0 + 7.13.0 + 1.4.1 10.0.4 @@ -198,7 +203,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 org.apache.maven.plugins @@ -315,7 +320,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -345,7 +350,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -376,7 +381,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -404,7 +409,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -432,7 +437,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -462,7 +467,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -491,7 +496,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -520,7 +525,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -549,7 +554,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -577,7 +582,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -605,7 +610,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -633,7 +638,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -662,7 +667,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + 3.5.3 false @@ -1351,7 +1356,7 @@ org.apache.xmlgraphics batik-transcoder - 1.18 + 1.19 test @@ -1368,7 +1373,7 @@ org.apache.commons commons-text - 1.13.0 + ${commons-text.version} test diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 604a5436686..713c4750ceb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -7,6 +7,138 @@ + + + WebClient option NekoReaderBufferSize added. You can use this to increase the buffer size used by + the Neko Html parser to optimize parsing performance. + + + HTMLParser parseFragment(DomNode, String), parse(WebResponse, HtmlPage, boolean, boolean), and + parseFragment(DomNode, DomNode, String, boolean) are deprecated. + + + neko: HTMLScanner always requires a document handler; the null check is moved to the setter + and all the others are removed. + + + neko: avoid HTML1011 error for self closing tags. + + + neko: ignore whitespace before the closing > when parsing special tags. + + + neko: remove two superfluous conversions from the code. + + + core-js: NativeArray impl is now lambda based. + + + core-js: improved date string parser; support optional ms digits, + skip ms digits, extended year support is not available in es6 + + + core-js: detailed message added to IndexOutOfBoundsExceptions + + + core-js: add double null check pattern when initializing cache values. + + + DomTokenList.forEach() now takes care of the current state of the list + (e.g. the forEach function might add/remove elements to the list itself). + + + NodeList.forEach() now takes care of the current state of the list + (e.g. the forEach function might add/remove elements to the list itself). + + + AlertHandler, ConfirmHandler, FrameContentHandler, CharacterDataChangeListener, and IncorrectnessListener + marked as @FunctionalInterface. + + + Upgrade Apache commons-io to 2.19.0. + + + Element.scrollIntoView() now triggers scroll events on all parents. + + + For FF scroll events are of type UIEvent. + + + Scroll events are not bubbling and not cancelable. + + + core-js: Function.prototype[Symbol.hasInstance] fixed. + + + core-js: regression in hex and unicode hex parsing or regexp fixed + + + CSS blockSize support improved. + + + core-js: Complete reimplementation of 'String.prototype.search', 'String.prototype.replace', + 'String.prototype.replaceAll', and 'String.prototype.split'. The new impl is much closer to the spec. + + + core-js: Fix a character class parsing regression for regexp. + + + core-js: Fix handling of \x and \u in regexp. + + + FF137: SVGDiscardElement added. + + + Chrome/Edge 135, FF137: Setter validation for length style properties adjusted. + + + Chrome/Edge 135: Style properties 'interactivity', 'overflowBlock', 'overflowInline', and 'scrollMarkerGroup' added. + + + FF137: Adjust clientHeight for some ruby related tags. + + + Chrome/Edge 135, FF137: Improved namespace handling when sending an html document via XMLHttpRequest. + + + Chrome/Edge 135: Improved <br> handling in options tags. + + + Chrome/Edge 135, FF137: Fixed font sizes for smaller/larger css prooerty value. + + + FF137: Set span for table cells to zero if provided value is invalid. + + + core-js: Some fixes for strict handling. + + + core-js: Several code improvements for the RegExp implementation. + + + WebClient.setWebSocketAdapter(WebSocketAdapterFactory) added. This should + help to use a different WebSocket implementation. + + + WebSocketAdapter splitted into WebSocketAdapter and WebSocketListener. + New interface WebSocketAdapterFactory introduced. This should help to + make it simpler to use a different WebSocket implementation. + + + core-js: Named capture groups in RegularExpressions now supported. + + + Deprecated method CssStyleSheet.validateSelectors(SelectorList, int, DomNode) removed. + + + Deprecated method HtmlForm.getElements() removed. + + + Deprecated method WebRequest.setRefererlHeader(URL) removed. + + + + NumberFormatException when calculating the clientHeight/offsetHeight. diff --git a/src/main/java/org/htmlunit/AlertHandler.java b/src/main/java/org/htmlunit/AlertHandler.java index 227f2f186a1..d8b768a0f6c 100644 --- a/src/main/java/org/htmlunit/AlertHandler.java +++ b/src/main/java/org/htmlunit/AlertHandler.java @@ -23,6 +23,7 @@ * @author Mike Bowler * @author Ronald Brill */ +@FunctionalInterface public interface AlertHandler extends Serializable { /** diff --git a/src/main/java/org/htmlunit/BrowserVersion.java b/src/main/java/org/htmlunit/BrowserVersion.java index 21f04601d44..68afc603429 100644 --- a/src/main/java/org/htmlunit/BrowserVersion.java +++ b/src/main/java/org/htmlunit/BrowserVersion.java @@ -61,11 +61,11 @@ * @author Frank Danek * @author Ronald Brill */ -@SuppressWarnings("PMD.AvoidDuplicateLiterals") +@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "PMD.TooManyFields"}) public final class BrowserVersion implements Serializable { /** Latest Firefox. */ - public static final BrowserVersion FIREFOX = new BrowserVersion(136, "FF"); + public static final BrowserVersion FIREFOX = new BrowserVersion(137, "FF"); private static final int FIREFOX_ESR_NUMERIC = 128; @@ -73,10 +73,10 @@ public final class BrowserVersion implements Serializable { public static final BrowserVersion FIREFOX_ESR = new BrowserVersion(FIREFOX_ESR_NUMERIC, "FF-ESR"); /** Latest Edge. */ - public static final BrowserVersion EDGE = new BrowserVersion(134, "Edge"); + public static final BrowserVersion EDGE = new BrowserVersion(135, "Edge"); /** Latest Chrome. */ - public static final BrowserVersion CHROME = new BrowserVersion(134, "Chrome"); + public static final BrowserVersion CHROME = new BrowserVersion(135, "Chrome"); /** * Array with all supported browsers. @@ -197,6 +197,7 @@ public final class BrowserVersion implements Serializable { CHROME.cssAcceptHeader_ = "text/css,*/*;q=0.1"; CHROME.scriptAcceptHeader_ = "*/*"; + /* if (CHROME.getBrowserVersionNumeric() % 2 == 0) { CHROME.secClientHintUserAgentHeader_ = "\"Chromium\";v=\"" + CHROME.getBrowserVersionNumeric() + "\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"" @@ -207,6 +208,10 @@ public final class BrowserVersion implements Serializable { + CHROME.getBrowserVersionNumeric() + "\", \"Chromium\";v=\"" + CHROME.getBrowserVersionNumeric() + "\""; } + */ + CHROME.secClientHintUserAgentHeader_ = "\"Google Chrome\";v=\"" + + CHROME.getBrowserVersionNumeric() + "\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"" + + CHROME.getBrowserVersionNumeric() + "\""; CHROME.fontHeights_ = new int[] { 0, 1, 2, 4, 5, 5, 6, 8, 9, 10, 11, 12, 15, 16, 16, 17, 18, 20, 21, 22, 23, 25, 26, 26, @@ -250,7 +255,9 @@ public final class BrowserVersion implements Serializable { EDGE.imgAcceptHeader_ = "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; EDGE.cssAcceptHeader_ = "text/css,*/*;q=0.1"; EDGE.scriptAcceptHeader_ = "*/*"; - if (CHROME.getBrowserVersionNumeric() % 2 == 0) { + + /* + if (EDGE.getBrowserVersionNumeric() % 2 == 0) { EDGE.secClientHintUserAgentHeader_ = "\"Chromium\";v=\"" + EDGE.getBrowserVersionNumeric() + "\", \"Not:A-Brand\";v=\"24\", \"Microsoft Edge\";v=\"" + EDGE.getBrowserVersionNumeric() + "\""; @@ -260,6 +267,11 @@ public final class BrowserVersion implements Serializable { + EDGE.getBrowserVersionNumeric() + "\", \"Chromium\";v=\"" + EDGE.getBrowserVersionNumeric() + "\""; } + */ + EDGE.secClientHintUserAgentHeader_ = "\"Microsoft Edge\";v=\"" + + EDGE.getBrowserVersionNumeric() + "\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"" + + EDGE.getBrowserVersionNumeric() + "\""; + EDGE.fontHeights_ = new int[] { 0, 1, 2, 4, 5, 5, 6, 8, 9, 10, 11, 12, 15, 16, 16, 17, 18, 20, 21, 22, 23, 25, 26, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 37, 38, 40, 42, 43, 44, 45, 47, 48, 48, 49, 51, 52, 53, 54, 55, 57, @@ -806,13 +818,13 @@ public int getFontHeight(final String fontSize) { } if ("xx-small".equalsIgnoreCase(fontSize)) { - return fontHeights_[10]; + return fontHeights_[9]; } if ("x-small".equalsIgnoreCase(fontSize)) { return fontHeights_[10]; } if ("small".equalsIgnoreCase(fontSize)) { - return fontHeights_[12]; + return fontHeights_[13]; } if ("medium".equalsIgnoreCase(fontSize)) { return fontHeights_[16]; @@ -821,7 +833,7 @@ public int getFontHeight(final String fontSize) { return fontHeights_[18]; } if ("x-large".equalsIgnoreCase(fontSize)) { - return fontHeights_[25]; + return fontHeights_[24]; } if ("xx-large".equalsIgnoreCase(fontSize)) { return fontHeights_[32]; @@ -829,8 +841,9 @@ public int getFontHeight(final String fontSize) { if ("xxx-large".equalsIgnoreCase(fontSize)) { return fontHeights_[48]; } + if ("smaller".equalsIgnoreCase(fontSize)) { - return fontHeights_[12]; + return fontHeights_[13]; } if ("larger".equalsIgnoreCase(fontSize)) { return fontHeights_[19]; diff --git a/src/main/java/org/htmlunit/BrowserVersionFeatures.java b/src/main/java/org/htmlunit/BrowserVersionFeatures.java index e3133d721c7..3a68914a218 100644 --- a/src/main/java/org/htmlunit/BrowserVersionFeatures.java +++ b/src/main/java/org/htmlunit/BrowserVersionFeatures.java @@ -90,6 +90,10 @@ public enum BrowserVersionFeatures { @BrowserFeature({FF, FF_ESR}) EVENT_ONPOPSTATE_DOCUMENT_CREATE_NOT_SUPPORTED, + /** Scroll events are of type 'UIEvent'. */ + @BrowserFeature({FF, FF_ESR}) + EVENT_SCROLL_UIEVENT, + /** Supports event type 'TextEvent'. */ @BrowserFeature({FF, FF_ESR}) EVENT_TYPE_MUTATIONEVENT, @@ -266,6 +270,18 @@ public enum BrowserVersionFeatures { @BrowserFeature(FF) JS_CLIENTHEIGHT_RADIO_CHECKBOX_14, + /** ClientHeight for rb is 17. */ + @BrowserFeature({FF, FF_ESR}) + JS_CLIENTHEIGHT_RB_17, + + /** ClientHeight for rt is 9. */ + @BrowserFeature({FF, FF_ESR}) + JS_CLIENTHEIGHT_RT_9, + + /** ClientHeight for ruby is 17. */ + @BrowserFeature({FF, FF_ESR}) + JS_CLIENTHEIGHT_RUBY_17, + /** ClientWidth for text/password input is 154. */ @BrowserFeature(FF_ESR) JS_CLIENTWIDTH_INPUT_TEXT_154, @@ -408,14 +424,14 @@ public enum BrowserVersionFeatures { @BrowserFeature({FF, FF_ESR}) JS_STORAGE_PRESERVED_INCLUDED, + /** Indicates letterSpacing support percent values. */ + @BrowserFeature(FF) + JS_STYLE_LETTER_SPACING_ACCEPTS_PERCENT, + /** Indicates wordSpacing support percent values. */ @BrowserFeature({FF, FF_ESR}) JS_STYLE_WORD_SPACING_ACCEPTS_PERCENT, - /** Set span zo zero if provided value is invalid. */ - @BrowserFeature({CHROME, EDGE}) - JS_TABLE_SPAN_SET_ZERO_IF_INVALID, - /** window.getComputedStyle works with pseudo selectors without colon in front. */ @BrowserFeature({CHROME, EDGE}) JS_WINDOW_COMPUTED_STYLE_PSEUDO_ACCEPT_WITHOUT_COLON, diff --git a/src/main/java/org/htmlunit/ConfirmHandler.java b/src/main/java/org/htmlunit/ConfirmHandler.java index ea1b12a47eb..1502869f3e2 100644 --- a/src/main/java/org/htmlunit/ConfirmHandler.java +++ b/src/main/java/org/htmlunit/ConfirmHandler.java @@ -21,7 +21,9 @@ * are triggered when the JavaScript function window.confirm() is invoked. * * @author Mike Bowler + * @author Ronald Brill */ +@FunctionalInterface public interface ConfirmHandler extends Serializable { /** diff --git a/src/main/java/org/htmlunit/DefaultPageCreator.java b/src/main/java/org/htmlunit/DefaultPageCreator.java index 14936310edd..85aff6db4ca 100644 --- a/src/main/java/org/htmlunit/DefaultPageCreator.java +++ b/src/main/java/org/htmlunit/DefaultPageCreator.java @@ -297,7 +297,7 @@ protected HtmlPage createHtmlPage(final WebResponse webResponse, final WebWindow final HtmlPage page = new HtmlPage(webResponse, webWindow); webWindow.setEnclosedPage(page); - HTML_PARSER.parse(webResponse, page, false, false); + HTML_PARSER.parse(webWindow.getWebClient(), webResponse, page, false, false); return page; } @@ -313,7 +313,7 @@ protected XHtmlPage createXHtmlPage(final WebResponse webResponse, final WebWind final XHtmlPage page = new XHtmlPage(webResponse, webWindow); webWindow.setEnclosedPage(page); - HTML_PARSER.parse(webResponse, page, true, false); + HTML_PARSER.parse(webWindow.getWebClient(), webResponse, page, true, false); return page; } diff --git a/src/main/java/org/htmlunit/FrameContentHandler.java b/src/main/java/org/htmlunit/FrameContentHandler.java index 83ddad1c8d7..90917500cba 100644 --- a/src/main/java/org/htmlunit/FrameContentHandler.java +++ b/src/main/java/org/htmlunit/FrameContentHandler.java @@ -23,6 +23,7 @@ * * @author Ronald Brill */ +@FunctionalInterface public interface FrameContentHandler { /** diff --git a/src/main/java/org/htmlunit/HttpWebConnection.java b/src/main/java/org/htmlunit/HttpWebConnection.java index 68ac8252b6e..7a15b14943e 100644 --- a/src/main/java/org/htmlunit/HttpWebConnection.java +++ b/src/main/java/org/htmlunit/HttpWebConnection.java @@ -426,7 +426,8 @@ private static Charset getCharset(final Charset charset, final List 127) { return charset; } diff --git a/src/main/java/org/htmlunit/IncorrectnessListener.java b/src/main/java/org/htmlunit/IncorrectnessListener.java index 0a1f5dbc1d4..be471515020 100644 --- a/src/main/java/org/htmlunit/IncorrectnessListener.java +++ b/src/main/java/org/htmlunit/IncorrectnessListener.java @@ -20,7 +20,9 @@ * that HtmlUnit can handle but that denote a badly written application. * * @author Marc Guillemot + * @author Ronald Brill */ +@FunctionalInterface public interface IncorrectnessListener { /** diff --git a/src/main/java/org/htmlunit/WebClient.java b/src/main/java/org/htmlunit/WebClient.java index 15972c06e64..c17eedc9094 100644 --- a/src/main/java/org/htmlunit/WebClient.java +++ b/src/main/java/org/htmlunit/WebClient.java @@ -99,6 +99,10 @@ import org.htmlunit.util.MimeType; import org.htmlunit.util.NameValuePair; import org.htmlunit.util.UrlUtils; +import org.htmlunit.websocket.JettyWebSocketAdapter.JettyWebSocketAdapterFactory; +import org.htmlunit.websocket.WebSocketAdapter; +import org.htmlunit.websocket.WebSocketAdapterFactory; +import org.htmlunit.websocket.WebSocketListener; import org.htmlunit.webstart.WebStartHandler; /** @@ -147,6 +151,7 @@ * @author René Schwietzke * @author Sven Strickroth */ +@SuppressWarnings("PMD.TooManyFields") public class WebClient implements Serializable, AutoCloseable { /** Logging support. */ @@ -191,6 +196,7 @@ public class WebClient implements Serializable, AutoCloseable { private transient WebConnection webConnection_; private CredentialsProvider credentialsProvider_ = new DefaultCredentialsProvider(); private CookieManager cookieManager_ = new CookieManager(); + private WebSocketAdapterFactory webSocketAdapterFactory_; private transient AbstractJavaScriptEngine scriptEngine_; private transient List loadQueue_; private final Map requestHeaders_ = Collections.synchronizedMap(new HashMap<>(89)); @@ -332,6 +338,8 @@ public WebClient(final BrowserVersion browserVersion, final boolean javaScriptEn } loadQueue_ = new ArrayList<>(); + webSocketAdapterFactory_ = new JettyWebSocketAdapterFactory(); + // The window must be constructed AFTER the script engine. currentWindowTracker_ = new CurrentWindowTracker(this, true); currentWindow_ = new TopLevelWindow("", this); @@ -507,7 +515,8 @@

P getPage(final WebWindow webWindow, final WebRequest webReques /** * Convenient method to build a URL and load it into the current WebWindow as it would be done * by {@link #getPage(WebWindow, WebRequest)}. - * @param url the URL of the new content + * @param url the URL of the new content; in contrast to real browsers plain file url's are not supported. + * You have to use the 'file', 'data', 'blob', 'http' or 'https' protocol. * @param

the page type * @return the new page * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property @@ -523,7 +532,8 @@ public

P getPage(final String url) throws IOException, FailingH /** * Convenient method to load a URL into the current top WebWindow as it would be done * by {@link #getPage(WebWindow, WebRequest)}. - * @param url the URL of the new content + * @param url the URL of the new content; in contrast to real browsers plain file url's are not supported. + * You have to use the 'file', 'data', 'blob', 'http' or 'https' protocol. * @param

the page type * @return the new page * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property @@ -534,7 +544,6 @@ public

P getPage(final URL url) throws IOException, FailingHttp final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader(), getBrowserVersion().getAcceptEncodingHeader()); request.setCharset(UTF_8); - return getPage(getCurrentWindow().getTopWindow(), request); } @@ -1539,7 +1548,8 @@ private WebResponse makeWebResponseForJavaScriptUrl(final WebWindow webWindow, f * @return the WebResponse */ public WebResponse loadWebResponse(final WebRequest webRequest) throws IOException { - switch (webRequest.getUrl().getProtocol()) { + final String protocol = webRequest.getUrl().getProtocol(); + switch (protocol) { case UrlUtils.ABOUT: return makeWebResponseForAboutUrl(webRequest); @@ -1552,8 +1562,12 @@ public WebResponse loadWebResponse(final WebRequest webRequest) throws IOExcepti case "blob": return makeWebResponseForBlobUrl(webRequest); - default: + case "http": + case "https": return loadWebResponseFromWebConnection(webRequest, ALLOWED_REDIRECTIONS_SAME_URL); + + default: + throw new IOException("Unsupported protocol '" + protocol + "'"); } } @@ -2540,6 +2554,7 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot scriptEngine_ = new JavaScriptEngine(this); jobManagers_ = Collections.synchronizedList(new ArrayList<>()); loadQueue_ = new ArrayList<>(); + css3ParserPool_ = new CSS3ParserPool(); } private static class LoadJob { @@ -2589,13 +2604,12 @@ public boolean isOutdated() { * @param target the name of the target window * @param request the request to perform * @param checkHash if true check for hashChenage - * @param forceLoad if true always load the request even if there is already the same in the queue * @param forceAttachmentWithFilename if not {@code null} the AttachmentHandler isAttachment() method is not called, * the response has to be handled as attachment in any case * @param description information about the origin of the request. Useful for debugging. */ public void download(final WebWindow requestingWindow, final String target, - final WebRequest request, final boolean checkHash, final boolean forceLoad, + final WebRequest request, final boolean checkHash, final String forceAttachmentWithFilename, final String description) { final WebWindow targetWindow = resolveWindow(requestingWindow, target); @@ -2632,9 +2646,7 @@ public void download(final WebWindow requestingWindow, final String target, final WebRequest otherRequest = otherLoadJob.request_; final URL otherUrl = otherRequest.getUrl(); - // TODO: investigate but it seems that IE considers query string too but not FF - if (!forceLoad - && url.getPath().equals(otherUrl.getPath()) // fail fast + if (url.getPath().equals(otherUrl.getPath()) // fail fast && url.toString().equals(otherUrl.toString()) && request.getRequestParameters().equals(otherRequest.getRequestParameters()) && Objects.equals(request.getRequestBody(), otherRequest.getRequestBody())) { @@ -2863,7 +2875,7 @@ public HtmlPage loadHtmlCodeIntoCurrentWindow(final String htmlCode) throws IOEx final HtmlPage page = new HtmlPage(webResponse, webWindow); webWindow.setEnclosedPage(page); - htmlParser.parse(webResponse, page, false, false); + htmlParser.parse(this, webResponse, page, false, false); return page; } @@ -2884,10 +2896,29 @@ public XHtmlPage loadXHtmlCodeIntoCurrentWindow(final String xhtmlCode) throws I final XHtmlPage page = new XHtmlPage(webResponse, webWindow); webWindow.setEnclosedPage(page); - htmlParser.parse(webResponse, page, true, false); + htmlParser.parse(this, webResponse, page, true, false); return page; } + /** + * Creates a new {@link WebSocketAdapter}. + * + * @param webSocketListener the {@link WebSocketListener} + * @return a new {@link WebSocketAdapter} + */ + public WebSocketAdapter buildWebSocketAdapter(final WebSocketListener webSocketListener) { + return webSocketAdapterFactory_.buildWebSocketAdapter(this, webSocketListener); + } + + /** + * Defines a new factory method to create a new WebSocketAdapter. + * + * @param factory a {@link WebSocketAdapterFactory} + */ + public void setWebSocketAdapter(final WebSocketAdapterFactory factory) { + webSocketAdapterFactory_ = factory; + } + /** * INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
* @@ -2919,7 +2950,7 @@ static class CSS3ParserPool { * Our pool. We only hold data when it is available. In addition, synchronization against * this deque is cheap. */ - private ConcurrentLinkedDeque parsers_ = new ConcurrentLinkedDeque<>(); + private final ConcurrentLinkedDeque parsers_ = new ConcurrentLinkedDeque<>(); /** * Fetch a new or recycled CSS3parser. Make sure you use the try-with-resource concept diff --git a/src/main/java/org/htmlunit/WebClientOptions.java b/src/main/java/org/htmlunit/WebClientOptions.java index a1a1237243d..2e672d3ff81 100644 --- a/src/main/java/org/htmlunit/WebClientOptions.java +++ b/src/main/java/org/htmlunit/WebClientOptions.java @@ -37,6 +37,7 @@ * @author Madis Pärn * @author Ronald Brill */ +@SuppressWarnings("PMD.TooManyFields") public class WebClientOptions implements Serializable { /** 1920. */ @@ -82,6 +83,8 @@ public class WebClientOptions implements Serializable { private boolean geolocationEnabled_; private Geolocation geolocation_; + private int nekoReaderBufferSize_ = -1; + private boolean webSocketEnabled_ = true; private int webSocketMaxTextMessageSize_ = -1; private int webSocketMaxTextMessageBufferSize_ = -1; @@ -725,6 +728,23 @@ public int getScreenHeight() { return screenHeight_; } + /** + * @return the Neko Html parser reader buffer size + */ + public int getNekoReaderBufferSize() { + return nekoReaderBufferSize_; + } + + /** + * Sets the Neko Html parser reader buffer size. + * + * @param nekoReaderBufferSize the new value + */ + public void setNekoReaderBufferSize(final int nekoReaderBufferSize) { + nekoReaderBufferSize_ = nekoReaderBufferSize; + } + + /** * Enables/disables WebSocket support. By default, this property is enabled. * diff --git a/src/main/java/org/htmlunit/WebRequest.java b/src/main/java/org/htmlunit/WebRequest.java index e07f4fd775b..137225f8c17 100644 --- a/src/main/java/org/htmlunit/WebRequest.java +++ b/src/main/java/org/htmlunit/WebRequest.java @@ -54,6 +54,7 @@ * @author Lai Quang Duong * @author Kristof Neirynck */ +@SuppressWarnings("PMD.TooManyFields") public class WebRequest implements Serializable { /** @@ -559,17 +560,6 @@ public void setRefererHeader(final URL url) { } } - /** - * Sets the referer HTTP header - only if the provided url is valid. - * @param url the url for the referer HTTP header - * - * @deprecated as of version 4.5.0; use {@link #setRefererHeader(URL)} instead - */ - @Deprecated - public void setRefererlHeader(final URL url) { - setRefererHeader(url); - } - /** * Sets the specified name/value pair in the additional HTTP headers. * @param name the name of the additional HTTP header diff --git a/src/main/java/org/htmlunit/WebResponse.java b/src/main/java/org/htmlunit/WebResponse.java index 80ce54b66d5..4661bde6bb1 100644 --- a/src/main/java/org/htmlunit/WebResponse.java +++ b/src/main/java/org/htmlunit/WebResponse.java @@ -240,7 +240,7 @@ public Charset getContentCharset() { * @return {@code true} if the charset of the previous call to {@link #getContentCharset()} was * "tentative". * @see - * https://html.spec.whatwg.org/multipage/parsing.html#concept-encoding-confidence + * https://html.spec.whatwg.org/multipage/parsing.html#concept-encoding-confidence */ public boolean wasContentCharsetTentative() { return wasContentCharsetTentative_; diff --git a/src/main/java/org/htmlunit/WebWindowListener.java b/src/main/java/org/htmlunit/WebWindowListener.java index 0cb8868d4f1..e111fc50c70 100644 --- a/src/main/java/org/htmlunit/WebWindowListener.java +++ b/src/main/java/org/htmlunit/WebWindowListener.java @@ -25,6 +25,10 @@ * process. This implies, the initial window is already open at the time you attach this listener. * Therefore you will receive no open event for this. *

+ *

+ * Caution: Frames and also iFrames are handled as separate windows. Therefore the listener is also + * called for each and every containing (i)Frame when e.g. closing a {@link TopLevelWindow}. + *

* * @author Mike Bowler * @author Ronald Brill diff --git a/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java b/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java index 4e650546d79..c0baff12da7 100644 --- a/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java +++ b/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java @@ -437,6 +437,14 @@ public String getBackgroundRepeat() { return value; } + /** + * Gets the {@code blockSize} style attribute. + * @return the style attribute + */ + public String getBlockSize() { + return getStyleAttribute(Definition.BLOCK_SIZE, true); + } + /** * Gets the {@code borderBottomColor} style attribute. * @return the style attribute diff --git a/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java b/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java index ae132d1273c..702b704a269 100644 --- a/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java +++ b/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java @@ -18,6 +18,9 @@ import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_INPUT_18; import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_RADIO_CHECKBOX_10; import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_RADIO_CHECKBOX_14; +import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_RB_17; +import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_RT_9; +import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTHEIGHT_RUBY_17; import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTWIDTH_INPUT_TEXT_154; import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTWIDTH_INPUT_TEXT_173; import static org.htmlunit.BrowserVersionFeatures.JS_CLIENTWIDTH_RADIO_CHECKBOX_10; @@ -526,6 +529,10 @@ public String getBackgroundAttachment() { */ @Override public String getBackgroundColor() { + if (!getDomElement().isAttachedToPage()) { + return EMPTY_FINAL; + } + final String value = super.getBackgroundColor(); if (StringUtils.isEmpty(value)) { return Definition.BACKGROUND_COLOR.getDefaultComputedValue(getBrowserVersion()); @@ -558,6 +565,38 @@ public String getBackgroundRepeat() { return defaultIfEmpty(super.getBackgroundRepeat(), Definition.BACKGROUND_REPEAT); } + /** + * {@inheritDoc} + */ + @Override + public String getBlockSize() { + if (NONE.equals(getDisplay())) { + return defaultIfEmpty(super.getBlockSize(), Definition.BLOCK_SIZE); + } + + final DomElement domElem = getDomElement(); + if (!domElem.isAttachedToPage()) { + return defaultIfEmpty(super.getBlockSize(), Definition.BLOCK_SIZE); + } + + return CssPixelValueConverter.pixelString(domElem, new CssPixelValueConverter.CssValue(0, 0) { + @Override + public String get(final ComputedCssStyleDeclaration style) { + final String value = style.getStyleAttribute(Definition.HEIGHT, true); + if (StringUtils.isEmpty(value)) { + final String content = domElem.getVisibleText(); + // do this only for small content + // at least for empty div's this is more correct + if (null == content) { + return getDefaultValue() + "px"; + } + return getEmptyHeight(domElem) + "px"; + } + return value; + } + }); + } + /** * {@inheritDoc} */ @@ -1177,6 +1216,10 @@ public String getWordSpacing() { */ @Override public String getZIndex() { + if (!getDomElement().isAttachedToPage()) { + return EMPTY_FINAL; + } + final String response = super.getZIndex(); if (response.isEmpty()) { return AUTO; @@ -1663,9 +1706,9 @@ else if (child instanceof DomText) { * elements */ private int getEmptyHeight(final DomElement element) { - final Integer cachedHeight2 = getCachedEmptyHeight(); - if (cachedHeight2 != null) { - return cachedHeight2.intValue(); + final Integer cachedEmptyHeight = getCachedEmptyHeight(); + if (cachedEmptyHeight != null) { + return cachedEmptyHeight.intValue(); } if (!element.mayBeDisplayed()) { @@ -1726,10 +1769,7 @@ private int getEmptyHeight(final DomElement element) { || element instanceof HtmlNoLayer || element instanceof HtmlNoScript || element instanceof HtmlPlainText - || element instanceof HtmlRuby - || element instanceof HtmlRb || element instanceof HtmlRp - || element instanceof HtmlRt || element instanceof HtmlRtc || element instanceof HtmlS || element instanceof HtmlSample @@ -1797,6 +1837,33 @@ else if (element instanceof HtmlInlineFrame) { defaultHeight = 0; } } + else if (element instanceof HtmlRb) { + final BrowserVersion browser = webWindow.getWebClient().getBrowserVersion(); + if (browser.hasFeature(JS_CLIENTHEIGHT_RB_17)) { + defaultHeight = 17; + } + else { + defaultHeight = 0; + } + } + else if (element instanceof HtmlRt) { + final BrowserVersion browser = webWindow.getWebClient().getBrowserVersion(); + if (browser.hasFeature(JS_CLIENTHEIGHT_RT_9)) { + defaultHeight = 9; + } + else { + defaultHeight = 0; + } + } + else if (element instanceof HtmlRuby) { + final BrowserVersion browser = webWindow.getWebClient().getBrowserVersion(); + if (browser.hasFeature(JS_CLIENTHEIGHT_RUBY_17)) { + defaultHeight = 17; + } + else { + defaultHeight = 0; + } + } else { final String fontSize; @@ -1902,6 +1969,13 @@ else if (element instanceof HtmlHeading6) { defaultHeight *= StringUtils.countMatches(content, '\n') + 1; } } + + final String styleHeight = getStyleAttribute(Definition.HEIGHT, true); + if (styleHeight.endsWith("%")) { + if (page instanceof HtmlPage && !((HtmlPage) page).isQuirksMode()) { + return defaultHeight; + } + } } } diff --git a/src/main/java/org/htmlunit/css/CssColors.java b/src/main/java/org/htmlunit/css/CssColors.java index 85c0a8aa086..1e5ae5094c6 100644 --- a/src/main/java/org/htmlunit/css/CssColors.java +++ b/src/main/java/org/htmlunit/css/CssColors.java @@ -14,9 +14,9 @@ */ package org.htmlunit.css; -import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * Helper to work with colors. @@ -25,7 +25,7 @@ */ public final class CssColors { - private static final Map CSS_COLORS = new HashMap<>(); + private static final Map CSS_COLORS = new ConcurrentHashMap<>(); static { CSS_COLORS.put("aqua", "rgb(0, 255, 255)"); diff --git a/src/main/java/org/htmlunit/css/CssStyleSheet.java b/src/main/java/org/htmlunit/css/CssStyleSheet.java index afcbe5339de..9afb0bc3feb 100644 --- a/src/main/java/org/htmlunit/css/CssStyleSheet.java +++ b/src/main/java/org/htmlunit/css/CssStyleSheet.java @@ -1044,25 +1044,6 @@ private static String toString(final InputSource source) { } } - /** - * Validates the list of selectors. - * @param selectorList the selectors - * @param documentMode see {@link Document#getDocumentMode()} - * @param domNode the dom node the query should work on - * @throws CSSException if a selector is invalid - * - * @deprecated as of version 4.5.0; use {@link #validateSelectors(SelectorList, DomNode)} instead - */ - @Deprecated - public static void validateSelectors(final SelectorList selectorList, final int documentMode, - final DomNode domNode) throws CSSException { - for (final Selector selector : selectorList) { - if (!isValidSelector(selector, domNode)) { - throw new CSSException("Invalid selector: " + selector, null); - } - } - } - /** * Validates the list of selectors. * @param selectorList the selectors @@ -1224,7 +1205,8 @@ public static boolean isActive(final MediaListImpl mediaList, final WebWindow we return true; } - for (int i = 0; i < mediaList.getLength(); i++) { + final int length = mediaList.getLength(); + for (int i = 0; i < length; i++) { final MediaQuery mediaQuery = mediaList.mediaQuery(i); boolean isActive = isActive(mediaQuery, webWindow); if (mediaQuery.isNot()) { diff --git a/src/main/java/org/htmlunit/css/StyleAttributes.java b/src/main/java/org/htmlunit/css/StyleAttributes.java index 137da28391a..a41f839323e 100644 --- a/src/main/java/org/htmlunit/css/StyleAttributes.java +++ b/src/main/java/org/htmlunit/css/StyleAttributes.java @@ -32,9 +32,9 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.htmlunit.BrowserVersion; @@ -48,7 +48,7 @@ */ @SuppressWarnings("PMD.AvoidDuplicateLiterals") public final class StyleAttributes implements Serializable { - private static final Map STYLES = new HashMap<>(); + private static final Map STYLES = new ConcurrentHashMap<>(); static { for (final Definition definition : Definition.values()) { @@ -338,10 +338,10 @@ public enum Definition { BASELINE_SOURCE_("baseline-source", "baseline-source", ff("auto")), /** The style property {@code blockSize}. */ - BLOCK_SIZE("blockSize", "block-size", chromeAndEdge("324px"), ff("328px")), + BLOCK_SIZE("blockSize", "block-size", chromeAndEdgeAndFirefox("auto")), /** The style property {@code block-size}. */ - BLOCK_SIZE_("block-size", "block-size", ff("328px")), + BLOCK_SIZE_("block-size", "block-size", ff("auto")), /** The style property {@code border}. */ BORDER("border", "border", chromeAndEdge("0px none rgb(0, 0, 0)"), ff("0px rgb(0, 0, 0)")), @@ -1426,7 +1426,10 @@ public enum Definition { HYPHENATE_CHARACTER_("hyphenate-character", "hyphenate-character", ff("auto")), /** The style property {@code hyphenateLimitChars}. */ - HYPHENATE_LIMIT_CHAR("hyphenateLimitChars", "hyphenate-limit-char", chromeAndEdgeAuto()), + HYPHENATE_LIMIT_CHAR("hyphenateLimitChars", "hyphenate-limit-chars", chromeAndEdgeAuto(), ffLatest("auto")), + + /** The style property {@code hyphenate-limit-chars}. */ + HYPHENATE_LIMIT_CHAR_("hyphenate-limit-chars", "hyphenate-limit-chars", ffLatest("auto")), /** The style property {@code hyphens}. */ HYPHENS("hyphens", "hyphens", ff("manual"), chromeAndEdge("manual")), @@ -1505,6 +1508,9 @@ public enum Definition { /** The style property {@code inset-inline-start}. */ INSET_INLINE_START_("inset-inline-start", "inset-inline-start", ff("auto")), + /** The style property {@code interactivity}. */ + INTERACTIVITY("interactivity", "interpolate-size", chromeAndEdge("auto")), + /** The style property {@code interpolateSize}. */ INTERPOLATE_SIZE("interpolateSize", "interpolate-size", chromeAndEdge("numeric-only")), @@ -2084,10 +2090,10 @@ public enum Definition { MOZ_PERSPECTIVE__("-moz-perspective", "-moz-perspective", ffLatest("none")), /** The style property {@code MozPerspectiveOrigin}. */ - MOZ_PERSPECTIVE_ORIGIN("MozPerspectiveOrigin", "-moz-perspective-origin", ffLatest("620px 164px")), + MOZ_PERSPECTIVE_ORIGIN("MozPerspectiveOrigin", "-moz-perspective-origin", ffLatest("620px 9px")), /** The style property {@code -moz-perspective-origin}. */ - MOZ_PERSPECTIVE_ORIGIN__("-moz-perspective-origin", "-moz-perspective-origin", ffLatest("620px 164px")), + MOZ_PERSPECTIVE_ORIGIN__("-moz-perspective-origin", "-moz-perspective-origin", ffLatest("620px 9px")), /** The style property {@code MozTabSize}. */ MOZ_TAB_SIZE("MozTabSize", "-moz-tab-size", ff("8")), @@ -2119,11 +2125,11 @@ public enum Definition { /** The style property {@code MozTransformOrigin}. */ MOZ_TRANSFORM_ORIGIN("MozTransformOrigin", "-moz-transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code -moz-transform-origin}. */ MOZ_TRANSFORM_ORIGIN__("-moz-transform-origin", "-moz-transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code MozTransformStyle}. */ MOZ_TRANSFORM_STYLE("MozTransformStyle", "-moz-transform-style", ffLatest("flat")), @@ -2257,7 +2263,7 @@ public enum Definition { OVERFLOW_ANCHOR_("overflow-anchor", "overflow-anchor", ff("auto")), /** The style property {@code overflowBlock}. */ - OVERFLOW_BLOCK("overflowBlock", "overflow-block", ff("visible")), + OVERFLOW_BLOCK("overflowBlock", "overflow-block", chromeAndEdgeAndFirefox("visible")), /** The style property {@code overflow-block}. */ OVERFLOW_BLOCK_("overflow-block", "overflow-block", ff("visible")), @@ -2269,7 +2275,7 @@ public enum Definition { OVERFLOW_CLIP_MARGIN_("overflow-clip-margin", "overflow-clip-margin", ff("0px")), /** The style property {@code overflowInline}. */ - OVERFLOW_INLINE("overflowInline", "overflow-inline", ff("visible")), + OVERFLOW_INLINE("overflowInline", "overflow-inline", chromeAndEdgeAndFirefox("visible")), /** The style property {@code overflow-inline}. */ OVERFLOW_INLINE_("overflow-inline", "overflow-inline", ff("visible")), @@ -2433,10 +2439,11 @@ public enum Definition { /** The style property {@code perspectiveOrigin}. */ PERSPECTIVE_ORIGIN("perspectiveOrigin", "perspective-origin", - ffEsr("622px 164px"), ffLatest("620px 164px"), chrome("620px 162px"), edge("616px 162px")), + ffEsr("622px 9px"), ffLatest("620px 9px"), chrome("620px 9px"), edge("616px 9px")), /** The style property {@code perspective-origin}. */ - PERSPECTIVE_ORIGIN_("perspective-origin", "perspective-origin", ffEsr("622px 164px"), ffLatest("620px 164px")), + PERSPECTIVE_ORIGIN_("perspective-origin", "perspective-origin", + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code placeContent}. */ PLACE_CONTENT("placeContent", "place-content", chromeAndEdgeNormal(), ffNormal()), @@ -2619,6 +2626,9 @@ public enum Definition { /** The style property {@code scroll-margin-top}. */ SCROLL_MARGIN_TOP_("scroll-margin-top", "scroll-margin-top", ff("0px")), + /** The style property {@code scrollMarkerGroup}. */ + SCROLL_MARKER_GROUP("scrollMarkerGroup", "scroll-marker-group", chromeAndEdgeNone()), + /** The style property {@code scrollPadding}. */ SCROLL_PADDING("scrollPadding", "scroll-padding", chromeAndEdgeAuto(), ff("auto")), @@ -3062,10 +3072,10 @@ public enum Definition { /** The style property {@code transformOrigin}. */ TRANSFORM_ORIGIN("transformOrigin", "transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px"), chrome("620px 162px"), edge("616px 162px")), + ffEsr("622px 9px"), ffLatest("620px 9px"), chrome("620px 9px"), edge("616px 9px")), /** The style property {@code transform-origin}. */ - TRANSFORM_ORIGIN_("transform-origin", "transform-origin", ffEsr("622px 164px"), ffLatest("620px 164px")), + TRANSFORM_ORIGIN_("transform-origin", "transform-origin", ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code transformStyle}. */ TRANSFORM_STYLE("transformStyle", "transform-style", ff("flat"), chromeAndEdge("flat")), @@ -3706,7 +3716,7 @@ public enum Definition { WEBKIT_LOCALE("webkitLocale", "webkit-locale", chromeAndEdgeAuto()), /** The style property {@code webkitLogicalHeight}. */ - WEBKIT_LOGICAL_HEIGHT("webkitLogicalHeight", "webkit-logical-height", chromeAndEdge("324px")), + WEBKIT_LOGICAL_HEIGHT("webkitLogicalHeight", "webkit-logical-height", chromeAndEdge("18px")), /** The style property {@code webkitLogicalWidth}. */ WEBKIT_LOGICAL_WIDTH("webkitLogicalWidth", "webkit-logical-width", chrome("1240px"), edge("1232px")), @@ -3879,15 +3889,15 @@ public enum Definition { /** The style property {@code webkitPerspectiveOrigin}. */ WEBKIT_PERSPECTIVE_ORIGIN("webkitPerspectiveOrigin", "webkit-perspective-origin", - ffEsr("622px 164px"), ffLatest("620px 164px"), chrome("620px 162px"), edge("616px 162px")), + ffEsr("622px 9px"), ffLatest("620px 9px"), chrome("620px 9px"), edge("616px 9px")), /** The style property {@code WebkitPerspectiveOrigin}. */ WEBKIT_PERSPECTIVE_ORIGIN_("WebkitPerspectiveOrigin", "webkit-perspective-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code -webkit-perspective-origin}. */ WEBKIT_PERSPECTIVE_ORIGIN__("-webkit-perspective-origin", "webkit-perspective-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code webkitPerspectiveOriginX}. */ WEBKIT_PERSPECTIVE_ORIGIN_X("webkitPerspectiveOriginX", "webkit-perspective-origin-x", chromeAndEdgeEmpty()), @@ -4013,15 +4023,15 @@ public enum Definition { /** The style property {@code webkitTransformOrigin}. */ WEBKIT_TRANSFORM_ORIGIN("webkitTransformOrigin", "webkit-transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px"), chrome("620px 162px"), edge("616px 162px")), + ffEsr("622px 9px"), ffLatest("620px 9px"), chrome("620px 9px"), edge("616px 9px")), /** The style property {@code WebkitTransformOrigin}. */ WEBKIT_TRANSFORM_ORIGIN_("WebkitTransformOrigin", "webkit-transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code -webkit-transform-origin}. */ WEBKIT_TRANSFORM_ORIGIN__("-webkit-transform-origin", "webkit-transform-origin", - ffEsr("622px 164px"), ffLatest("620px 164px")), + ffEsr("622px 9px"), ffLatest("620px 9px")), /** The style property {@code webkitTransformOriginX}. */ WEBKIT_TRANSFORM_ORIGIN_X("webkitTransformOriginX", "webkit-transform-origin-x", chromeAndEdgeEmpty()), diff --git a/src/main/java/org/htmlunit/html/CharacterDataChangeListener.java b/src/main/java/org/htmlunit/html/CharacterDataChangeListener.java index fab5572b72b..d37c4ce833f 100644 --- a/src/main/java/org/htmlunit/html/CharacterDataChangeListener.java +++ b/src/main/java/org/htmlunit/html/CharacterDataChangeListener.java @@ -20,8 +20,10 @@ * Implementations of this interface receive notifications of changes to the Character Data. * * @author Ahmed Ashour + * @author Ronald Brill * @see CharacterDataChangeEvent */ +@FunctionalInterface public interface CharacterDataChangeListener extends Serializable { /** diff --git a/src/main/java/org/htmlunit/html/DomNode.java b/src/main/java/org/htmlunit/html/DomNode.java index 019fee9bbbb..bf6b80f8724 100644 --- a/src/main/java/org/htmlunit/html/DomNode.java +++ b/src/main/java/org/htmlunit/html/DomNode.java @@ -1120,7 +1120,8 @@ public void removeAllChildren() { * @throws SAXException in case of error */ public void parseHtmlSnippet(final String source) throws SAXException, IOException { - getPage().getWebClient().getPageCreator().getHtmlParser().parseFragment(this, source); + final WebClient webClient = getPage().getWebClient(); + webClient.getPageCreator().getHtmlParser().parseFragment(webClient, this, this, source, false); } /** @@ -1173,7 +1174,7 @@ else if (previousSibling_ != null && previousSibling_.nextSibling_ == this) { private void fireRemoval(final DomNode exParent) { final SgmlPage page = getPage(); - if (page != null && page instanceof HtmlPage) { + if (page instanceof HtmlPage) { // some actions executed on removal need an intact parent relationship (e.g. for the // DocumentPositionComparator) so we have to restore it temporarily parent_ = exParent; @@ -2296,9 +2297,6 @@ public DomElement closest(final String selectorString) { * An unmodifiable empty {@link NamedNodeMap} implementation. */ private static final class ReadOnlyEmptyNamedNodeMapImpl implements NamedNodeMap, Serializable { - private ReadOnlyEmptyNamedNodeMapImpl() { - super(); - } /** * {@inheritDoc} diff --git a/src/main/java/org/htmlunit/html/DomNodeIterator.java b/src/main/java/org/htmlunit/html/DomNodeIterator.java index 9424ff28139..2bedfb345c0 100644 --- a/src/main/java/org/htmlunit/html/DomNodeIterator.java +++ b/src/main/java/org/htmlunit/html/DomNodeIterator.java @@ -143,15 +143,7 @@ private DomNode traverse(final boolean next) { } else { if (beforeNode) { - final DomNode left = getSibling(node, true); - if (left == null) { - final Node parent = node.getParentNode(); - if (parent == null) { - node = null; - } - } - - DomNode follow = left; + DomNode follow = getSibling(node, true); if (follow != null) { while (follow.hasChildNodes()) { final DomNode toFollow = getChild(follow, false); diff --git a/src/main/java/org/htmlunit/html/Html.java b/src/main/java/org/htmlunit/html/Html.java index 9a00ceca549..d12ed2e2454 100644 --- a/src/main/java/org/htmlunit/html/Html.java +++ b/src/main/java/org/htmlunit/html/Html.java @@ -21,6 +21,9 @@ */ public final class Html { + /** The html5 doctype. */ + public static final String DOCTYPE_HTML = ""; + /** XHTML namespace. */ public static final String XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"; diff --git a/src/main/java/org/htmlunit/html/HtmlAnchor.java b/src/main/java/org/htmlunit/html/HtmlAnchor.java index 09a55e7ac38..ba42f1b9857 100644 --- a/src/main/java/org/htmlunit/html/HtmlAnchor.java +++ b/src/main/java/org/htmlunit/html/HtmlAnchor.java @@ -195,7 +195,7 @@ protected void doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey, target = page.getResolvedTarget(getTargetAttribute()); } page.getWebClient().download(page.getEnclosingWindow(), target, webRequest, - true, false, (ATTRIBUTE_NOT_DEFINED != downloadAttribute) ? downloadAttribute : null, "Link click"); + true, (ATTRIBUTE_NOT_DEFINED != downloadAttribute) ? downloadAttribute : null, "Link click"); } private boolean relContainsNoreferrer() { diff --git a/src/main/java/org/htmlunit/html/HtmlDomTreeWalker.java b/src/main/java/org/htmlunit/html/HtmlDomTreeWalker.java index e2db02a4411..0f6a9a7625e 100644 --- a/src/main/java/org/htmlunit/html/HtmlDomTreeWalker.java +++ b/src/main/java/org/htmlunit/html/HtmlDomTreeWalker.java @@ -26,7 +26,7 @@ * therefore we have this impl as backend. * * @see - * DOM-Level-2-Traversal-Range + * DOM-Level-2-Traversal-Range * @author Mike Dirolf * @author Frank Danek * @author Ahmed Ashour diff --git a/src/main/java/org/htmlunit/html/HtmlElement.java b/src/main/java/org/htmlunit/html/HtmlElement.java index d028fc6fa93..68034b78210 100644 --- a/src/main/java/org/htmlunit/html/HtmlElement.java +++ b/src/main/java/org/htmlunit/html/HtmlElement.java @@ -16,6 +16,9 @@ import static org.htmlunit.BrowserVersionFeatures.HTMLELEMENT_REMOVE_ACTIVE_TRIGGERS_BLUR_EVENT; import static org.htmlunit.BrowserVersionFeatures.KEYBOARD_EVENT_SPECIAL_KEYPRESS; +import static org.htmlunit.css.CssStyleSheet.ABSOLUTE; +import static org.htmlunit.css.CssStyleSheet.FIXED; +import static org.htmlunit.css.CssStyleSheet.STATIC; import java.io.IOException; import java.util.ArrayList; @@ -31,6 +34,8 @@ import org.htmlunit.SgmlPage; import org.htmlunit.WebAssert; import org.htmlunit.WebClient; +import org.htmlunit.WebWindow; +import org.htmlunit.css.ComputedCssStyleDeclaration; import org.htmlunit.html.impl.SelectableTextInput; import org.htmlunit.javascript.HtmlUnitScriptable; import org.htmlunit.javascript.host.dom.Document; @@ -191,17 +196,17 @@ protected void setAttributeNS(final String namespaceURI, final String qualifiedN final String attributeValue, final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) { + final HtmlPage htmlPage = getHtmlPageOrNull(); + // TODO: Clean up; this is a hack for HtmlElement living within an XmlPage. - if (null == getHtmlPageOrNull()) { + if (null == htmlPage) { super.setAttributeNS(namespaceURI, qualifiedName, attributeValue, notifyAttributeChangeListeners, notifyMutationObservers); return; } final String oldAttributeValue = getAttribute(qualifiedName); - final HtmlPage htmlPage = (HtmlPage) getPage(); final boolean mappedElement = isAttachedToPage() - && htmlPage != null && (DomElement.NAME_ATTRIBUTE.equals(qualifiedName) || DomElement.ID_ATTRIBUTE.equals(qualifiedName)); if (mappedElement) { // cast is save here because isMappedElement checks for HtmlPage @@ -287,12 +292,19 @@ private void fireAttributeChangeImpl(final HtmlAttributeChangeEvent event, */ @Override public Attr setAttributeNode(final Attr attribute) { + final HtmlPage htmlPage = getHtmlPageOrNull(); + + // TODO: Clean up; this is a hack for HtmlElement living within an XmlPage. + if (null == htmlPage) { + return super.setAttributeNode(attribute); + } + final String qualifiedName = attribute.getName(); final String oldAttributeValue = getAttribute(qualifiedName); - final HtmlPage htmlPage = (HtmlPage) getPage(); + final boolean mappedElement = isAttachedToPage() - && htmlPage != null - && (DomElement.NAME_ATTRIBUTE.equals(qualifiedName) || DomElement.ID_ATTRIBUTE.equals(qualifiedName)); + && (DomElement.NAME_ATTRIBUTE.equals(qualifiedName) + || DomElement.ID_ATTRIBUTE.equals(qualifiedName)); if (mappedElement) { htmlPage.removeMappedElement(this, false, false); } @@ -325,23 +337,28 @@ public void removeAttribute(final String attributeName) { } final HtmlPage htmlPage = getHtmlPageOrNull(); - final boolean mapped = htmlPage != null - && (DomElement.NAME_ATTRIBUTE.equals(attributeName) || DomElement.ID_ATTRIBUTE.equals(attributeName)); + + // TODO: Clean up; this is a hack for HtmlElement living within an XmlPage. + if (null == htmlPage) { + super.removeAttribute(attributeName); + return; + } + + final boolean mapped = DomElement.NAME_ATTRIBUTE.equals(attributeName) + || DomElement.ID_ATTRIBUTE.equals(attributeName); if (mapped) { htmlPage.removeMappedElement(this, false, false); } super.removeAttribute(attributeName); - if (htmlPage != null) { - if (mapped) { - htmlPage.addMappedElement(this, false); - } - - final HtmlAttributeChangeEvent event = new HtmlAttributeChangeEvent(this, attributeName, value); - fireHtmlAttributeRemoved(event); - htmlPage.fireHtmlAttributeRemoved(event); + if (mapped) { + htmlPage.addMappedElement(this, false); } + + final HtmlAttributeChangeEvent event = new HtmlAttributeChangeEvent(this, attributeName, value); + fireHtmlAttributeRemoved(event); + htmlPage.fireHtmlAttributeRemoved(event); } /** @@ -662,7 +679,8 @@ public Page type(final Keyboard keyboard) throws IOException { } } - for (int i = 0; i < keys.size(); i++) { + final int size = keys.size(); + for (int i = 0; i < size; i++) { final Object[] entry = keys.get(i); if (entry.length == 1) { type((char) entry[0], i == keys.size() - 1); @@ -1423,6 +1441,186 @@ public void setRequired(final boolean required) { } } + /** + * INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
+ * + * @param returnNullIfFixed if position is 'fixed' return null + * @return the offset parent {@link HtmlElement} + */ + public HtmlElement getOffsetParentInternal(final boolean returnNullIfFixed) { + if (getParentNode() == null) { + return null; + } + + final WebWindow webWindow = getPage().getEnclosingWindow(); + final ComputedCssStyleDeclaration style = webWindow.getComputedStyle(this, null); + final String position = style.getPositionWithInheritance(); + + if (returnNullIfFixed && FIXED.equals(position)) { + return null; + } + + final boolean staticPos = STATIC.equals(position); + + DomNode currentElement = this; + while (currentElement != null) { + + final DomNode parentNode = currentElement.getParentNode(); + if (parentNode instanceof HtmlBody + || (staticPos && parentNode instanceof HtmlTableDataCell) + || (staticPos && parentNode instanceof HtmlTable)) { + return (HtmlElement) parentNode; + } + + if (parentNode instanceof HtmlElement) { + final ComputedCssStyleDeclaration parentStyle = + webWindow.getComputedStyle((HtmlElement) parentNode, null); + final String parentPosition = parentStyle.getPositionWithInheritance(); + if (!STATIC.equals(parentPosition)) { + return (HtmlElement) parentNode; + } + } + + currentElement = currentElement.getParentNode(); + } + + return null; + } + + /** + * @return this element's top offset, which is the calculated left position of this + * element relative to the offsetParent. + */ + public int getOffsetTop() { + if (this instanceof HtmlBody) { + return 0; + } + + int top = 0; + + // Add the offset for this node. + final WebWindow webWindow = getPage().getEnclosingWindow(); + ComputedCssStyleDeclaration style = webWindow.getComputedStyle(this, null); + top += style.getTop(true, false, false); + + // If this node is absolutely positioned, we're done. + final String position = style.getPositionWithInheritance(); + if (ABSOLUTE.equals(position) || FIXED.equals(position)) { + return top; + } + + final HtmlElement offsetParent = getOffsetParentInternal(false); + + // Add the offset for the ancestor nodes. + DomNode parentNode = getParentNode(); + while (parentNode != null && parentNode != offsetParent) { + if (parentNode instanceof HtmlElement) { + style = webWindow.getComputedStyle((HtmlElement) parentNode, null); + top += style.getTop(false, true, true); + } + parentNode = parentNode.getParentNode(); + } + + if (offsetParent != null) { + style = webWindow.getComputedStyle(this, null); + final boolean thisElementHasTopMargin = style.getMarginTopValue() != 0; + + style = webWindow.getComputedStyle(offsetParent, null); + if (!thisElementHasTopMargin) { + top += style.getMarginTopValue(); + } + top += style.getPaddingTopValue(); + } + + return top; + } + + /** + * @return this element's left offset, which is the calculated left position of this + * element relative to the offsetParent. + */ + public int getOffsetLeft() { + if (this instanceof HtmlBody) { + return 0; + } + + int left = 0; + + // Add the offset for this node. + final WebWindow webWindow = getPage().getEnclosingWindow(); + ComputedCssStyleDeclaration style = webWindow.getComputedStyle(this, null); + left += style.getLeft(true, false, false); + + // If this node is absolutely positioned, we're done. + final String position = style.getPositionWithInheritance(); + if (ABSOLUTE.equals(position) || FIXED.equals(position)) { + return left; + } + + final HtmlElement offsetParent = getOffsetParentInternal(false); + + DomNode parentNode = getParentNode(); + while (parentNode != null && parentNode != offsetParent) { + if (parentNode instanceof HtmlElement) { + style = webWindow.getComputedStyle((HtmlElement) parentNode, null); + left += style.getLeft(true, true, true); + } + parentNode = parentNode.getParentNode(); + } + + if (offsetParent != null) { + style = webWindow.getComputedStyle(offsetParent, null); + left += style.getMarginLeftValue(); + left += style.getPaddingLeftValue(); + } + + return left; + } + + /** + * Returns this element's X position. + * @return this element's X position + */ + public int getPosX() { + int cumulativeOffset = 0; + final WebWindow webWindow = getPage().getEnclosingWindow(); + + HtmlElement element = this; + while (element != null) { + cumulativeOffset += element.getOffsetLeft(); + if (element != this) { + final ComputedCssStyleDeclaration style = + webWindow.getComputedStyle(element, null); + cumulativeOffset += style.getBorderLeftValue(); + } + element = element.getOffsetParentInternal(false); + } + + return cumulativeOffset; + } + + /** + * Returns this element's Y position. + * @return this element's Y position + */ + public int getPosY() { + int cumulativeOffset = 0; + final WebWindow webWindow = getPage().getEnclosingWindow(); + + HtmlElement element = this; + while (element != null) { + cumulativeOffset += element.getOffsetTop(); + if (element != this) { + final ComputedCssStyleDeclaration style = + webWindow.getComputedStyle(element, null); + cumulativeOffset += style.getBorderTopValue(); + } + element = element.getOffsetParentInternal(false); + } + + return cumulativeOffset; + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/htmlunit/html/HtmlForm.java b/src/main/java/org/htmlunit/html/HtmlForm.java index fdb07d5c743..dd7797388f3 100644 --- a/src/main/java/org/htmlunit/html/HtmlForm.java +++ b/src/main/java/org/htmlunit/html/HtmlForm.java @@ -191,7 +191,7 @@ && getAttributeDirect(ATTRIBUTE_NOVALIDATE) != ATTRIBUTE_NOT_DEFINED) { final WebWindow webWindow = htmlPage.getEnclosingWindow(); // Calling form.submit() twice forces double download. - webClient.download(webWindow, target, request, false, false, null, "JS form.submit()"); + webClient.download(webWindow, target, request, false, null, "JS form.submit()"); } /** @@ -541,28 +541,9 @@ private List getFormElementsByAttribute( final String attributeName, final String attributeValue) { - final List list = new ArrayList<>(); - final String lowerCaseTagName = elementName.toLowerCase(Locale.ROOT); - - for (final HtmlElement element : getElements()) { - if (element.getTagName().equals(lowerCaseTagName)) { - final String attValue = element.getAttribute(attributeName); - if (attValue.equals(attributeValue)) { - list.add((E) element); - } - } - } - return list; - } - - /** - * @return returns a list of all form controls contained in the <form> element or referenced by formId - * but ignoring elements that are contained in a nested form - * @deprecated as of version 4.4.0; use {@link #getFormElements()}, {@link #getElementsJS()} instead - */ - @Deprecated - public List getElements() { - return getElements(htmlElement -> SUBMITTABLE_TAG_NAMES.contains(htmlElement.getTagName())); + return (List) getElements(htmlElement -> + htmlElement.getTagName().equals(elementName) + && htmlElement.getAttribute(attributeName).equals(attributeValue)); } /** diff --git a/src/main/java/org/htmlunit/html/HtmlImage.java b/src/main/java/org/htmlunit/html/HtmlImage.java index 0695114fa4b..ec90e4aa4f4 100644 --- a/src/main/java/org/htmlunit/html/HtmlImage.java +++ b/src/main/java/org/htmlunit/html/HtmlImage.java @@ -47,7 +47,6 @@ import org.htmlunit.javascript.host.dom.Document; import org.htmlunit.javascript.host.event.Event; import org.htmlunit.javascript.host.event.MouseEvent; -import org.htmlunit.javascript.host.html.HTMLElement; import org.htmlunit.platform.Platform; import org.htmlunit.platform.geom.IntDimension2D; import org.htmlunit.platform.image.ImageData; @@ -876,12 +875,11 @@ public String getLocalName() { public ScriptResult fireEvent(final Event event) { if (event instanceof MouseEvent) { final MouseEvent mouseEvent = (MouseEvent) event; - final HTMLElement scriptableObject = getScriptableObject(); if (lastClickX_ >= 0) { - mouseEvent.setClientX(scriptableObject.getPosX() + lastClickX_); + mouseEvent.setClientX(getPosX() + lastClickX_); } if (lastClickY_ >= 0) { - mouseEvent.setClientY(scriptableObject.getPosX() + lastClickY_); + mouseEvent.setClientY(getPosX() + lastClickY_); } } diff --git a/src/main/java/org/htmlunit/html/HtmlOption.java b/src/main/java/org/htmlunit/html/HtmlOption.java index 12438877c9e..c0dda178ab6 100644 --- a/src/main/java/org/htmlunit/html/HtmlOption.java +++ b/src/main/java/org/htmlunit/html/HtmlOption.java @@ -224,7 +224,7 @@ public final void setLabelAttribute(final String newLabel) { * HTML 4.01 * documentation for details on the use of this attribute. * @see - * initial value if value attribute is not set + * initial value if value attribute is not set * @return the value of the attribute {@code value} */ public final String getValueAttribute() { diff --git a/src/main/java/org/htmlunit/html/HtmlPage.java b/src/main/java/org/htmlunit/html/HtmlPage.java index a52a241cb47..a3a8547a386 100644 --- a/src/main/java/org/htmlunit/html/HtmlPage.java +++ b/src/main/java/org/htmlunit/html/HtmlPage.java @@ -139,6 +139,7 @@ * @author Lai Quang Duong * @author Sven Strickroth */ +@SuppressWarnings("PMD.TooManyFields") public class HtmlPage extends SgmlPage { private static final Log LOG = LogFactory.getLog(HtmlPage.class); @@ -923,7 +924,7 @@ public ScriptResult executeJavaScript(final String sourceCode) { *

Please note: Although this method is public, it is not intended for * general execution of JavaScript. Users of HtmlUnit should interact with the pages * as a user would by clicking on buttons or links and having the JavaScript event - * handlers execute as needed.. + * handlers execute as needed. *

* * @param sourceCode the JavaScript code to execute @@ -2874,7 +2875,7 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot } private static final class MappedElementIndexEntry implements Serializable { - private ArrayList elements_; + private final ArrayList elements_; private boolean sorted_; MappedElementIndexEntry() { diff --git a/src/main/java/org/htmlunit/html/HtmlTable.java b/src/main/java/org/htmlunit/html/HtmlTable.java index a656ed38ebb..9d62e33c804 100644 --- a/src/main/java/org/htmlunit/html/HtmlTable.java +++ b/src/main/java/org/htmlunit/html/HtmlTable.java @@ -91,9 +91,11 @@ public final HtmlTableCell getCellAt(final int rowIndex, final int columnIndex) return cell; } } - if (cell.getRowSpan() > 1 || cell.getColumnSpan() > 1) { - for (int i = 0; i < cell.getRowSpan(); i++) { - for (int j = 0; j < cell.getColumnSpan(); j++) { + final int rowSpan = cell.getRowSpan(); + final int columnSpan = cell.getColumnSpan(); + if (rowSpan > 1 || columnSpan > 1) { + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { occupied.add(new Position(row + i, col + j)); } } diff --git a/src/main/java/org/htmlunit/html/HtmlTableCell.java b/src/main/java/org/htmlunit/html/HtmlTableCell.java index 7225fda0abd..591a495729e 100644 --- a/src/main/java/org/htmlunit/html/HtmlTableCell.java +++ b/src/main/java/org/htmlunit/html/HtmlTableCell.java @@ -14,8 +14,6 @@ */ package org.htmlunit.html; -import static org.htmlunit.BrowserVersionFeatures.JS_TABLE_SPAN_SET_ZERO_IF_INVALID; - import java.util.Map; import org.apache.commons.lang3.StringUtils; @@ -80,18 +78,11 @@ public int getRowSpan() { } try { final int span = (int) Double.parseDouble(spanString); - if (getPage().getWebClient().getBrowserVersion().hasFeature(JS_TABLE_SPAN_SET_ZERO_IF_INVALID)) { - if (span < 0) { - return 1; - } - if (span < 1) { - return 0; - } + if (span < 0) { + return 1; } - else { - if (span < 1) { - return 1; - } + if (span < 1) { + return 0; } if (span > 65_534) { diff --git a/src/main/java/org/htmlunit/html/parser/HTMLParser.java b/src/main/java/org/htmlunit/html/parser/HTMLParser.java index adeafefec45..4c56579a337 100644 --- a/src/main/java/org/htmlunit/html/parser/HTMLParser.java +++ b/src/main/java/org/htmlunit/html/parser/HTMLParser.java @@ -17,6 +17,7 @@ import java.io.IOException; import org.htmlunit.SgmlPage; +import org.htmlunit.WebClient; import org.htmlunit.WebResponse; import org.htmlunit.html.DomNode; import org.htmlunit.html.ElementFactory; @@ -75,12 +76,19 @@ ElementFactory getElementFactory(SgmlPage page, String namespaceURI, * @param source the (X)HTML to be parsed * @throws SAXException if a SAX error occurs * @throws IOException if an IO error occurs + * + * @deprecated as of version 4.12.0; use + * {@link #parseFragment(WebClient, DomNode, DomNode, String, boolean)} instead. */ - void parseFragment(DomNode parent, String source) throws SAXException, IOException; + @Deprecated + default void parseFragment(DomNode parent, String source) throws SAXException, IOException { + parseFragment(null, parent, parent, source, false); + } /** * Parses the HTML content from the given string into an object tree representation. * + * @param webClient the {@link WebClient} * @param parent where the new parsed nodes will be added to * @param context the context to build the fragment context stack * @param source the (X)HTML to be parsed @@ -88,9 +96,41 @@ ElementFactory getElementFactory(SgmlPage page, String namespaceURI, * @throws SAXException if a SAX error occurs * @throws IOException if an IO error occurs */ - void parseFragment(DomNode parent, DomNode context, String source, + void parseFragment(WebClient webClient, DomNode parent, DomNode context, String source, boolean createdByJavascript) throws SAXException, IOException; + /** + * Parses the HTML content from the given string into an object tree representation. + * + * @param parent where the new parsed nodes will be added to + * @param context the context to build the fragment context stack + * @param source the (X)HTML to be parsed + * @param createdByJavascript if true the (script) tag was created by javascript + * @throws SAXException if a SAX error occurs + * @throws IOException if an IO error occurs + * + * @deprecated as of version 4.12.0; use + * {@link #parseFragment(WebClient, DomNode, DomNode, String, boolean)} instead. + */ + @Deprecated + default void parseFragment(DomNode parent, DomNode context, String source, + boolean createdByJavascript) throws SAXException, IOException { + parseFragment(null, parent, context, source, createdByJavascript); + } + + /** + * Parses the WebResponse into an object tree representation. + * + * @param webClient the {@link WebClient} + * @param webResponse the response data + * @param page the HtmlPage to add the nodes + * @param xhtml if true use the XHtml parser + * @param createdByJavascript if true the (script) tag was created by javascript + * @throws IOException if there is an IO error + */ + void parse(WebClient webClient, WebResponse webResponse, HtmlPage page, + boolean xhtml, boolean createdByJavascript) throws IOException; + /** * Parses the WebResponse into an object tree representation. * @@ -99,6 +139,12 @@ void parseFragment(DomNode parent, DomNode context, String source, * @param xhtml if true use the XHtml parser * @param createdByJavascript if true the (script) tag was created by javascript * @throws IOException if there is an IO error + * + * @deprecated as of version 4.12.0; use + * {@link #parse(WebClient, WebResponse, HtmlPage, boolean, boolean)} instead. */ - void parse(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript) throws IOException; + @Deprecated + default void parse(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript) throws IOException { + parse(null, webResponse, page, xhtml, createdByJavascript); + } } diff --git a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java index 6c40cb36074..7a601eff1f2 100644 --- a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java +++ b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java @@ -21,14 +21,15 @@ import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.htmlunit.ObjectInstantiationException; import org.htmlunit.Page; import org.htmlunit.SgmlPage; import org.htmlunit.WebAssert; +import org.htmlunit.WebClient; import org.htmlunit.WebResponse; import org.htmlunit.cyberneko.HTMLScanner; import org.htmlunit.cyberneko.HTMLTagBalancer; @@ -73,7 +74,7 @@ public final class HtmlUnitNekoHtmlParser implements HTMLParser { */ public static final SvgElementFactory SVG_FACTORY = new SvgElementFactory(); - private static final Map ELEMENT_FACTORIES = new HashMap<>(); + private static final Map ELEMENT_FACTORIES = new ConcurrentHashMap<>(); static { final DefaultElementFactory defaultElementFactory = new DefaultElementFactory(); @@ -83,30 +84,10 @@ public final class HtmlUnitNekoHtmlParser implements HTMLParser { } /** - * Parses the HTML content from the given string into an object tree representation. - * - * @param parent the parent for the new nodes - * @param source the (X)HTML to be parsed - * @throws SAXException if a SAX error occurs - * @throws IOException if an IO error occurs + *{@inheritDoc} */ @Override - public void parseFragment(final DomNode parent, final String source) throws SAXException, IOException { - parseFragment(parent, parent, source, false); - } - - /** - * Parses the HTML content from the given string into an object tree representation. - * - * @param parent where the new parsed nodes will be added to - * @param context the context to build the fragment context stack - * @param source the (X)HTML to be parsed - * @param createdByJavascript if true the (script) tag was created by javascript - * @throws SAXException if a SAX error occurs - * @throws IOException if an IO error occurs - */ - @Override - public void parseFragment(final DomNode parent, final DomNode context, final String source, + public void parseFragment(final WebClient webClient, final DomNode parent, final DomNode context, final String source, final boolean createdByJavascript) throws SAXException, IOException { final Page page = parent.getPage(); @@ -153,16 +134,10 @@ else if (ancestors.size() == 1 } /** - * Parses the WebResponse into an object tree representation. - * - * @param webResponse the response data - * @param page the HtmlPage to add the nodes - * @param xhtml if true use the XHtml parser - * @param createdByJavascript if true the (script) tag was created by javascript - * @throws IOException if there is an IO error + * {@inheritDoc} */ @Override - public void parse(final WebResponse webResponse, final HtmlPage page, + public void parse(final WebClient webClient, final WebResponse webResponse, final HtmlPage page, final boolean xhtml, final boolean createdByJavascript) throws IOException { final URL url = webResponse.getWebRequest().getUrl(); final HtmlUnitNekoDOMBuilder domBuilder = @@ -182,6 +157,13 @@ public void parse(final WebResponse webResponse, final HtmlPage page, domBuilder.setFeature(HTMLScanner.STYLE_STRIP_CDATA_DELIMS, true); domBuilder.setFeature(HTMLScanner.CDATA_EARLY_CLOSING, false); } + + if (webClient != null) { + final int bufferSize = webClient.getOptions().getNekoReaderBufferSize(); + if (bufferSize > 0) { + domBuilder.setProperty(HTMLScanner.READER_BUFFER_SIZE, bufferSize); + } + } } catch (final Exception e) { throw new ObjectInstantiationException("Error setting HTML parser feature", e); diff --git a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java index b57f2f485a5..435a3d22201 100644 --- a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java +++ b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java @@ -512,9 +512,7 @@ protected void appendSelect(final HtmlSerializerTextBuilder builder, */ protected void appendOption(final HtmlSerializerTextBuilder builder, final HtmlOption htmlOption, final Mode mode) { - builder.ignoreHtmlBreaks(); appendChildren(builder, htmlOption, mode); - builder.processHtmlBreaks(); } /** @@ -787,7 +785,6 @@ private enum State { private final StringBuilder builder_; private int trimRightPos_; private boolean contentAdded_; - private boolean ignoreHtmlBreaks_; /** * Ctor. @@ -985,10 +982,6 @@ public void appendBlockSeparator() { * @param mode the {@link Mode} */ public void appendBreak(final Mode mode) { - if (ignoreHtmlBreaks_) { - return; - } - builder_.setLength(trimRightPos_); builder_.append('\n'); @@ -1046,20 +1039,6 @@ public void resetContentAdded() { contentAdded_ = false; } - /** - * Ignore the following html breaks in the content to be added. - */ - public void ignoreHtmlBreaks() { - ignoreHtmlBreaks_ = true; - } - - /** - * Prozess the following html breaks in the content to be added. - */ - public void processHtmlBreaks() { - ignoreHtmlBreaks_ = false; - } - /** * @return the constructed text. */ diff --git a/src/main/java/org/htmlunit/html/xpath/XPathAdapter.java b/src/main/java/org/htmlunit/html/xpath/XPathAdapter.java index ade9c47c8b8..203c0cc72da 100644 --- a/src/main/java/org/htmlunit/html/xpath/XPathAdapter.java +++ b/src/main/java/org/htmlunit/html/xpath/XPathAdapter.java @@ -45,14 +45,6 @@ private enum STATE { } private final Expression mainExp_; - private FunctionTable funcTable_; - - /** - * Initiates the function table. - */ - private void initFunctionTable() { - funcTable_ = new FunctionTable(); - } /** * Constructor. @@ -64,11 +56,9 @@ private void initFunctionTable() { public XPathAdapter(final String exprString, final PrefixResolver prefixResolver, final boolean caseSensitive) throws TransformerException { - initFunctionTable(); - final ErrorListener errorHandler = new DefaultErrorHandler(); final XPathParser parser = new XPathParser(errorHandler); - final Compiler compiler = new Compiler(errorHandler, funcTable_); + final Compiler compiler = new Compiler(errorHandler, new FunctionTable()); final String expression = preProcessXPath(exprString, caseSensitive); parser.initXPath(compiler, expression, prefixResolver); diff --git a/src/main/java/org/htmlunit/html/xpath/XPathHelper.java b/src/main/java/org/htmlunit/html/xpath/XPathHelper.java index e7e675ff736..881058edc74 100644 --- a/src/main/java/org/htmlunit/html/xpath/XPathHelper.java +++ b/src/main/java/org/htmlunit/html/xpath/XPathHelper.java @@ -112,7 +112,8 @@ public static List getByXPath(final Node node, final XPathAdapter xpath, if (result instanceof XNodeSet) { final NodeList nodelist = result.nodelist(); - for (int i = 0; i < nodelist.getLength(); i++) { + final int length = nodelist.getLength(); + for (int i = 0; i < length; i++) { list.add((T) nodelist.item(i)); } } diff --git a/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java b/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java index 893ec8bf758..fce1220057f 100644 --- a/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java +++ b/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java @@ -223,7 +223,8 @@ public List
formatCookies(final List cookies) { final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size()); buffer.append(SM.COOKIE); buffer.append(": "); - for (int i = 0; i < cookies.size(); i++) { + final int size = cookies.size(); + for (int i = 0; i < size; i++) { final Cookie cookie = cookies.get(i); if (i > 0) { buffer.append("; "); diff --git a/src/main/java/org/htmlunit/javascript/HtmlUnitScriptable.java b/src/main/java/org/htmlunit/javascript/HtmlUnitScriptable.java index 1ac52788f88..608f982b3e0 100644 --- a/src/main/java/org/htmlunit/javascript/HtmlUnitScriptable.java +++ b/src/main/java/org/htmlunit/javascript/HtmlUnitScriptable.java @@ -117,22 +117,17 @@ public void put(final String name, final Scriptable start, final Object value) { /** * Gets a named property from the object. * Normally HtmlUnit objects don't need to overwrite this method as properties are defined - * on the prototypes from the XML configuration. In some cases where "content" of object + * on the prototypes. In some cases where "content" of object * has priority compared to the properties consider using utility {@link #getWithPreemption(String)}. + * * {@inheritDoc} */ @Override public Object get(final String name, final Scriptable start) { // Try to get property configured on object itself. - Object response = super.get(name, start); - if (response != NOT_FOUND) { - return response; - } - if (this == start) { - response = getWithPreemption(name); - } - if (response == NOT_FOUND && start instanceof Window) { - response = ((Window) start).getWithFallback(name); + final Object response = super.get(name, start); + if (response == NOT_FOUND && this == start) { + return getWithPreemption(name); } return response; } diff --git a/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java b/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java index 9b93756300f..7d299d2301c 100644 --- a/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java +++ b/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java @@ -103,7 +103,7 @@ * @author Sven Strickroth * * @see - * Rhino and Java Browser + * Rhino and Java Browser */ public class JavaScriptEngine implements AbstractJavaScriptEngine\n" + + ""; + loadPageVerifyTitle2(html); + } + /** * @throws Exception if the test fails */ diff --git a/src/test/java/org/htmlunit/javascript/host/Window2Test.java b/src/test/java/org/htmlunit/javascript/host/Window2Test.java index 6fa0044ee54..1f77e8c5da4 100644 --- a/src/test/java/org/htmlunit/javascript/host/Window2Test.java +++ b/src/test/java/org/htmlunit/javascript/host/Window2Test.java @@ -1126,7 +1126,7 @@ public void changeHeightsAndWidths() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = {"621", "1256", "604", "1239"}, + @Alerts(CHROME = {"621", "1256", "606", "1241"}, EDGE = {"630", "1248", "615", "1233"}, FF = {"675", "1256", "658", "1239"}, FF_ESR = {"677", "1260", "660", "1243"}) diff --git a/src/test/java/org/htmlunit/javascript/host/Window3Test.java b/src/test/java/org/htmlunit/javascript/host/Window3Test.java index 274d52b1e2e..f51952b5776 100644 --- a/src/test/java/org/htmlunit/javascript/host/Window3Test.java +++ b/src/test/java/org/htmlunit/javascript/host/Window3Test.java @@ -482,7 +482,8 @@ public void scrollBy() throws Exception { + "\n" + + "\n" + + "\n" + ""; loadPageVerifyTitle2(html); } @@ -491,7 +492,7 @@ public void scrollBy() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"document", "body"}) + @Alerts({"document [object HTMLDocument]", "body", "window [object HTMLDocument]"}) public void scrollByEvents() throws Exception { final String html = DOCTYPE_HTML + "\n" @@ -499,7 +500,9 @@ public void scrollByEvents() throws Exception { + "\n" @@ -575,7 +578,7 @@ public void scrollTo() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"document", "body"}) + @Alerts({"document[object HTMLDocument]", "body", "document[object HTMLDocument]"}) public void scrollToEvents() throws Exception { final String html = DOCTYPE_HTML + "\n" @@ -583,7 +586,8 @@ public void scrollToEvents() throws Exception { + "\n" @@ -1214,6 +1218,8 @@ public void detachEventInAttachEvent() throws Exception { @Test @Alerts({"window.name before: ", "window.name after: main"}) public void windowName() throws Exception { + shutDownAll(); + final String html = DOCTYPE_HTML + "\n" + "\n" diff --git a/src/test/java/org/htmlunit/javascript/host/WindowConcurrencyTest.java b/src/test/java/org/htmlunit/javascript/host/WindowConcurrencyTest.java index 351aab37d5c..a23f2bedfa2 100644 --- a/src/test/java/org/htmlunit/javascript/host/WindowConcurrencyTest.java +++ b/src/test/java/org/htmlunit/javascript/host/WindowConcurrencyTest.java @@ -308,8 +308,7 @@ public void nestedSetTimeoutAboveMaxPriority() throws Exception { /** * Regression test for bug #693 with clearInterval. - * @see - * bug details + * @see bug details * @throws Exception if the test fails */ @Test @@ -319,8 +318,7 @@ public void clearInterval_threadInterrupt() throws Exception { /** * Regression test for bug #2093370 with clearTimeout. - * @see - * bug details + * @see bug details * @throws Exception if the test fails */ @Test diff --git a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.java b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.java index 1b4b352c3f6..c9fbe41af59 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.java +++ b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.java @@ -17,7 +17,6 @@ import org.htmlunit.WebDriverTestCase; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.annotation.Alerts; -import org.htmlunit.junit.annotation.HtmlUnitNYI; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -105,7 +104,10 @@ function test() { * @throws Exception if the test fails */ @Test - @Alerts({"success", "success", "success", "success"}) + @Alerts({"bottom: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "left: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "right: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "top: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}) public void width_like_properties() throws Exception { width_like_properties("bottom", "left", "right", "top"); } @@ -114,8 +116,10 @@ public void width_like_properties() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"borderBottomWidth 42% - 42em", "borderLeftWidth 42% - 42em", - "borderRightWidth 42% - 42em", "borderTopWidth 42% - 42em"}) + @Alerts({"borderBottomWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "borderLeftWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "borderRightWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "borderTopWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]"}) public void width_like_properties_border() throws Exception { width_like_properties("borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth"); } @@ -124,7 +128,10 @@ public void width_like_properties_border() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"success", "success", "success", "success"}) + @Alerts({"marginBottom: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "marginLeft: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "marginRight: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "marginTop: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}) public void width_like_properties_margin() throws Exception { width_like_properties("marginBottom", "marginLeft", "marginRight", "marginTop"); } @@ -133,7 +140,10 @@ public void width_like_properties_margin() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"success", "success", "success", "success"}) + @Alerts({"paddingBottom: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "paddingLeft: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "paddingRight: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "paddingTop: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}) public void width_like_properties_padding() throws Exception { width_like_properties("paddingBottom", "paddingLeft", "paddingRight", "paddingTop"); } @@ -142,7 +152,12 @@ public void width_like_properties_padding() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"success", "success", "success", "success", "success", "success"}) + @Alerts({"height: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "width: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "maxHeight: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "maxWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "minHeight: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "minWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}) public void width_like_properties_heightWidth() throws Exception { width_like_properties("height", "width", "maxHeight", "maxWidth", "minHeight", "minWidth"); } @@ -151,26 +166,24 @@ public void width_like_properties_heightWidth() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = {"success", "letterSpacing 42% - 42em", - "outlineWidth 42.0 - ; 42.7 - ; 42 - ; 42% - 42em", - "success", - "success", - "wordSpacing 42% - 42em"}, - FF = {"success", "success", - "outlineWidth 42.0 - ; 42.7 - ; 42 - ; 42% - 42em", - "success", - "success", - "success"}, - FF_ESR = {"success", "letterSpacing 42% - 42em", - "outlineWidth 42.0 - ; 42.7 - ; 42 - ; 42% - 42em", - "success", - "success", - "success"}) - @HtmlUnitNYI(FF = {"success", "letterSpacing 42% - 42em", - "outlineWidth 42.0 - ; 42.7 - ; 42 - ; 42% - 42em", - "success", - "success", - "success"}) + @Alerts(DEFAULT = {"fontSize: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "letterSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "outlineWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "textIndent: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "verticalAlign: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "wordSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]"}, + FF = {"fontSize: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "letterSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "outlineWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "textIndent: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "verticalAlign: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "wordSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}, + FF_ESR = {"fontSize: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "letterSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "outlineWidth: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42em]", + "textIndent: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "verticalAlign: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]", + "wordSpacing: initial [] 42.0 [] 42.7 [] 42 [] 42px [42px] 42mm [42mm] 42em [42em] 42% [42%]"}) public void width_like_properties_font() throws Exception { width_like_properties("fontSize", "letterSpacing", "outlineWidth", "textIndent", "verticalAlign", "wordSpacing"); @@ -186,58 +199,33 @@ private void width_like_properties(final String... properties) throws Exception + "\n" + " for (var prop in properties) {\n" + " prop = properties[prop];\n" - + " var result = '';\n" + + " var result = prop + ':';\n" + " var node = document.createElement('div');\n" - + " if (node.style[prop] != '') {\n" - + " if (result == '') { result += prop } else { result += '; ' }\n" - + " result += ' initial ' + node.style[prop];\n" - + " }\n" + + " result += ' initial [' + node.style[prop] + ']';\n" + " node.style[prop] = '42.0';\n" - + " if (node.style[prop] != '42px') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42.0 - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42.0 [' + node.style[prop] + ']';\n" + " node.style[prop] = '42.7';\n" - + " var expected = document.all ? '42px' : '42.7px';\n" - + " if (node.style[prop] != expected) {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42.7 - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42.7 [' + node.style[prop] + ']';\n" + " node.style[prop] = '42';\n" - + " if (node.style[prop] != '42px') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42 - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42 [' + node.style[prop] + ']';\n" + " node.style[prop] = '42px';\n" - + " if (node.style[prop] != '42px') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42px - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42px [' + node.style[prop] + ']';\n" + " node.style[prop] = '42mm';\n" - + " if (node.style[prop] != '42mm') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42mm - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42mm [' + node.style[prop] + ']';\n" + " node.style[prop] = '42em';\n" - + " if (node.style[prop] != '42em') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42em - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42em [' + node.style[prop] + ']';\n" + " node.style[prop] = '42%';\n" - + " if (node.style[prop] != '42%') {\n" - + " if (result == '') { result += prop } else { result += ';' }\n" - + " result += ' 42% - ' + node.style[prop];\n" - + " }\n" + + " result += ' 42% [' + node.style[prop] + ']';\n" - + " log(result == '' ? 'success' : result);\n" + + " log(result);\n" + " }\n" + "}\n" + "\n" diff --git a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java index 6c150a6f09b..07db10ed8d1 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java @@ -2214,7 +2214,7 @@ private void setPropertyBackgroundColor(final String params, final String... exp * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setWidthProperty() throws Exception { setLengthProperty("width", "width"); @@ -2224,7 +2224,7 @@ public void setWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setWidth() throws Exception { setLength("width", "width"); @@ -2234,7 +2234,7 @@ public void setWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setHeightProperty() throws Exception { setLengthProperty("height", "height"); @@ -2244,7 +2244,7 @@ public void setHeightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setHeight() throws Exception { setLength("height", "height"); @@ -2254,7 +2254,7 @@ public void setHeight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setTopProperty() throws Exception { setLengthProperty("top", "top"); @@ -2264,7 +2264,7 @@ public void setTopProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setTop() throws Exception { setLength("top", "top"); @@ -2274,7 +2274,7 @@ public void setTop() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setLeftProperty() throws Exception { setLengthProperty("left", "left"); @@ -2284,7 +2284,7 @@ public void setLeftProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setLeft() throws Exception { setLength("left", "left"); @@ -2294,7 +2294,7 @@ public void setLeft() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBottomProperty() throws Exception { setLengthProperty("bottom", "bottom"); @@ -2304,7 +2304,7 @@ public void setBottomProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBottom() throws Exception { setLength("bottom", "bottom"); @@ -2314,7 +2314,7 @@ public void setBottom() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setRightProperty() throws Exception { setLengthProperty("right", "right"); @@ -2324,7 +2324,7 @@ public void setRightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setRight() throws Exception { setLength("right", "right"); @@ -2334,7 +2334,7 @@ public void setRight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginTopProperty() throws Exception { setLengthProperty("margin-top", "marginTop"); @@ -2344,7 +2344,7 @@ public void setMarginTopProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginTop() throws Exception { setLength("margin-top", "marginTop"); @@ -2354,7 +2354,7 @@ public void setMarginTop() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginLeftProperty() throws Exception { setLengthProperty("margin-left", "marginLeft"); @@ -2364,7 +2364,7 @@ public void setMarginLeftProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginLeft() throws Exception { setLength("margin-left", "marginLeft"); @@ -2374,7 +2374,7 @@ public void setMarginLeft() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginBottomProperty() throws Exception { setLengthProperty("margin-bottom", "marginBottom"); @@ -2384,7 +2384,7 @@ public void setMarginBottomProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginBottom() throws Exception { setLength("margin-bottom", "marginBottom"); @@ -2394,7 +2394,7 @@ public void setMarginBottom() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginRightProperty() throws Exception { setLengthProperty("margin-right", "marginRight"); @@ -2404,7 +2404,7 @@ public void setMarginRightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMarginRight() throws Exception { setLength("margin-right", "marginRight"); @@ -2414,7 +2414,7 @@ public void setMarginRight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingTopProperty() throws Exception { setLengthProperty("padding-top", "paddingTop"); @@ -2424,7 +2424,7 @@ public void setPaddingTopProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingTop() throws Exception { setLength("padding-top", "paddingTop"); @@ -2434,7 +2434,7 @@ public void setPaddingTop() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingLeftProperty() throws Exception { setLengthProperty("padding-left", "paddingLeft"); @@ -2444,7 +2444,7 @@ public void setPaddingLeftProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingLeft() throws Exception { setLength("padding-left", "paddingLeft"); @@ -2454,7 +2454,7 @@ public void setPaddingLeft() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingBottomProperty() throws Exception { setLengthProperty("padding-bottom", "paddingBottom"); @@ -2464,7 +2464,7 @@ public void setPaddingBottomProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingBottom() throws Exception { setLength("padding-bottom", "paddingBottom"); @@ -2474,7 +2474,7 @@ public void setPaddingBottom() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingRightProperty() throws Exception { setLengthProperty("padding-right", "paddingRight"); @@ -2484,7 +2484,7 @@ public void setPaddingRightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setPaddingRight() throws Exception { setLength("padding-right", "paddingRight"); @@ -2494,7 +2494,7 @@ public void setPaddingRight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderTopWidthProperty() throws Exception { setLengthProperty("border-top-width", "borderTopWidth"); @@ -2504,7 +2504,7 @@ public void setBorderTopWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderTopWidth() throws Exception { setLength("border-top-width", "borderTopWidth"); @@ -2514,7 +2514,7 @@ public void setBorderTopWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderLeftWidthProperty() throws Exception { setLengthProperty("border-left-width", "borderLeftWidth"); @@ -2524,7 +2524,7 @@ public void setBorderLeftWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderLeftWidth() throws Exception { setLength("border-left-width", "borderLeftWidth"); @@ -2534,7 +2534,7 @@ public void setBorderLeftWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderBottomWidthProperty() throws Exception { setLengthProperty("border-bottom-width", "borderBottomWidth"); @@ -2544,7 +2544,7 @@ public void setBorderBottomWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderBottomWidth() throws Exception { setLength("border-bottom-width", "borderBottomWidth"); @@ -2554,7 +2554,7 @@ public void setBorderBottomWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderRightWidthProperty() throws Exception { setLengthProperty("border-right-width", "borderRightWidth"); @@ -2564,7 +2564,7 @@ public void setBorderRightWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setBorderRightWidth() throws Exception { setLength("border-right-width", "borderRightWidth"); @@ -2574,7 +2574,7 @@ public void setBorderRightWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMaxWidthProperty() throws Exception { setLengthProperty("max-width", "maxWidth"); @@ -2584,7 +2584,7 @@ public void setMaxWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMaxWidth() throws Exception { setLength("max-width", "maxWidth"); @@ -2594,7 +2594,7 @@ public void setMaxWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMinWidthProperty() throws Exception { setLengthProperty("min-width", "minWidth"); @@ -2604,7 +2604,7 @@ public void setMinWidthProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMinWidth() throws Exception { setLength("min-width", "minWidth"); @@ -2614,7 +2614,7 @@ public void setMinWidth() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMaxHeightProperty() throws Exception { setLengthProperty("max-height", "maxHeight"); @@ -2624,7 +2624,7 @@ public void setMaxHeightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMaxHeight() throws Exception { setLength("max-height", "maxHeight"); @@ -2634,7 +2634,7 @@ public void setMaxHeight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMinHeightProperty() throws Exception { setLengthProperty("min-height", "minHeight"); @@ -2644,7 +2644,7 @@ public void setMinHeightProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "auto", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "auto", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setMinHeight() throws Exception { setLength("min-height", "minHeight"); @@ -2654,7 +2654,7 @@ public void setMinHeight() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setTextIndentProperty() throws Exception { setLengthProperty("text-indent", "textIndent"); @@ -2664,7 +2664,7 @@ public void setTextIndentProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setTextIndent() throws Exception { setLength("text-indent", "textIndent"); @@ -2674,7 +2674,7 @@ public void setTextIndent() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setFontSizeProperty() throws Exception { setLengthProperty("font-size", "fontSize"); @@ -2684,7 +2684,7 @@ public void setFontSizeProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setFontSize() throws Exception { setLength("font-size", "fontSize"); @@ -2694,11 +2694,11 @@ public void setFontSize() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts(DEFAULT = {"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}, - FF = {"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + FF = {"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}, - FF_ESR = {"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + FF_ESR = {"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setWordSpacingProperty() throws Exception { setLengthProperty("word-spacing", "wordSpacing"); @@ -2708,11 +2708,11 @@ public void setWordSpacingProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts(DEFAULT = {"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px", "17px"}, - FF = {"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + FF = {"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px", "17px"}, - FF_ESR = {"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + FF_ESR = {"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px", "17px"}) public void setWordSpacing() throws Exception { setLength("word-spacing", "wordSpacing"); @@ -2722,12 +2722,10 @@ public void setWordSpacing() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts(DEFAULT = {"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}, - FF = {"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + FF = {"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) - @HtmlUnitNYI(FF = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", - "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setLetterSpacingProperty() throws Exception { setLengthProperty("letter-spacing", "letterSpacing"); } @@ -2736,12 +2734,10 @@ public void setLetterSpacingProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", + @Alerts(DEFAULT = {"17px", "5px", "6em", "17px", "17px", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}, - FF = {"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + FF = {"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) - @HtmlUnitNYI(FF = {"4px", "5px", "6em", "17px", "17px", "initial", "inherit", - "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setLetterSpacing() throws Exception { setLength("letter-spacing", "letterSpacing"); } @@ -2750,7 +2746,7 @@ public void setLetterSpacing() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "7%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "7%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setVerticalAlignProperty() throws Exception { setLengthProperty("vertical-align", "verticalAlign"); @@ -2760,7 +2756,7 @@ public void setVerticalAlignProperty() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"4px", "5px", "6em", "17px", "70%", "initial", "inherit", + @Alerts({"17px", "5px", "6em", "17px", "70%", "initial", "inherit", "17px", "17px", "17px", "", "17px", "", "17px", "17px", "17px"}) public void setVerticalAlign() throws Exception { setLength("vertical-align", "verticalAlign"); diff --git a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleSheetTest.java b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleSheetTest.java index 34ded65491f..edab3cccdd7 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/CSSStyleSheetTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/CSSStyleSheetTest.java @@ -2026,9 +2026,23 @@ public void brokenExternalCSS() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts({"true", "true"}) + @Alerts({"true", "false"}) public void widthHeightPercent() throws Exception { - final String html = DOCTYPE_HTML + widthHeightPercent(DOCTYPE_HTML); + } + + /** + * Test for #941. + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "true"}) + public void widthHeightPercentQuirks() throws Exception { + widthHeightPercent(""); + } + + private void widthHeightPercent(final String doctype) throws Exception { + final String html = doctype + "\n" + " " + " \n" @@ -2057,10 +2071,10 @@ public void widthHeightPercent() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = "break at: 10 660.5833740234375 / 622", - EDGE = "break at: 10 660.5833740234375 / 631", - FF = "break at: 11 726.63330078125 / 676", - FF_ESR = "break at: 11 726.63330078125 / 677") + @Alerts(CHROME = "break at: 10 664.25 / 621", + EDGE = "break at: 10 664.25 / 630", + FF = "break at: 10 675.2000122070312 / 675", + FF_ESR = "break at: 11 734.63330078125 / 677") @HtmlUnitNYI(CHROME = "break at: 16 637 / 605", EDGE = "break at: 16 637 / 605", FF = "break at: 15 616 / 605", diff --git a/src/test/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java b/src/test/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java index 0315960491a..b04f44f89fc 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java @@ -104,9 +104,8 @@ public void cssFloat() throws Exception { public void stringProperties() throws Exception { final String html = DOCTYPE_HTML + "\n" - + "

\n" + + "
HtmlUnit
\n" + " \n" - + "
\n" + "\n" + + "\n" + + "\n" + + "
\n" + + ""; + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "false"}) + public void offsetHeight_setting_height_quirks() throws Exception { + final String html = + "\n" + + "\n" + "\n" @@ -2645,6 +2676,7 @@ public void heightManyLines() throws Exception { */ @Test @Alerts(DEFAULT = "0 17", + CHROME = "0 15", EDGE = "0 15") @HtmlUnitNYI(CHROME = "0 0", EDGE = "0 0", @@ -3197,4 +3229,43 @@ public void animationDuration() throws Exception { loadPageVerifyTitle2(html); } + + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"0px", "0px", "18px", "18px", "auto", "auto"}) + public void blockSize() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
\n" + + "
HtmlUnit
\n" + + " \n" + + ""; + + loadPageVerifyTitle2(html); + } } diff --git a/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientHeightTest.java b/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientHeightTest.java index d3dacd7a3f0..ca530fdd096 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientHeightTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientHeightTest.java @@ -804,8 +804,8 @@ public void hr() throws Exception { @Test @Alerts(CHROME = "621", EDGE = "630", - FF = "8", - FF_ESR = "8") + FF = "675", + FF_ESR = "677") @HtmlUnitNYI(CHROME = "605", EDGE = "605", FF = "605", @@ -1341,7 +1341,9 @@ public void progress() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(DEFAULT = "0", + FF = "17", + FF_ESR = "17") public void ruby() throws Exception { loadPageVerifyTitle2(test("ruby")); } @@ -1352,7 +1354,9 @@ public void ruby() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(DEFAULT = "0", + FF = "17", + FF_ESR = "17") public void rb() throws Exception { loadPageVerifyTitle2(test("rb")); } @@ -1374,7 +1378,9 @@ public void rp() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(DEFAULT = "0", + FF = "9", + FF_ESR = "9") public void rt() throws Exception { loadPageVerifyTitle2(test("rt")); } @@ -2041,10 +2047,6 @@ public void slot() throws Exception { @Alerts(DEFAULT = "10, 11, 16, 18, 21, 27, 37, 55", FF = "11, 12, 16, 18, 21, 28, 38, 56", FF_ESR = "11, 12, 16, 18, 21, 28, 38, 56") - @HtmlUnitNYI(CHROME = "11, 11, 15, 18, 21, 28, 37, 55", - EDGE = "11, 11, 15, 18, 21, 28, 37, 55", - FF = "12, 12, 15, 18, 21, 29, 38, 56", - FF_ESR = "12, 12, 15, 18, 21, 29, 38, 56") public void clientHeightSmallLarge() throws Exception { final String html = DOCTYPE_HTML + "\n" @@ -2093,10 +2095,6 @@ public void clientHeightSmallLarge() throws Exception { */ @Test @Alerts("16, 22") - @HtmlUnitNYI(CHROME = "15, 22", - EDGE = "15, 22", - FF = "15, 22", - FF_ESR = "15, 22") public void clientHeightSmallerLarger() throws Exception { final String html = DOCTYPE_HTML + "\n" @@ -2130,9 +2128,7 @@ public void clientHeightSmallerLarger() throws Exception { FF = "12, 49, 3", FF_ESR = "12, 49, 3") @HtmlUnitNYI(CHROME = "11, 49, 2", - EDGE = "11, 49, 2", - FF = "12, 49, 3", - FF_ESR = "12, 49, 3") + EDGE = "11, 49, 2") public void clientHeightUnits() throws Exception { final String html = DOCTYPE_HTML + "\n" diff --git a/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientWidthTest.java b/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientWidthTest.java index 5b926867255..44f9ceb8e10 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientWidthTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/property/ElementClientWidthTest.java @@ -1361,7 +1361,7 @@ public void section() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = "22", + @Alerts(CHROME = "20", EDGE = "20", FF = "26", FF_ESR = "26") @@ -1590,7 +1590,7 @@ public void track() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = "168", + @Alerts(CHROME = "166", EDGE = "166", FF = "164", FF_ESR = "161") diff --git a/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeight2Test.java b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeight2Test.java new file mode 100644 index 00000000000..5fd9c135a4c --- /dev/null +++ b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeight2Test.java @@ -0,0 +1,398 @@ +/* + * Copyright (c) 2002-2025 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.htmlunit.javascript.host.css.property; + +import org.htmlunit.WebDriverTestCase; +import org.htmlunit.junit.BrowserRunner; +import org.htmlunit.junit.annotation.Alerts; +import org.htmlunit.junit.annotation.HtmlUnitNYI; +import org.htmlunit.junit.annotation.NotYetImplemented; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +/** + * Tests for ComputedHeight. + * + * @author Ahmed Ashour + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class ElementOffsetHeight2Test extends WebDriverTestCase { + + /** + * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * + * @throws Exception if the test fails + */ + @Test + public void offsetHeight() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
a
\n" + + " \n" + + ""; + + final WebDriver driver = loadPage2(html); + final String expected = loadExpectation("ElementOffsetHeightTest.properties", ".txt"); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(expected, actual); + } + + /** + * Try to do a line break if width is fixed. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "12, 27, 44, 60, 80, 108, 126, 161, 208, 216, 270, 288, 340, 407", + FF = "14, 30, 48, 60, 80, 108, 126, 161, 208, 224, 279, 297, 350, 418", + FF_ESR = "14, 30, 48, 60, 80, 108, 126, 161, 208, 224, 279, 297, 350, 418") + @NotYetImplemented // we will see other results on unix + public void offsetHeightLineBreaks() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
" + + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt " + + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " + + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " + + "sit amet.
\n" + + " \n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("true, true, true, true, true, true, true, true, true, true, true, true, true, true") + public void offsetHeightLineBreaks2() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
Lorem ipsum
\n" + + "
" + + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt " + + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " + + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " + + "sit amet.
\n" + + " \n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Try to do a line break if width is fixed. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("true") + public void offsetHeightManualLineBreaks() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + + "
" + + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " + + "sed diam nonumy eirmod tempor invidunt " + + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " + + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " + + "sit amet.
\n" + + + "
" + + "Lorem
ipsum
dolor
sit
amet, consetetur sadipscing elitr, " + + "sed diam nonumy eirmod tempor invidunt " + + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " + + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " + + "sit amet.
\n" + + + " \n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "10, 11, 16, 18, 21, 27, 37, 55", + FF = "11, 12, 16, 18, 21, 28, 38, 56", + FF_ESR = "11, 12, 16, 18, 21, 28, 38, 56") + public void offsetHeightSmallLarge() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
a
\n" + + " \n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("16, 22") + public void offsetHeightSmallerLarger() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
a
\n" + + " \n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "11, 49, 6", + FF = "12, 49, 3", + FF_ESR = "12, 49, 3") + @HtmlUnitNYI(CHROME = "11, 49, 2", + EDGE = "11, 49, 2") + public void offsetHeightUnits() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
a
\n" + + "
a
\n" + + "
a
\n" + + " \n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "12, 49, 6", + FF = "13, 49, 4", + FF_ESR = "13, 49, 4") + @HtmlUnitNYI(CHROME = "12, 49, 4", + EDGE = "12, 49, 4", + FF = "13, 49, 5", + FF_ESR = "13, 49, 5") + public void offsetHeightUnitsWidth() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
a
\n" + + "
a
\n" + + "
a
\n" + + " \n" + + ""; + + final WebDriver driver = loadPage2(html); + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); + assertEquals(getExpectedAlerts()[0], actual); + } + + /** + * Test case for #124. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({"300", "549", "945", "60", "273", "938", "35"}) + @HtmlUnitNYI(CHROME = {"300", "552", "9690", "60", "294", "6885", "43"}, + EDGE = {"300", "552", "9690", "60", "294", "6885", "43"}, + FF = {"300", "552", "9690", "60", "294", "6885", "43"}, + FF_ESR = {"300", "552", "9690", "60", "294", "6885", "43"}) + public void issue124() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " 8oz steak from Good and Gather. 8oz steak from Good and Gather. 8oz" + + " steak from Good and Gather. 8oz steak from Good and Gather. 8oz steak" + + " from Good and Gather. 8oz steak from Good and Gather. 8oz steak from" + + " Good and Gather. 8oz steak from Good and Gather." + + " \n" + + " \n" + + "
\n" + + " \n" + + + " \n" + + ""; + + loadPageVerifyTitle2(html); + } +} diff --git a/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeightTest.java b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeightTest.java index 8c95760118b..dd83ed843e4 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeightTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetHeightTest.java @@ -18,14 +18,11 @@ import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.annotation.Alerts; import org.htmlunit.junit.annotation.HtmlUnitNYI; -import org.htmlunit.junit.annotation.NotYetImplemented; import org.junit.Test; import org.junit.runner.RunWith; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; /** - * Tests for ComputedHeight. + * Unit tests for {@code offsetHeight} of an element. * * @author Ahmed Ashour * @author Ronald Brill @@ -33,374 +30,2149 @@ @RunWith(BrowserRunner.class) public class ElementOffsetHeightTest extends WebDriverTestCase { + private static final String VALUE_ = "e == null ? e : e.offsetHeight"; + + private void test(final String tagName) throws Exception { + String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "<" + tagName + " id='outer'><" + tagName + ">\n" + + ""; + + if ("basefont".equals(tagName) || "isindex".equals(tagName)) { + html = DOCTYPE_HTML + + "\n" + + "<" + tagName + " id='outer'><" + tagName + ">\n" + + "\n" + + "\n" + + ""; + } + + if ("title".equals(tagName)) { + // title is a bit special, we have to provide at least + // one closing tab otherwise title spans to the end of the file + html = DOCTYPE_HTML + + "\n" + + "\n" + + "<title>\n" + + "\n" + + ""; + } + + if ("frame".equals(tagName)) { + html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + } + if ("script".equals(tagName)) { + html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + } + if ("frameset".equals(tagName)) { + html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + } + + if ("basefont".equals(tagName) + || "isindex".equals(tagName)) { + loadPageWithAlerts2(html); + return; + } + + loadPageVerifyTitle2(html); + } + + private static String testInput(final String type) { + return DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + } + + /** + * Test {@link org.htmlunit.html.HtmlAbbreviated}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void abbr() throws Exception { + test("abbr"); + } + + /** + * Test {@link org.htmlunit.html.HtmlAcronym}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void acronym() throws Exception { + test("acronym"); + } + + /** + * Test {@link org.htmlunit.html.HtmlAnchor}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void a() throws Exception { + test("a"); + } + + /** + * Test {@link org.htmlunit.html.HtmlAddress}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void address() throws Exception { + test("address"); + } + + /** + * Test {@link org.htmlunit.html.HtmlApplet}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void applet() throws Exception { + test("applet"); + } + + /** + * Test {@link org.htmlunit.html.HtmlArea}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void area() throws Exception { + test("area"); + } + + /** + * Test {@link org.htmlunit.html.HtmlArticle}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void article() throws Exception { + test("article"); + } + + /** + * Test {@link org.htmlunit.html.HtmlAside}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void aside() throws Exception { + test("aside"); + } + + /** + * Test {@link org.htmlunit.html.HtmlAudio}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void audio() throws Exception { + test("audio"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBackgroundSound}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void bgsound() throws Exception { + test("bgsound"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBase}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void base() throws Exception { + test("base"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBaseFont}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void basefont() throws Exception { + test("basefont"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBidirectionalIsolation}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void bdi() throws Exception { + test("bdi"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBidirectionalOverride}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void bdo() throws Exception { + test("bdo"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBig}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "21") + @HtmlUnitNYI(FF_ESR = "0") + public void big() throws Exception { + test("big"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBlink}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void blink() throws Exception { + test("blink"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBlockQuote}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void blockquote() throws Exception { + test("blockquote"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBody}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void body() throws Exception { + test("body"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBold}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void b() throws Exception { + test("b"); + } + + /** + * Test {@link org.htmlunit.html.HtmlBreak}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF = "18", + FF_ESR = "18") + @HtmlUnitNYI(FF = "0", + FF_ESR = "0") + public void br() throws Exception { + test("br"); + } + + /** + * Test {@link org.htmlunit.html.HtmlButton}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("6") + @HtmlUnitNYI(CHROME = "20", + EDGE = "20", + FF = "20", + FF_ESR = "20") + public void button() throws Exception { + test("button"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCanvas}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("150") + public void canvas() throws Exception { + test("canvas"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCaption}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("null") + public void caption() throws Exception { + test("caption"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCenter}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void center() throws Exception { + test("center"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCitation}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void cite() throws Exception { + test("cite"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCode}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void code() throws Exception { + test("code"); + } + + /** + * Test {@link org.htmlunit.html.HtmlCommand}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void command() throws Exception { + test("command"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDataList}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void datalist() throws Exception { + test("datalist"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDetails}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "18", + FF = "19", + FF_ESR = "19") + @HtmlUnitNYI(FF = "18", + FF_ESR = "18") + public void details() throws Exception { + test("details"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDefinition}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void dfn() throws Exception { + test("dfn"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDefinitionDescription}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void dd() throws Exception { + test("dd"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDeletedText}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void del() throws Exception { + test("del"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDialog}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void dialog() throws Exception { + test("dialog"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDirectory}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void dir() throws Exception { + test("dir"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDivision}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void div() throws Exception { + test("div"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDefinitionList}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void dl() throws Exception { + test("dl"); + } + + /** + * Test {@link org.htmlunit.html.HtmlDefinitionTerm}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void dt() throws Exception { + test("dt"); + } + + /** + * Test {@link org.htmlunit.html.HtmlEmbed}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void embed() throws Exception { + test("embed"); + } + + /** + * Test {@link org.htmlunit.html.HtmlEmphasis}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void em() throws Exception { + test("em"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFieldSet}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("39") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void fieldset() throws Exception { + test("fieldset"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFigureCaption}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void figcaption() throws Exception { + test("figcaption"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFigure}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void figure() throws Exception { + test("figure"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFont}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void font() throws Exception { + test("font"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFooter}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void footer() throws Exception { + test("footer"); + } + + /** + * Test {@link org.htmlunit.html.HtmlForm}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void form() throws Exception { + test("form"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFrame}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(CHROME = "621", + FF = "675", + FF_ESR = "677", + EDGE = "630") + @HtmlUnitNYI(CHROME = "0", + EDGE = "0", + FF = "0", + FF_ESR = "0") + public void frame() throws Exception { + test("frame"); + } + + /** + * Test {@link org.htmlunit.html.HtmlFrameSet}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "621", + EDGE = "630", + FF = "675", + FF_ESR = "677") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void frameset() throws Exception { + test("frameset"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading1}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h1() throws Exception { + test("h1"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading2}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h2() throws Exception { + test("h2"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading3}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h3() throws Exception { + test("h3"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading4}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h4() throws Exception { + test("h4"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading5}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h5() throws Exception { + test("h5"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeading6}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void h6() throws Exception { + test("h6"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHead}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("null") + public void head() throws Exception { + test("head"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHeader}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void header() throws Exception { + test("header"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHorizontalRule}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("2") + @HtmlUnitNYI(CHROME = "0", + EDGE = "0", + FF = "0", + FF_ESR = "0") + public void hr() throws Exception { + test("hr"); + } + + /** + * Test {@link org.htmlunit.html.HtmlHtml}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("8") + public void html() throws Exception { + test("html"); + } + + /** + * Test {@link org.htmlunit.html.HtmlInlineFrame}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("154") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void iframe() throws Exception { + test("iframe"); + } + + /** + * Test {@link org.htmlunit.html.HtmlInlineQuotation}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void q() throws Exception { + test("q"); + } + + /** + * Test {@link org.htmlunit.html.HtmlImage}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void image() throws Exception { + test("image"); + } + + /** + * Test {@link org.htmlunit.html.HtmlImage}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void img() throws Exception { + test("img"); + } + + /** + * Test {@link org.htmlunit.html.HtmlInsertedText}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void ins() throws Exception { + test("ins"); + } + + /** + * Test {@link org.htmlunit.html.HtmlIsIndex}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void isindex() throws Exception { + test("isindex"); + } + + /** + * Test {@link org.htmlunit.html.HtmlItalic}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void i() throws Exception { + test("i"); + } + + /** + * Test {@link org.htmlunit.html.HtmlKeyboard}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void kbd() throws Exception { + test("kbd"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void keygen() throws Exception { + test("keygen"); + } + + /** + * Test {@link org.htmlunit.html.HtmlLabel}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void label() throws Exception { + test("label"); + } + + /** + * Test {@link org.htmlunit.html.HtmlLayer}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void layer() throws Exception { + test("layer"); + } + + /** + * Test {@link org.htmlunit.html.HtmlLegend}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void legend() throws Exception { + test("legend"); + } + + /** + * Test {@link org.htmlunit.html.HtmlListing}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void listing() throws Exception { + test("listing"); + } + + /** + * Test {@link org.htmlunit.html.HtmlListItem}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "18", + FF = "19", + FF_ESR = "19") + @HtmlUnitNYI(CHROME = "0", + EDGE = "0", + FF = "0", + FF_ESR = "0") + public void li() throws Exception { + test("li"); + } + + /** + * Test {@link org.htmlunit.html.HtmlLink}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void link() throws Exception { + test("link"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMain}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void main() throws Exception { + test("main"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMap}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void map() throws Exception { + test("map"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMarquee}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("18") + public void marquee() throws Exception { + test("marquee"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMark}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void mark() throws Exception { + test("mark"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMenu}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void menu() throws Exception { + test("menu"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMenuItem}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void menuitem() throws Exception { + test("menuitem"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMeta}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void meta() throws Exception { + test("meta"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMeter}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("16") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void meter() throws Exception { + test("meter"); + } + + /** + * Test {@link org.htmlunit.html.HtmlMultiColumn}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void multicol() throws Exception { + test("multicol"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNoBreak}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void nobr() throws Exception { + test("nobr"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNav}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void nav() throws Exception { + test("nav"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNextId}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void nextid() throws Exception { + test("nextid"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNoEmbed}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void noembed() throws Exception { + test("noembed"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNoFrames}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void noframes() throws Exception { + test("noframes"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNoLayer}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void nolayer() throws Exception { + test("nolayer"); + } + + /** + * Test {@link org.htmlunit.html.HtmlNoScript}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18") + public void noscript() throws Exception { + test("noscript"); + } + + /** + * Test {@link org.htmlunit.html.HtmlObject}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "17", + FF = "0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void object() throws Exception { + test("object"); + } + + /** + * Test {@link org.htmlunit.html.HtmlOrderedList}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void ol() throws Exception { + test("ol"); + } + + /** + * Test {@link org.htmlunit.html.HtmlOptionGroup}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "20", + FF = "18", + FF_ESR = "18") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18") + public void optgroup() throws Exception { + test("optgroup"); + } + + /** + * Test {@link org.htmlunit.html.HtmlOption}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("20") + @HtmlUnitNYI(CHROME = "0", + EDGE = "0", + FF = "0", + FF_ESR = "0") + public void option() throws Exception { + test("option"); + } + + /** + * Test {@link org.htmlunit.html.HtmlOutput}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void output() throws Exception { + test("output"); + } + + /** + * Test {@link org.htmlunit.html.HtmlParagraph}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void p() throws Exception { + test("p"); + } + + /** + * Test {@link org.htmlunit.html.HtmlParameter}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void param() throws Exception { + test("param"); + } + + /** + * Test {@link org.htmlunit.html.HtmlPlainText}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("30") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void plaintext() throws Exception { + test("plaintext"); + } + + /** + * Test {@link org.htmlunit.html.HtmlPreformattedText}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void pre() throws Exception { + test("pre"); + } + + /** + * Test {@link org.htmlunit.html.HtmlProgress}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("16") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void progress() throws Exception { + test("progress"); + } + + /** + * Test {@link org.htmlunit.html.HtmlRuby}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF = "17", + FF_ESR = "17") + public void ruby() throws Exception { + test("ruby"); + } + + /** + * Test {@link org.htmlunit.html.HtmlRb}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF = "17", + FF_ESR = "17") + public void rb() throws Exception { + test("rb"); + } + + /** + * Test {@link org.htmlunit.html.HtmlRp}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void rp() throws Exception { + test("rp"); + } + + /** + * Test {@link org.htmlunit.html.HtmlRt}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF = "9", + FF_ESR = "9") + public void rt() throws Exception { + test("rt"); + } + + /** + * Test {@link org.htmlunit.html.HtmlRtc}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF = "9", + FF_ESR = "9") + @HtmlUnitNYI(FF = "0", + FF_ESR = "0") + public void rtc() throws Exception { + test("rtc"); + } + + /** + * Test {@link org.htmlunit.html.HtmlS}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void s() throws Exception { + test("s"); + } + + /** + * Test {@link org.htmlunit.html.HtmlSample}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void samp() throws Exception { + test("samp"); + } + + /** + * Test {@link org.htmlunit.html.HtmlScript}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void script() throws Exception { + test("script"); + } + + /** + * Test {@link org.htmlunit.html.HtmlSection}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void section() throws Exception { + test("section"); + } + + /** + * Test {@link org.htmlunit.html.HtmlSelect}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "19", + FF = "22", + FF_ESR = "22") + @HtmlUnitNYI(CHROME = "20", + EDGE = "20", + FF = "20", + FF_ESR = "20") + public void select() throws Exception { + test("select"); + } + + /** + * Test {@link org.htmlunit.html.HtmlSmall}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void small() throws Exception { + test("small"); + } + + /** + * Test {@link org.htmlunit.html.HtmlSource}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void source() throws Exception { + test("source"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void spacer() throws Exception { + test("spacer"); + } + /** - * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * Test {@link org.htmlunit.html.HtmlSpan}. * * @throws Exception if the test fails */ @Test - public void offsetHeight() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
a
\n" - + " \n" - + ""; + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void span() throws Exception { + test("span"); + } - final WebDriver driver = loadPage2(html); - final String expected = loadExpectation("ElementOffsetHeightTest.properties", ".txt"); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(expected, actual); + /** + * Test {@link org.htmlunit.html.HtmlStrike}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void strike() throws Exception { + test("strike"); } /** - * Try to do a line break if width is fixed. + * Test {@link org.htmlunit.html.HtmlStrong}. * * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "12, 27, 44, 60, 80, 108, 126, 161, 208, 216, 270, 288, 340, 407", - FF = "14, 30, 48, 60, 80, 108, 126, 161, 208, 224, 279, 297, 350, 418", - FF_ESR = "14, 30, 48, 60, 80, 108, 126, 161, 208, 224, 279, 297, 350, 418") - @NotYetImplemented // we will see other results on unix - public void offsetHeightLineBreaks() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
" - + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt " - + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " - + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " - + "sit amet.
\n" - + " \n" - + "\n" - + ""; + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void strong() throws Exception { + test("strong"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlStyle}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void style() throws Exception { + test("style"); } /** + * Test {@link org.htmlunit.html.HtmlSubscript}. + * * @throws Exception if the test fails */ @Test - @Alerts("true, true, true, true, true, true, true, true, true, true, true, true, true, true") - public void offsetHeightLineBreaks2() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
Lorem ipsum
\n" - + "
" - + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt " - + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " - + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " - + "sit amet.
\n" - + " \n" - + "\n" - + ""; + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void sub() throws Exception { + test("sub"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlSummary}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void summary() throws Exception { + test("summary"); } /** - * Try to do a line break if width is fixed. + * Test {@link org.htmlunit.html.HtmlSuperscript}. * * @throws Exception if the test fails */ @Test - @Alerts("true") - public void offsetHeightManualLineBreaks() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - - + "
" - + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " - + "sed diam nonumy eirmod tempor invidunt " - + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " - + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " - + "sit amet.
\n" - - + "
" - + "Lorem
ipsum
dolor
sit
amet, consetetur sadipscing elitr, " - + "sed diam nonumy eirmod tempor invidunt " - + "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo " - + "dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " - + "sit amet.
\n" - - + " \n" - + "\n" - + ""; + /** + * Test {@link org.htmlunit.html.HtmlSvg}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("undefined") + public void svg() throws Exception { + test("svg"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlTable}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void table() throws Exception { + test("table"); } /** - * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * Test {@link org.htmlunit.html.HtmlTableColumn}. * * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "11, 11, 15, 18, 21, 28, 37, 55", - FF = "11, 11, 15, 19, 21, 28, 37, 56", - FF_ESR = "11, 11, 15, 19, 21, 28, 37, 56") - @HtmlUnitNYI(FF = "12, 12, 15, 18, 21, 29, 38, 56", - FF_ESR = "12, 12, 15, 18, 21, 29, 38, 56") - public void offsetHeightSmallLarge() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
a
\n" - + " \n" - + ""; + /** + * Test {@link org.htmlunit.html.HtmlTeletype}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "15") + @HtmlUnitNYI(FF_ESR = "0") + public void tt() throws Exception { + test("tt"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlTime}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void time() throws Exception { + test("time"); } /** - * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * Test {@link org.htmlunit.html.HtmlTitle}. * * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "15, 22", - FF = "15, 23", - FF_ESR = "15, 23") - @HtmlUnitNYI(FF = "15, 22", - FF_ESR = "15, 22") - public void offsetHeightSmallerLarger() throws Exception { + @Alerts("0") + public void title() throws Exception { + // title is a bit special, we have to provide at least + // one closing tab otherwise title spans to the end of the file final String html = DOCTYPE_HTML - + "\n" - + "
a
\n" - + " \n" + + "\n" + "\n" + + "<title>\n" + + "\n" + + ""; + + loadPageWithAlerts2(html); + } - + "e.style.fontSize = 'smaller';\n" - + "array.push(e.offsetHeight);\n" + /** + * Test {@link org.htmlunit.html.HtmlUnderlined}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void u() throws Exception { + test("u"); + } - + "e.style.fontSize = 'larger';\n" - + "array.push(e.offsetHeight);\n" + /** + * Test {@link org.htmlunit.html.HtmlUnorderedList}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void ul() throws Exception { + test("ul"); + } - + "document.getElementById('myTextarea').value = array.join(', ');\n" - + ""; + /** + * Test {@link org.htmlunit.html.HtmlVariable}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void var() throws Exception { + test("var"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlVideo}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("150") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void video() throws Exception { + test("video"); } /** - * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * Test {@link org.htmlunit.html.HtmlWordBreak}. * * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "11, 49, 6", - FF = "12, 49, 3", - FF_ESR = "12, 49, 3") - @HtmlUnitNYI(CHROME = "11, 49, 2", - EDGE = "11, 49, 2", - FF = "12, 49, 3", - FF_ESR = "12, 49, 3") - public void offsetHeightUnits() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
a
\n" - + "
a
\n" - + "
a
\n" - + " \n" - + ""; + /** + * Test {@link org.htmlunit.html.HtmlInput}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "13", + FF = "14", + FF_ESR = "14") + @HtmlUnitNYI(FF_ESR = "10") + public void inputCheckbox() throws Exception { + loadPageVerifyTitle2(testInput("checkbox")); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlInput}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "21", + FF = "22", + FF_ESR = "22") + @HtmlUnitNYI(CHROME = "17", + EDGE = "17", + FF = "18", + FF_ESR = "18") + public void inputFile() throws Exception { + loadPageVerifyTitle2(testInput("file")); } /** - * Tests the relation between {@code fontSize} and {@code offsetHeight}. + * Test {@link org.htmlunit.html.HtmlInput}. * * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "12, 49, 6", - FF = "13, 49, 4", - FF_ESR = "13, 49, 4") - @HtmlUnitNYI(CHROME = "12, 49, 4", - EDGE = "12, 49, 4", - FF = "13, 49, 5", - FF_ESR = "13, 49, 5") - public void offsetHeightUnitsWidth() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + "
a
\n" - + "
a
\n" - + "
a
\n" - + " \n" - + ""; + /** + * Test HtmlContent. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(FF_ESR = "0") + public void content() throws Exception { + test("content"); + } - final WebDriver driver = loadPage2(html); - final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); - assertEquals(getExpectedAlerts()[0], actual); + /** + * Test {@link org.htmlunit.html.HtmlPicture}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "0", + FF_ESR = "17") + @HtmlUnitNYI(CHROME = "18", + EDGE = "18", + FF = "18", + FF_ESR = "18") + public void picture() throws Exception { + test("picture"); } /** - * Test case for #124. + * Test {@link org.htmlunit.html.HtmlTemplate}. * * @throws Exception if the test fails */ @Test - @Alerts({"300", "549", "945", "60", "273", "938", "35"}) - @HtmlUnitNYI(CHROME = {"300", "552", "9690", "60", "294", "6885", "43"}, - EDGE = {"300", "552", "9690", "60", "294", "6885", "43"}, - FF = {"300", "552", "9690", "60", "294", "6885", "43"}, - FF_ESR = {"300", "552", "9690", "60", "294", "6885", "43"}) - public void issue124() throws Exception { - final String html = DOCTYPE_HTML - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + "
\n" - + " \n" - + " \n" - + " 8oz steak from Good and Gather. 8oz steak from Good and Gather. 8oz" - + " steak from Good and Gather. 8oz steak from Good and Gather. 8oz steak" - + " from Good and Gather. 8oz steak from Good and Gather. 8oz steak from" - + " Good and Gather. 8oz steak from Good and Gather." - + " \n" - + " \n" - + "
\n" - + " \n" - - + " \n" - + ""; + @Alerts("0") + public void template() throws Exception { + test("template"); + } - loadPageVerifyTitle2(html); + /** + * Test {@link org.htmlunit.html.HtmlSlot}. + * + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void slot() throws Exception { + test("slot"); } + } diff --git a/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java index 7a0cb36fb17..02952924960 100644 --- a/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java +++ b/src/test/java/org/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java @@ -30,8 +30,7 @@ @RunWith(BrowserRunner.class) public class ElementOffsetWidthTest extends WebDriverTestCase { - private static final String VALUE_ = "e == null ? e : (e.offsetWidth < 1000 ? e.offsetWidth :" - + "e.offsetWidth - document.documentElement.offsetWidth)"; + private static final String VALUE_ = "e == null ? e : e.offsetWidth"; private void test(final String tagName) throws Exception { String html = DOCTYPE_HTML @@ -186,7 +185,12 @@ public void a() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void address() throws Exception { test("address"); } @@ -219,7 +223,12 @@ public void area() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void article() throws Exception { test("article"); } @@ -230,7 +239,12 @@ public void article() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void aside() throws Exception { test("aside"); } @@ -329,11 +343,14 @@ public void blink() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-96") - @HtmlUnitNYI(CHROME = "-16", - EDGE = "-16", - FF = "-16", - FF_ESR = "-16") + @Alerts(CHROME = "1160", + EDGE = "1152", + FF = "1160", + FF_ESR = "1164") + @HtmlUnitNYI(CHROME = "1240", + EDGE = "1240", + FF = "1240", + FF_ESR = "1240") public void blockquote() throws Exception { test("blockquote"); } @@ -344,7 +361,12 @@ public void blockquote() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void body() throws Exception { test("body"); } @@ -417,7 +439,12 @@ public void caption() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void center() throws Exception { test("center"); } @@ -472,7 +499,12 @@ public void datalist() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void details() throws Exception { test("details"); } @@ -494,11 +526,14 @@ public void dfn() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-56") - @HtmlUnitNYI(CHROME = "-16", - EDGE = "-16", - FF = "-16", - FF_ESR = "-16") + @Alerts(CHROME = "1200", + EDGE = "1192", + FF = "1200", + FF_ESR = "1204") + @HtmlUnitNYI(CHROME = "1240", + EDGE = "1240", + FF = "1240", + FF_ESR = "1240") public void dd() throws Exception { test("dd"); } @@ -531,7 +566,12 @@ public void dialog() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void dir() throws Exception { test("dir"); } @@ -542,7 +582,12 @@ public void dir() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void div() throws Exception { test("div"); } @@ -553,7 +598,12 @@ public void div() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void dl() throws Exception { test("dl"); } @@ -564,7 +614,12 @@ public void dl() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void dt() throws Exception { test("dt"); } @@ -597,11 +652,13 @@ public void em() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-20") - @HtmlUnitNYI(CHROME = "-16", - EDGE = "-16", - FF = "-16", - FF_ESR = "-16") + @Alerts(CHROME = "1236", + EDGE = "1228", + FF = "1236", + FF_ESR = "1240") + @HtmlUnitNYI(CHROME = "1240", + EDGE = "1240", + FF = "1240") public void fieldset() throws Exception { test("fieldset"); } @@ -612,7 +669,12 @@ public void fieldset() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void figcaption() throws Exception { test("figcaption"); } @@ -623,11 +685,14 @@ public void figcaption() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-96") - @HtmlUnitNYI(CHROME = "-16", - EDGE = "-16", - FF = "-16", - FF_ESR = "-16") + @Alerts(CHROME = "1160", + EDGE = "1152", + FF = "1160", + FF_ESR = "1164") + @HtmlUnitNYI(CHROME = "1240", + EDGE = "1240", + FF = "1240", + FF_ESR = "1240") public void figure() throws Exception { test("figure"); } @@ -649,7 +714,12 @@ public void font() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void footer() throws Exception { test("footer"); } @@ -660,7 +730,12 @@ public void footer() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void form() throws Exception { test("form"); } @@ -671,7 +746,12 @@ public void form() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(CHROME = "1256", + EDGE = "1248", + FF = "1256", + FF_ESR = "1260") + @HtmlUnitNYI(EDGE = "1256", + FF_ESR = "1256") public void frame() throws Exception { test("frame"); } @@ -682,7 +762,12 @@ public void frame() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(CHROME = "1256", + EDGE = "1248", + FF = "1256", + FF_ESR = "1260") + @HtmlUnitNYI(EDGE = "1256", + FF_ESR = "1256") public void frameset() throws Exception { test("frameset"); } @@ -693,7 +778,12 @@ public void frameset() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h1() throws Exception { test("h1"); } @@ -704,7 +794,12 @@ public void h1() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h2() throws Exception { test("h2"); } @@ -715,7 +810,12 @@ public void h2() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h3() throws Exception { test("h3"); } @@ -726,7 +826,12 @@ public void h3() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h4() throws Exception { test("h4"); } @@ -737,7 +842,12 @@ public void h4() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h5() throws Exception { test("h5"); } @@ -748,7 +858,12 @@ public void h5() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void h6() throws Exception { test("h6"); } @@ -770,7 +885,12 @@ public void head() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void header() throws Exception { test("header"); } @@ -781,7 +901,12 @@ public void header() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void hr() throws Exception { test("hr"); } @@ -792,7 +917,12 @@ public void hr() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("0") + @Alerts(CHROME = "1256", + EDGE = "1248", + FF = "1256", + FF_ESR = "1260") + @HtmlUnitNYI(EDGE = "1256", + FF_ESR = "1256") public void html() throws Exception { test("html"); } @@ -804,10 +934,10 @@ public void html() throws Exception { */ @Test @Alerts("304") - @HtmlUnitNYI(CHROME = "0", - EDGE = "0", - FF = "0", - FF_ESR = "0") + @HtmlUnitNYI(CHROME = "1256", + EDGE = "1256", + FF = "1256", + FF_ESR = "1256") public void iframe() throws Exception { test("iframe"); } @@ -930,7 +1060,12 @@ public void layer() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void legend() throws Exception { test("legend"); } @@ -941,7 +1076,12 @@ public void legend() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void listing() throws Exception { test("listing"); } @@ -952,7 +1092,10 @@ public void listing() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") @HtmlUnitNYI(CHROME = "0", EDGE = "0", FF = "0", @@ -978,7 +1121,12 @@ public void link() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void main() throws Exception { test("main"); } @@ -1000,7 +1148,10 @@ public void map() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") @HtmlUnitNYI(CHROME = "0", EDGE = "0", FF = "0", @@ -1026,7 +1177,12 @@ public void mark() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void menu() throws Exception { test("menu"); } @@ -1096,7 +1252,12 @@ public void nobr() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void nav() throws Exception { test("nav"); } @@ -1179,7 +1340,12 @@ public void object() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void ol() throws Exception { test("ol"); } @@ -1190,7 +1356,12 @@ public void ol() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void optgroup() throws Exception { test("optgroup"); } @@ -1201,7 +1372,12 @@ public void optgroup() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void option() throws Exception { test("option"); } @@ -1223,7 +1399,12 @@ public void output() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void p() throws Exception { test("p"); } @@ -1245,7 +1426,12 @@ public void param() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void plaintext() throws Exception { test("plaintext"); } @@ -1256,7 +1442,12 @@ public void plaintext() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void pre() throws Exception { test("pre"); } @@ -1370,7 +1561,12 @@ public void script() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void section() throws Exception { test("section"); } @@ -1381,7 +1577,7 @@ public void section() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = "24", + @Alerts(CHROME = "22", EDGE = "22", FF = "30", FF_ESR = "30") @@ -1485,7 +1681,12 @@ public void sub() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void summary() throws Exception { test("summary"); } @@ -1507,7 +1708,10 @@ public void sup() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("NaN") + @Alerts(CHROME = "undefined", + EDGE = "undefined", + FF = "undefined", + FF_ESR = "undefined") public void svg() throws Exception { test("svg"); } @@ -1606,7 +1810,7 @@ public void track() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(CHROME = "170", + @Alerts(CHROME = "168", EDGE = "168", FF = "168", FF_ESR = "165") @@ -1704,7 +1908,12 @@ public void u() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void ul() throws Exception { test("ul"); } @@ -1752,7 +1961,12 @@ public void wbr() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("-16") + @Alerts(CHROME = "1240", + EDGE = "1232", + FF = "1240", + FF_ESR = "1244") + @HtmlUnitNYI(EDGE = "1240", + FF_ESR = "1240") public void xmp() throws Exception { test("xmp"); } diff --git a/src/test/java/org/htmlunit/javascript/host/dom/DOMTokenListTest.java b/src/test/java/org/htmlunit/javascript/host/dom/DOMTokenListTest.java index 5c99862050a..226175503a9 100644 --- a/src/test/java/org/htmlunit/javascript/host/dom/DOMTokenListTest.java +++ b/src/test/java/org/htmlunit/javascript/host/dom/DOMTokenListTest.java @@ -210,6 +210,90 @@ public void forEach() throws Exception { loadPageVerifyTitle2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"4", "a", "b", "c", "d", "4"}) + public void forEachAdd() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"4", "a", "c", "d", "3"}) + public void forEachRemove() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
\n" + + ""; + + loadPageVerifyTitle2(html); + } + + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"4", "a", "1"}) + public void forEachRemove2() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "
\n" + + ""; + + loadPageVerifyTitle2(html); + } + /** * @throws Exception if the test fails */ diff --git a/src/test/java/org/htmlunit/javascript/host/dom/NodeListTest.java b/src/test/java/org/htmlunit/javascript/host/dom/NodeListTest.java index f25ec6d092b..12774025e51 100644 --- a/src/test/java/org/htmlunit/javascript/host/dom/NodeListTest.java +++ b/src/test/java/org/htmlunit/javascript/host/dom/NodeListTest.java @@ -282,6 +282,140 @@ public void forEach() throws Exception { loadPageVerifyTitle2(html); } + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts({"4", "4", + "[object HTMLElement]/0", "3", "3", + "[object HTMLElement]/1", "2", "2", + "2", "2"}) + public void forEachRemove() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "
abde
\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts({"4", "4", + "[object HTMLElement]/0", "5", "5", + "[object Text]/1", "6", "6", + "[object HTMLElement]/2", "7", "7", + "[object Text]/3", "8", "8", + "8", "8"}) + public void forEachAppend() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "
abde
\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts({"4", "4", + "[object HTMLElement]/0", "5", "5", + "[object HTMLElement]/1", "6", "6", + "[object HTMLElement]/2", "7", "7", + "[object HTMLElement]/3", "8", "8", + "8", "8"}) + public void forEachInsert() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "
abde
\n" + + ""; + + loadPageVerifyTitle2(html); + } + /** * @throws Exception if the test fails */ diff --git a/src/test/java/org/htmlunit/javascript/host/dom/RangeTest.java b/src/test/java/org/htmlunit/javascript/host/dom/RangeTest.java index e0592d5227f..1f781f8c8e6 100644 --- a/src/test/java/org/htmlunit/javascript/host/dom/RangeTest.java +++ b/src/test/java/org/htmlunit/javascript/host/dom/RangeTest.java @@ -147,6 +147,31 @@ public void createContextualFragment2() throws Exception { loadPageVerifyTitle2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("
hello:
") + public void createContextualStrangeCode() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "
\n" + + ""; + + loadPageVerifyTitle2(html); + } + /** * @throws Exception if the test fails */ diff --git a/src/test/java/org/htmlunit/javascript/host/event/Event3Test.java b/src/test/java/org/htmlunit/javascript/host/event/Event3Test.java index 0cb6343ba59..486be1969ed 100644 --- a/src/test/java/org/htmlunit/javascript/host/event/Event3Test.java +++ b/src/test/java/org/htmlunit/javascript/host/event/Event3Test.java @@ -27,7 +27,6 @@ import org.htmlunit.html.Keyboard; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.annotation.Alerts; -import org.htmlunit.junit.annotation.NotYetImplemented; import org.junit.Test; import org.junit.runner.RunWith; @@ -159,41 +158,6 @@ public void eventOnBlur() throws Exception { assertEquals(expectedAlerts, collectedAlerts); } - /** - * Test for event bubbling in IE. - * @throws Exception if the test fails - */ - @Test - @NotYetImplemented // TODO: in IE no click event can be registered for the window - @Alerts({"span bubbling", "div", "div bubbling"}) - public void ie_EventBubbling() throws Exception { - final String content = DOCTYPE_HTML - + "foo\n" - + "\n" - + "\n" - + "
\n" - + "blabla\n" - + "
\n" - + ""; - - final List collectedAlerts = new ArrayList<>(); - final HtmlPage page = loadPage(content, collectedAlerts); - page.getHtmlElementById("theSpan").click(); - - assertEquals(getExpectedAlerts(), collectedAlerts); - } - /** * Test for bug 1976960: what happens with different return values at different levels? * @throws Exception if an error occurs diff --git a/src/test/java/org/htmlunit/javascript/host/event/EventTest.java b/src/test/java/org/htmlunit/javascript/host/event/EventTest.java index b5b32d73d99..4734ae878ca 100644 --- a/src/test/java/org/htmlunit/javascript/host/event/EventTest.java +++ b/src/test/java/org/htmlunit/javascript/host/event/EventTest.java @@ -1518,4 +1518,194 @@ public void domEventNameUsedAsFunctionName() throws Exception { loadPageVerifyTitle2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "false", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "false", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "false", "true", "false"}) + public void scrollEventFromScrollIntoView() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + "
spacer
\n" + + "
Target
\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "true", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "true", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "true", "true", "false"}) + public void scrollEventWindowFromScrollIntoView() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + "
\n" + + "
Target
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "true", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "true", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "true", "true", "false"}) + public void scrollEventFromScrollBy() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "true", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "true", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "true", "true", "false"}) + public void scrollEventWindowFromScrollBy() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "true", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "true", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "true", "true", "false"}) + public void scrollEventFromScrollTo() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object Event]", "scroll", "true", "false", "false"}, + FF = {"[object UIEvent]", "scroll", "true", "true", "false"}, + FF_ESR = {"[object UIEvent]", "scroll", "true", "true", "false"}) + public void scrollEventWindowFromScrollTo() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } } diff --git a/src/test/java/org/htmlunit/javascript/host/html/HTMLElement2Test.java b/src/test/java/org/htmlunit/javascript/host/html/HTMLElement2Test.java index 56575cea06a..ef183744b22 100644 --- a/src/test/java/org/htmlunit/javascript/host/html/HTMLElement2Test.java +++ b/src/test/java/org/htmlunit/javascript/host/html/HTMLElement2Test.java @@ -330,6 +330,40 @@ public void offsetTopAndLeft_Nothing() throws Exception { @Test @Alerts({"50", "50"}) public void offsetTopAndLeft_AbsolutelyPositioned() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + "
d
\n" + + "
\n" + + "
\n" + + " \n" + + ""; + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts({"8", "8"}) + // so far we still support the quirks behaviour + @HtmlUnitNYI(CHROME = {"50", "50"}, + EDGE = {"50", "50"}, + FF = {"50", "50"}, + FF_ESR = {"50", "50"}) + public void offsetTopAndLeft_AbsolutelyPositionedValueWithoutUnit() throws Exception { final String html = DOCTYPE_HTML + "\n" + " \n" @@ -558,7 +592,11 @@ public void offsetTopAndLeftWithRelativePosition() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts({"30px", "46", "55px", "71", "71", "0", "0", "0", "0"}) + @Alerts(DEFAULT = {"", "1240", "", "34", "34", "0", "0", "0", "0"}, + EDGE = {"", "1232", "", "34", "34", "0", "0", "0", "0"}, + FF_ESR = {"", "1244", "", "34", "34", "0", "0", "0", "0"}) + @HtmlUnitNYI(EDGE = {"", "1240", "", "34", "34", "0", "0", "0", "0"}, + FF_ESR = {"", "1240", "", "34", "34", "0", "0", "0", "0"}) public void offsetWidthAndHeight() throws Exception { final String html = DOCTYPE_HTML + "\n" diff --git a/src/test/java/org/htmlunit/javascript/host/html/HTMLElementTest.java b/src/test/java/org/htmlunit/javascript/host/html/HTMLElementTest.java index b1b0e905d40..3ac17423bc0 100644 --- a/src/test/java/org/htmlunit/javascript/host/html/HTMLElementTest.java +++ b/src/test/java/org/htmlunit/javascript/host/html/HTMLElementTest.java @@ -2156,6 +2156,199 @@ public void scrollIntoView() throws Exception { loadPageVerifyTitle2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("container [object HTMLDivElement]") + @HtmlUnitNYI(CHROME = {"container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + EDGE = {"container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + FF = {"container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + FF_ESR = {"container [object HTMLDivElement]", "body [object HTMLBodyElement]"}) + public void scrollIntoViewTriggersOnScroll() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + "
spacer
\n" + + "
Target
" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"target-1 [object HTMLDivElement]", "container [object HTMLDivElement]"}) + @HtmlUnitNYI(CHROME = {"target-1 [object HTMLDivElement]", + "container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + EDGE = {"target-1 [object HTMLDivElement]", + "container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + FF = {"target-1 [object HTMLDivElement]", + "container [object HTMLDivElement]", "body [object HTMLBodyElement]"}, + FF_ESR = {"target-1 [object HTMLDivElement]", + "container [object HTMLDivElement]", "body [object HTMLBodyElement]"}) + public void scrollIntoViewTriggersOnScrollBubbling() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
\n" + + "
spacer
\n" + + "
\n" + + "
spacer
\n" + + "
Target
" + + "
\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("window [object HTMLDocument]") + public void scrollIntoViewTriggersWindowOnScroll() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + "
spacer
\n" + + "
Target
" + + + " \n" + + "\n" + + ""; + + loadPageVerifyTitle2(html); + } + + /** + * Test for issue #942. + * @throws Exception if the test fails + */ + @Test + @Alerts({"50", "100"}) + public void scrollIntoViewIssue() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + "\n" + + "\n" + + + "\n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + "
IDName
\n" + + "
\n" + + + " \n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html); + + final By tableRows = By.xpath("//tbody[@id='table-body']//tr"); + int rowCount = driver.findElements(tableRows).size(); + assertEquals(Integer.parseInt(getExpectedAlerts()[0]), rowCount); + + driver.findElement(By.id("myButton")).click(); + + rowCount = driver.findElements(tableRows).size(); + assertEquals(Integer.parseInt(getExpectedAlerts()[1]), rowCount); + } + /** * Tests the offsetParent property. * @throws Exception if the test fails diff --git a/src/test/java/org/htmlunit/javascript/host/html/HTMLIFrameElementTest.java b/src/test/java/org/htmlunit/javascript/host/html/HTMLIFrameElementTest.java index 17eade250c0..e56a41fcf9b 100644 --- a/src/test/java/org/htmlunit/javascript/host/html/HTMLIFrameElementTest.java +++ b/src/test/java/org/htmlunit/javascript/host/html/HTMLIFrameElementTest.java @@ -16,14 +16,16 @@ import java.util.List; +import javax.net.ssl.SSLHandshakeException; + import org.htmlunit.MockWebConnection; import org.htmlunit.SimpleWebTestCase; import org.htmlunit.WebClient; import org.htmlunit.html.FrameWindow; -import org.htmlunit.html.HtmlElement; import org.htmlunit.html.HtmlInlineFrame; import org.htmlunit.html.HtmlPage; import org.htmlunit.junit.BrowserRunner; +import org.htmlunit.junit.annotation.Alerts; import org.junit.Test; import org.junit.runner.RunWith; @@ -130,7 +132,7 @@ public void removeFrameWindow() throws Exception { assertEquals("frame content", ((HtmlPage) page.getFrameByName("content").getEnclosedPage()).asNormalizedText()); // replace frame tag with javascript - ((HtmlElement) page.getElementById("clickId")).click(); + page.getElementById("clickId").click(); assertEquals("new content", page.getElementById("content").asNormalizedText()); @@ -138,4 +140,33 @@ public void removeFrameWindow() throws Exception { frames = page.getFrames(); assertTrue(frames.isEmpty()); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"", "2"}) + public void iframeUrlInvalid() throws Exception { + final String html = DOCTYPE_HTML + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + " \n" + + "\n" + + ""; + + getMockWebConnection().setDefaultResponse(html); + getMockWebConnection().setThrowable(URL_SECOND, new SSLHandshakeException("Test")); + + final String[] expectedAlerts = getExpectedAlerts(); + final HtmlPage page = loadPage(html); + assertEquals(expectedAlerts[0], page.getTitleText()); + + assertEquals(Integer.parseInt(expectedAlerts[1]), getMockWebConnection().getRequestCount()); + } } diff --git a/src/test/java/org/htmlunit/javascript/host/html/HTMLTableCellElementTest.java b/src/test/java/org/htmlunit/javascript/host/html/HTMLTableCellElementTest.java index 311166c4114..4c78db8bca5 100644 --- a/src/test/java/org/htmlunit/javascript/host/html/HTMLTableCellElementTest.java +++ b/src/test/java/org/htmlunit/javascript/host/html/HTMLTableCellElementTest.java @@ -409,9 +409,7 @@ public void colSpanLarge() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"1", "3", "1", "2", "1", "5", "1", "2", "1"}, - CHROME = {"1", "3", "1", "2", "0", "5", "1", "2", "0"}, - EDGE = {"1", "3", "1", "2", "0", "5", "1", "2", "0"}) + @Alerts({"1", "3", "1", "2", "0", "5", "1", "2", "0"}) public void rowSpan() throws Exception { final String html = DOCTYPE_HTML + "\n" @@ -483,9 +481,7 @@ public void rowSpanLineBreaks() throws Exception { * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"1", "0", "3", "3", "3"}, - FF = {"1", "1", "3", "3", "3"}, - FF_ESR = {"1", "1", "3", "3", "3"}) + @Alerts({"1", "0", "3", "3", "3"}) public void rowSpanInvalid() throws Exception { final String html = DOCTYPE_HTML + "
\n" diff --git a/src/test/java/org/htmlunit/javascript/host/intl/DateTimeFormatTest.java b/src/test/java/org/htmlunit/javascript/host/intl/DateTimeFormatTest.java index a52b3399189..662f0ad5aad 100644 --- a/src/test/java/org/htmlunit/javascript/host/intl/DateTimeFormatTest.java +++ b/src/test/java/org/htmlunit/javascript/host/intl/DateTimeFormatTest.java @@ -271,7 +271,7 @@ public void timeZoneUTC() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "Etc/GMT+5", + @Alerts(DEFAULT = "America/Panama", FF = "EST", FF_ESR = "EST") @BuggyWebDriver(FF = "Europe/Berlin", FF_ESR = "Europe/Berlin") diff --git a/src/test/java/org/htmlunit/javascript/host/worker/WorkerNavigatorTest.java b/src/test/java/org/htmlunit/javascript/host/worker/WorkerNavigatorTest.java index 21b154488eb..200d61068a7 100644 --- a/src/test/java/org/htmlunit/javascript/host/worker/WorkerNavigatorTest.java +++ b/src/test/java/org/htmlunit/javascript/host/worker/WorkerNavigatorTest.java @@ -82,9 +82,9 @@ public void appName() throws Exception { */ @Test @Alerts(CHROME = "5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64)\\sAppleWebKit/537.36\\s" - + "(KHTML,\\slike\\sGecko)\\sChrome/134.0.0.0\\sSafari/537.36", + + "(KHTML,\\slike\\sGecko)\\sChrome/135.0.0.0\\sSafari/537.36", EDGE = "5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64)\\sAppleWebKit/537.36\\s" - + "(KHTML,\\slike\\sGecko)\\sChrome/134.0.0.0\\sSafari/537.36\\sEdg/134.0.0.0", + + "(KHTML,\\slike\\sGecko)\\sChrome/135.0.0.0\\sSafari/537.36\\sEdg/135.0.0.0", FF = "5.0\\s(Windows)", FF_ESR = "5.0\\s(Windows)") public void appVersion() throws Exception { @@ -161,10 +161,10 @@ public void product() throws Exception { */ @Test @Alerts(CHROME = "Mozilla/5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64)\\sAppleWebKit/537.36\\s" - + "(KHTML,\\slike\\sGecko)\\sChrome/134.0.0.0\\sSafari/537.36", + + "(KHTML,\\slike\\sGecko)\\sChrome/135.0.0.0\\sSafari/537.36", EDGE = "Mozilla/5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64)\\sAppleWebKit/537.36\\s" - + "(KHTML,\\slike\\sGecko)\\sChrome/134.0.0.0\\sSafari/537.36\\sEdg/134.0.0.0", - FF = "Mozilla/5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64;\\srv:136.0)\\sGecko/20100101\\sFirefox/136.0", + + "(KHTML,\\slike\\sGecko)\\sChrome/135.0.0.0\\sSafari/537.36\\sEdg/135.0.0.0", + FF = "Mozilla/5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64;\\srv:137.0)\\sGecko/20100101\\sFirefox/137.0", FF_ESR = "Mozilla/5.0\\s(Windows\\sNT\\s10.0;\\sWin64;\\sx64;\\srv:128.0)\\sGecko/20100101\\sFirefox/128.0") public void userAgent() throws Exception { final String workerJs = "postMessage(navigator.userAgent);\n"; diff --git a/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest3Test.java b/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest3Test.java index ef3c2a93f0c..e4e3c1699a3 100644 --- a/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest3Test.java +++ b/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest3Test.java @@ -42,7 +42,6 @@ import org.htmlunit.html.DomElement; import org.htmlunit.html.HtmlElement; import org.htmlunit.html.HtmlPage; -import org.htmlunit.html.HtmlSubmitInput; import org.htmlunit.javascript.host.xml.XMLHttpRequestTest.StreamingServlet; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.annotation.Alerts; @@ -405,7 +404,7 @@ public void ajaxInfluencesSubmitHeaders() throws Exception { while (STATE_ < 1) { Thread.sleep(42); } - ((HtmlSubmitInput) elem).click(); + elem.click(); client.waitForBackgroundJavaScript(DEFAULT_WAIT_TIME.toMillis()); assertEquals(COLLECTED_HEADERS.toString(), 2, COLLECTED_HEADERS.size()); diff --git a/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest5Test.java b/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest5Test.java index 0a5def8890d..ad0200a170c 100644 --- a/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest5Test.java +++ b/src/test/java/org/htmlunit/javascript/host/xml/XMLHttpRequest5Test.java @@ -300,7 +300,7 @@ public void sendLocalFileAsync() throws Exception { public void sendXMLDocumentEmpty() throws Exception { final String createXmlDoc = " var doc = document.implementation.createDocument('', '', null);\n"; - sendXMLDocument(createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); + sendXMLDocument(DOCTYPE_HTML, createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); } /** @@ -313,7 +313,7 @@ public void sendXMLDocumentRoot() throws Exception { " var doc = document.implementation.createDocument('', '', null);\n" + " var root = doc.createElement('root');\n" + " doc.appendChild(root);\n"; - sendXMLDocument(createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); + sendXMLDocument(DOCTYPE_HTML, createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); } /** @@ -336,32 +336,32 @@ public void sendXMLDocumentRootNamespace() throws Exception { + " var body = document.createElementNS('http://www.w3.org/1999/xhtml', 'body');\n" + " body.setAttribute('id', 'abc');\n" + " doc.documentElement.appendChild(body);\n"; - sendXMLDocument(createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); + sendXMLDocument(DOCTYPE_HTML, createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = {"text/html;charset=UTF-8", - "" - + "foo\n" - + "\n" - + ""}, - FF = {"text/html;charset=UTF-8", - "" - + "foo\n" + + "\n" + + ""}) + @HtmlUnitNYI(CHROME = {"text/html;charset=UTF-8", + "" + + "foo\n" + + "" + "\n" + ""}, - FF_ESR = {"text/html;charset=UTF-8", - "" - + "foo\n" - + "\n" - + ""}) + EDGE = {"text/html;charset=UTF-8", + "" + + "foo" + + "\n" + + ""}, + FF = {"text/html;charset=UTF-8", + "" + + "foo" + + "\n" + + ""}, + FF_ESR = {"text/html;charset=UTF-8", + "" + + "foo" + + "\n" + + ""}) + public void sendDocument() throws Exception { + final String createXmlDoc = + " var doc = document;\n"; + sendXMLDocument(DOCTYPE_HTML, createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); + } + + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"text/html;charset=UTF-8", + "foo\n" + + "\n" + + ""}) @HtmlUnitNYI(CHROME = {"text/html;charset=UTF-8", - "foo" + "\n" + ""}) - public void sendDocument() throws Exception { + public void sendDocumentNoDoctype() throws Exception { final String createXmlDoc = " var doc = document;\n"; - sendXMLDocument(createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); + sendXMLDocument("", createXmlDoc, getExpectedAlerts()[0], getExpectedAlerts()[1]); } - private void sendXMLDocument(final String createXmlDoc, + private void sendXMLDocument(final String doctype, final String createXmlDoc, final String expectedMimeType, final String expectedBody) throws Exception { startWebServer(getMockWebConnection(), Charset.defaultCharset()); final String url = URL_SECOND.toString(); - final String html = DOCTYPE_HTML + final String html = doctype + "foo" + "