diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml
index 205db2f9460..61afd4de5a2 100644
--- a/.github/workflows/checkstyle.yml
+++ b/.github/workflows/checkstyle.yml
@@ -22,12 +22,12 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up JDK
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
java-version: 21
distribution: 'temurin'
cache: maven
- - uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v0.20.1
+ - uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v0.20.1
name: Set up reviewdog
with:
reviewdog_version: latest
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index c557dc66663..50c0767f714 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -24,12 +24,12 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up JDK ${{ matrix.Java }}
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
java-version: ${{ matrix.Java }}
distribution: 'temurin'
cache: maven
- - uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v0.20.1
+ - uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v0.20.1
name: Set up reviewdog
with:
reviewdog_version: latest
diff --git a/.github/workflows/pmd.yml b/.github/workflows/pmd.yml
index 9aaf21e9ff6..8e2105e7af5 100644
--- a/.github/workflows/pmd.yml
+++ b/.github/workflows/pmd.yml
@@ -20,12 +20,12 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up JDK
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
java-version: 21
distribution: 'temurin'
cache: maven
- - uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v0.20.1
+ - uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v0.20.1
name: Set up reviewdog
with:
reviewdog_version: latest
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
index 16327d49eb5..71154a0b1f3 100644
--- a/.github/workflows/scorecard.yml
+++ b/.github/workflows/scorecard.yml
@@ -37,7 +37,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
- uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
+ uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
with:
results_file: results.sarif
results_format: sarif
diff --git a/README.md b/README.md
index ae6660d8b40..6b62d79ccd8 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# 
-Version 4.10.0 / February 22, 2025
+Version 4.11.0 / March 25, 2025
:heart: [Sponsor](https://github.com/sponsors/rbri)
@@ -51,7 +51,7 @@ Add to your `pom.xml`:
@@ -257,7 +238,7 @@ public Charset getContentCharset() {
* For example, HTML meta-tag sniffing can be fooled by text that looks-like-a-meta-tag inside
* JavaScript code (false positive) or if the meta-tag is after the first 1024 bytes (false negative).
* @return {@code true} if the charset of the previous call to {@link #getContentCharset()} was
- * "tentative".
+ * "tentative".
* @see
* https://html.spec.whatwg.org/multipage/parsing.html#concept-encoding-confidence
*/
@@ -268,7 +249,7 @@ public boolean wasContentCharsetTentative() {
/**
* Returns the response content as a string, using the charset/encoding specified in the server response.
* @return the response content as a string, using the charset/encoding specified in the server response
- * or null if the content retrieval was failing
+ * or null if the content retrieval was failing
*/
public String getContentAsString() {
return getContentAsString(getContentCharset());
@@ -362,15 +343,6 @@ public void cleanUp() {
}
}
- /**
- * Mark this response for using UTF-8 as default charset.
- * @deprecated as of version 4.0.0; use {@link WebRequest#setDefaultResponseContentCharset(Charset)} instead
- */
- @Deprecated
- public void defaultCharsetUtf8() {
- getWebRequest().setDefaultResponseContentCharset(UTF_8);
- }
-
/**
* @return true if the 2xx
*/
diff --git a/src/main/java/org/htmlunit/WebResponseData.java b/src/main/java/org/htmlunit/WebResponseData.java
index 6dab15f7ff7..6f55e37a4ab 100644
--- a/src/main/java/org/htmlunit/WebResponseData.java
+++ b/src/main/java/org/htmlunit/WebResponseData.java
@@ -113,7 +113,7 @@ private InputStream getStream(final ByteOrderMark... bomHeaders) throws IOExcept
LOG.error("Reading gzip encodec content failed.", e);
stream.close();
stream = IOUtils.toInputStream(
- "\n"
+ "\n"
+ "NodeIterator
over the subtree rooted at the
* specified node.
* @param root The node which will be iterated together with its
- * children. The NodeIterator
is initially positioned
- * just before this node. The whatToShow
flags and the
- * filter, if any, are not considered when setting this position. The
- * root must not be null
.
+ * children. The NodeIterator
is initially positioned
+ * just before this node. The whatToShow
flags and the
+ * filter, if any, are not considered when setting this position. The
+ * root must not be null
.
* @param whatToShow This flag specifies which node types may appear in
- * the logical view of the tree presented by the
- * NodeIterator
. See the description of
- * NodeFilter
for the set of possible SHOW_
- * values.These flags can be combined using OR
.
+ * the logical view of the tree presented by the
+ * NodeIterator
. See the description of
+ * NodeFilter
for the set of possible SHOW_
+ * values.These flags can be combined using OR
.
* @param filter The NodeFilter
to be used with this
- * NodeIterator
, or null
to indicate no
- * filter.
+ * NodeIterator
, or null
to indicate no
+ * filter.
* @param entityReferenceExpansion The value of this flag determines
- * whether entity reference nodes are expanded.
+ * whether entity reference nodes are expanded.
* @return The newly created NodeIterator
.
* @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if the specified root
is
- * null
.
+ * NOT_SUPPORTED_ERR: Raised if the specified root
is null
.
*/
public DomNodeIterator createNodeIterator(final Node root, final int whatToShow, final NodeFilter filter,
final boolean entityReferenceExpansion) throws DOMException {
diff --git a/src/main/java/org/htmlunit/TopLevelWindow.java b/src/main/java/org/htmlunit/TopLevelWindow.java
index 5baeb31fc91..178006f2c30 100644
--- a/src/main/java/org/htmlunit/TopLevelWindow.java
+++ b/src/main/java/org/htmlunit/TopLevelWindow.java
@@ -115,7 +115,7 @@ public void close() {
*
* Closes this window.
* @param ignoreOnbeforeunloadAccepted if true the result of triggering the OnbeforeunloadAccepted event
- * will be ignored
+ * will be ignored
*/
public void close(final boolean ignoreOnbeforeunloadAccepted) {
final Page page = getEnclosedPage();
diff --git a/src/main/java/org/htmlunit/WebClient.java b/src/main/java/org/htmlunit/WebClient.java
index 1eeed75862b..15972c06e64 100644
--- a/src/main/java/org/htmlunit/WebClient.java
+++ b/src/main/java/org/htmlunit/WebClient.java
@@ -589,7 +589,7 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
* @param webResponse the response that will be used to create the new page
* @param webWindow the window that the new page will be placed within
* @param forceAttachmentWithFilename if not {@code null}, handle this as an attachment with the specified name
- * or if an empty string ("") use the filename provided in the response
+ * or if an empty string ("") use the filename provided in the response
* @throws IOException if an IO error occurs
* @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property
* {@link WebClientOptions#setThrowExceptionOnFailingStatusCode(boolean)} is set to true
@@ -2080,7 +2080,7 @@ public void setClipboardHandler(final ClipboardHandler handler) {
/**
* Returns the current {@link PrintHandler}.
* @return the current {@link PrintHandler} or null if print
- * requests are ignored
+ * requests are ignored
*/
public PrintHandler getPrintHandler() {
return printHandler_;
@@ -2091,7 +2091,7 @@ public PrintHandler getPrintHandler() {
* (Printing Spec).
*
* @param handler the new {@link PrintHandler} or null if you like to
- * ignore print requests (default is null)
+ * ignore print requests (default is null)
*/
public void setPrintHandler(final PrintHandler handler) {
printHandler_ = handler;
@@ -2591,7 +2591,7 @@ public boolean isOutdated() {
* @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
+ * 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,
@@ -2892,7 +2892,7 @@ public XHtmlPage loadXHtmlCodeIntoCurrentWindow(final String xhtmlCode) throws I
* INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
*
* @return a CSS3Parser that will return to an internal pool for reuse if closed using the
- * try-with-resource concept
+ * try-with-resource concept
*/
public PooledCSS3Parser getCSS3Parser() {
return this.css3ParserPool_.get();
diff --git a/src/main/java/org/htmlunit/WebClientOptions.java b/src/main/java/org/htmlunit/WebClientOptions.java
index 88a5a02cf9a..a1a1237243d 100644
--- a/src/main/java/org/htmlunit/WebClientOptions.java
+++ b/src/main/java/org/htmlunit/WebClientOptions.java
@@ -640,8 +640,8 @@ public int getHistoryPageCacheLimit() {
* entries in the history. For older entries only the url is saved; the page
* will be (re)retrieved on demand.
* @param historyPageCacheLimit maximum number of pages to cache in history
- * default is Integer.MAX_VALUE; negative values are having the same effect
- * as setting this to zero.
+ * default is Integer.MAX_VALUE; negative values are having the same effect
+ * as setting this to zero.
*/
public void setHistoryPageCacheLimit(final int historyPageCacheLimit) {
historyPageCacheLimit_ = historyPageCacheLimit;
@@ -853,6 +853,9 @@ public void setGeolocation(final Geolocation geolocation) {
geolocation_ = geolocation;
}
+ /**
+ * Support class for Geolocation.
+ */
public static class Geolocation implements Serializable {
private final double accuracy_;
private final double latitude_;
diff --git a/src/main/java/org/htmlunit/WebRequest.java b/src/main/java/org/htmlunit/WebRequest.java
index 22777886591..e07f4fd775b 100644
--- a/src/main/java/org/htmlunit/WebRequest.java
+++ b/src/main/java/org/htmlunit/WebRequest.java
@@ -56,6 +56,9 @@
*/
public class WebRequest implements Serializable {
+ /**
+ * Enum to configure request creation.
+ */
public enum HttpHint {
/** Force to include the charset. */
IncludeCharsetInContentTypeHeader,
@@ -456,7 +459,7 @@ public String getRequestBody() {
* Other request types result in {@link RuntimeException}.
* Should not be used in combination with {@link #setRequestParameters(List) request parameters}.
* @param requestBody the body content to be submitted if this is a {@code POST}, {@code PUT}
- * or {@code PATCH} request
+ * or {@code PATCH} request
* @throws RuntimeException if the request parameters have already been set
* or this is not a {@code POST}, {@code PUT} or {@code PATCH} request.
*/
@@ -655,6 +658,10 @@ public void setDefaultResponseContentCharset(final Charset defaultResponseConten
this.defaultResponseContentCharset_ = Objects.requireNonNull(defaultResponseContentCharset);
}
+ /**
+ * @param hint the hint to check for
+ * @return true if the hint is enabled
+ */
public boolean hasHint(final HttpHint hint) {
if (httpHints_ == null) {
return false;
@@ -662,6 +669,10 @@ public boolean hasHint(final HttpHint hint) {
return httpHints_.contains(hint);
}
+ /**
+ * Enables the hint.
+ * @param hint the hint to add
+ */
public void addHint(final HttpHint hint) {
if (httpHints_ == null) {
httpHints_ = EnumSet.noneOf(HttpHint.class);
diff --git a/src/main/java/org/htmlunit/WebResponse.java b/src/main/java/org/htmlunit/WebResponse.java
index 9224b2efe3e..80ce54b66d5 100644
--- a/src/main/java/org/htmlunit/WebResponse.java
+++ b/src/main/java/org/htmlunit/WebResponse.java
@@ -174,25 +174,6 @@ public Charset getHeaderContentCharset() {
return EncodingSniffer.extractEncodingFromContentType(contentType);
}
- /**
- * Returns the content charset specified explicitly in the header or in the content,
- * or {@code null} if none was specified.
- * @return the content charset specified explicitly in the header or in the content,
- * or {@code null} if none was specified
- *
- * @deprecated as of version 4.0.0; use {@link #getContentCharset()} instead
- */
- @Deprecated
- public Charset getContentCharsetOrNull() {
- try (InputStream is = getContentAsStream()) {
- return EncodingSniffer.sniffEncoding(getResponseHeaders(), is);
- }
- catch (final IOException e) {
- LOG.warn("Error trying to sniff encoding.", e);
- return null;
- }
- }
-
/**
* Returns the content charset for this response, even if no charset was specified explicitly.
* Content Encoding Error
\n"
@@ -136,7 +136,7 @@ private InputStream getStream(final ByteOrderMark... bomHeaders) throws IOExcept
LOG.error("Reading Brotli encodec content failed.", e);
stream.close();
stream = IOUtils.toInputStream(
- "\n"
+ "\n"
+ "Content Encoding Error
\n"
diff --git a/src/main/java/org/htmlunit/WebWindow.java b/src/main/java/org/htmlunit/WebWindow.java
index b1660b2ff5d..09612fd7ce4 100644
--- a/src/main/java/org/htmlunit/WebWindow.java
+++ b/src/main/java/org/htmlunit/WebWindow.java
@@ -71,7 +71,7 @@ public interface WebWindow extends Serializable {
* is a top level window, then return this window.
*
* @return the top level window that contains this window or this
- * window if there is no parent.
+ * window if there is no parent.
*/
WebWindow getTopWindow();
@@ -187,15 +187,15 @@ public interface WebWindow extends Serializable {
Screen getScreen();
/**
- * INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
- *
+ * INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
+ *
* Returns computed style of the element. Computed style represents the final computed values
* of all CSS properties for the element. This method's return value is of the same type as
* that of element.style
, but the value returned by this method is read-only.
*
* @param element the element
* @param pseudoElement a string specifying the pseudo-element to match (may be {@code null});
- * e.g. ':before'
+ * e.g. ':before'
* @return the computed style
*/
ComputedCssStyleDeclaration getComputedStyle(DomElement element, String pseudoElement);
diff --git a/src/main/java/org/htmlunit/WebWindowEvent.java b/src/main/java/org/htmlunit/WebWindowEvent.java
index 4af175d9b3e..bbe17d7b1dc 100644
--- a/src/main/java/org/htmlunit/WebWindowEvent.java
+++ b/src/main/java/org/htmlunit/WebWindowEvent.java
@@ -169,7 +169,9 @@ public String toString() {
return builder.toString();
}
- /** @return the event type */
+ /**
+ * @return the event type
+ */
public int getEventType() {
return type_;
}
diff --git a/src/main/java/org/htmlunit/WebWindowListener.java b/src/main/java/org/htmlunit/WebWindowListener.java
index 07fa3d376c7..0cb8868d4f1 100644
--- a/src/main/java/org/htmlunit/WebWindowListener.java
+++ b/src/main/java/org/htmlunit/WebWindowListener.java
@@ -37,7 +37,7 @@ public interface WebWindowListener {
* This usually takes place AFTER the event was processed
P click(final Event event,
* @param ctrlKey {@code true} if CTRL is pressed
*
* @return true if doClickFireEvent method has to be called later on (to signal,
- * that the value was changed)
+ * that the value was changed)
* @throws IOException if an IO error occurs
*/
protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException {
@@ -1197,11 +1203,9 @@ protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlK
}
/**
- * @see #doClickStateUpdate(boolean, boolean)
- * Usually the click is propagated to the parent. Overwrite if you
- * like to disable this.
- *
+ * Usually the click is propagated to the parent. Overwrite if you like to disable this.
* @return true or false
+ * @see #doClickStateUpdate(boolean, boolean)
*/
protected boolean propagateClickStateUpdateToParent() {
return true;
diff --git a/src/main/java/org/htmlunit/html/DomNode.java b/src/main/java/org/htmlunit/html/DomNode.java
index 0ddd78fbd78..019fee9bbbb 100644
--- a/src/main/java/org/htmlunit/html/DomNode.java
+++ b/src/main/java/org/htmlunit/html/DomNode.java
@@ -207,7 +207,7 @@ public int getStartColumnNumber() {
/**
* Returns the line number in the source page where the DOM node ends.
* @return 0 if no information on the line number is available (for instance for nodes dynamically added),
- * -1 if the end tag has not yet been parsed (during page loading)
+ * -1 if the end tag has not yet been parsed (during page loading)
*/
public int getEndLineNumber() {
return endLineNumber_;
@@ -216,7 +216,7 @@ public int getEndLineNumber() {
/**
* Returns the column number in the source page where the DOM node ends.
* @return 0 if no information on the line number is available (for instance for nodes dynamically added),
- * -1 if the end tag has not yet been parsed (during page loading)
+ * -1 if the end tag has not yet been parsed (during page loading)
*/
public int getEndColumnNumber() {
return endColumnNumber_;
@@ -1244,11 +1244,11 @@ public void quietlyRemoveAndMoveChildrenTo(final DomNode destination) {
*
* @param newChild the new child node that is being inserted below this node
* @throws DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
- * not allow children of the type of the newChild node, or if the node to insert is one of
- * this node's ancestors or this node itself, or if this node is of type Document and the
- * DOM application attempts to insert a second DocumentType or Element node.
- * WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the
- * one that created this node.
+ * not allow children of the type of the newChild node, or if the node to insert is one of
+ * this node's ancestors or this node itself, or if this node is of type Document and the
+ * DOM application attempts to insert a second DocumentType or Element node.
+ * WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the
+ * one that created this node.
*/
protected void checkChildHierarchy(final Node newChild) throws DOMException {
Node parentNode = this;
@@ -1391,7 +1391,7 @@ public final Iterable
*
- * The following elements support the
+ * The following elements support the the page type
* @return the page contained in the current window as returned
- * by {@link org.htmlunit.WebClient#getCurrentWindow()}
+ * by {@link org.htmlunit.WebClient#getCurrentWindow()}
*/
public P setSelectedAttribute(final String optionValue, final boolean isSelected) {
return setSelectedAttribute(optionValue, isSelected, true);
@@ -294,7 +294,7 @@ public P setSelectedAttribute(final String optionValue, final b
* @param invokeOnFocus whether to set focus or not.
* @param the page type
* @return the page contained in the current window as returned
- * by {@link org.htmlunit.WebClient#getCurrentWindow()}
+ * by {@link org.htmlunit.WebClient#getCurrentWindow()}
*/
@SuppressWarnings("unchecked")
public P setSelectedAttribute(final String optionValue,
@@ -321,7 +321,7 @@ public P setSelectedAttribute(final String optionValue,
* @param selectedOption the value of the option that is to change
* @param the page type
* @return the page contained in the current window as returned
- * by {@link org.htmlunit.WebClient#getCurrentWindow()}
+ * by {@link org.htmlunit.WebClient#getCurrentWindow()}
*/
public P setSelectedAttribute(final HtmlOption selectedOption, final boolean isSelected) {
return setSelectedAttribute(selectedOption, isSelected, true, true, false, true);
@@ -343,7 +343,7 @@ public P setSelectedAttribute(final HtmlOption selectedOption,
* @param isClick is mouse clicked
* @param the page type
* @return the page contained in the current window as returned
- * by {@link org.htmlunit.WebClient#getCurrentWindow()}
+ * by {@link org.htmlunit.WebClient#getCurrentWindow()}
*/
@SuppressWarnings("unchecked")
public P setSelectedAttribute(final HtmlOption selectedOption, final boolean isSelected,
diff --git a/src/main/java/org/htmlunit/html/HtmlTable.java b/src/main/java/org/htmlunit/html/HtmlTable.java
index 71731bd5601..a656ed38ebb 100644
--- a/src/main/java/org/htmlunit/html/HtmlTable.java
+++ b/src/main/java/org/htmlunit/html/HtmlTable.java
@@ -235,7 +235,7 @@ public List
HtmlUnit is used by many projects for automated web testing
- jenkins-test-harness,
- Apache Shiro,
- Apache Struts,
- Quarkus,
- Togglz,
- Dataverse,
- Janssen Project,
- Apache TomEE,
- Apache Maven Surefire,
- JSCover,
- Apache Jackrabbit,
- OpenXava
- Cargo, ...
+ tabindex
attribute: A, AREA, BUTTON,
- * INPUT, OBJECT, SELECT, and TEXTAREA.tabindex
attribute:
+ * A, AREA, BUTTON, INPUT, OBJECT, SELECT, and TEXTAREA.
*
* @return all the tabbable elements in proper tab order
*/
@@ -908,7 +906,7 @@ public List
*
* @return a list of all styles from this page (<style> and <link rel=stylesheet>).
- * This returns an empty list if css support is disabled in the web client options.
+ * This returns an empty list if css support is disabled in the web client options.
*/
public List
+
HtmlUnit was originally written by @@ -75,17 +85,16 @@ Gargoyle Software and is released under the Apache 2 license. Since then, it has received many contributions from - other developers, and would not be where it is today without their - assistance. + other developers, and would not be where it is today without their assistance.
+ For gradle, you would add:
+
If you like to use the latest available snapshot build you have to add the sonatype snapshot repository to your pom repositories section; also (check diff --git a/src/test/java/org/htmlunit/BrowserVersion2Test.java b/src/test/java/org/htmlunit/BrowserVersion2Test.java index 605de1a522a..f391575f695 100644 --- a/src/test/java/org/htmlunit/BrowserVersion2Test.java +++ b/src/test/java/org/htmlunit/BrowserVersion2Test.java @@ -18,7 +18,6 @@ import java.util.Map; import java.util.Map.Entry; -import org.htmlunit.html.HtmlPageTest; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.annotation.Alerts; import org.htmlunit.util.MimeType; @@ -47,7 +46,7 @@ public class BrowserVersion2Test extends WebDriverTestCase { FF = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", FF_ESR = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") public void acceptHeaderGetUrl() throws Exception { - final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + final String html = DOCTYPE_HTML + "
Response"; loadPage2(html); @@ -64,11 +63,11 @@ public void acceptHeaderGetUrl() throws Exception { FF = {"2", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}, FF_ESR = {"2", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}) public void acceptHeaderWindowOpen() throws Exception { - String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + String html = DOCTYPE_HTML + "Response"; getMockWebConnection().setDefaultResponse(html); - html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + html = DOCTYPE_HTML + "Cookie Domain Test
\n" @@ -678,7 +687,8 @@ public void domain3() throws Exception { responseHeader1.add(new NameValuePair("Set-Cookie", "c4=4; Domain=" + DOMAIN + "; Path=/")); responseHeader1.add(new NameValuePair("Set-Cookie", "c5=5; Domain=.org; Path=/")); - final String html = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" + "\n" + "Cookie Domain Test
\n" @@ -705,7 +715,8 @@ public void differentHostsSameDomain() throws Exception { final ListCookie Domain Test
\n" @@ -729,7 +740,8 @@ public void differentHostsSameDomain() throws Exception { @Test @Alerts("cross-domain=1") public void differentHostsSameDomainCookieFromJS() throws Exception { - final String html = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" + "\n" + "\n" @@ -755,7 +767,8 @@ public void differentHostsSameDomainCookieFromJS() throws Exception { @Test @Alerts("cross-domain=1") public void differentHostsSameDomainCookieFromMeta() throws Exception { - final String html = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" + " \n" + "\n" @@ -947,7 +960,7 @@ public void sameSiteIncludeFromSameDomain() throws Exception { responseHeader.add(new NameValuePair("Set-Cookie", "c4=empty; SameSite=")); responseHeader.add(new NameValuePair("Set-Cookie", "c5=unknown; SameSite=unknown")); - final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + final String html = DOCTYPE_HTML + "\n" + " \n" + "\n" @@ -1002,7 +1015,7 @@ public void sameSiteIncludeFromSubDomain() throws Exception { responseHeader.add(new NameValuePair("Set-Cookie", "c4=empty; SameSite=")); responseHeader.add(new NameValuePair("Set-Cookie", "c5=unknown; SameSite=unknown")); - final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + final String html = DOCTYPE_HTML + "\n" + " \n" + "\n" @@ -1057,7 +1070,7 @@ public void sameSiteIFrameFromSameDomain() throws Exception { responseHeader.add(new NameValuePair("Set-Cookie", "c4=empty; SameSite=")); responseHeader.add(new NameValuePair("Set-Cookie", "c5=unknown; SameSite=unknown")); - final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + final String html = DOCTYPE_HTML + "\n" + "\n" + "\n" @@ -1112,7 +1125,7 @@ public void sameSiteIFrameFromSubDomain() throws Exception { responseHeader.add(new NameValuePair("Set-Cookie", "c4=empty; SameSite=")); responseHeader.add(new NameValuePair("Set-Cookie", "c5=unknown; SameSite=unknown")); - final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + final String html = DOCTYPE_HTML + "\n" + "\n" + "\n" @@ -1162,7 +1175,8 @@ public void issue270() throws Exception { final Listhello world
\n" @@ -118,7 +118,8 @@ public void handleAlert(final Page page, final String message) { public void scriptPreProcessor_UnimplementedJavascript() throws Exception { final WebClient client = getWebClient(); final MockWebConnection webConnection = new MockWebConnection(); - final String content = "hello world
\n" + "\n" + "\n" @@ -151,7 +152,8 @@ public String preProcess(final HtmlPage htmlPage, final String sourceCode, final */ @Test public void scriptPreProcessor_Eval() throws Exception { - final String html = ""; + final String html = DOCTYPE_HTML + + ""; final WebClient client = getWebClient(); final MockWebConnection conn = new MockWebConnection(); diff --git a/src/test/java/org/htmlunit/SgmlPage2Test.java b/src/test/java/org/htmlunit/SgmlPage2Test.java index 6611c52eaa8..f001c11f17d 100644 --- a/src/test/java/org/htmlunit/SgmlPage2Test.java +++ b/src/test/java/org/htmlunit/SgmlPage2Test.java @@ -36,7 +36,8 @@ public final class SgmlPage2Test extends WebDriverTestCase { @Test @Alerts({"2", "2"}) public void getElementsByTagName() throws Exception { - final String html = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" @@ -50,8 +50,8 @@ public void localStorage() throws Exception { assertEquals(1, localStorage.size()); assertEquals("Tom", localStorage.get("myCat")); - html - = "\n" + html = DOCTYPE_HTML + + "\n" + "\n" @@ -73,8 +73,8 @@ public void populateLocalStorage() throws Exception { localStorage.put("myCat", "Tom"); - final String html - = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" @@ -96,8 +96,8 @@ public void sessionStorage() throws Exception { webClient.getStorageHolder().getSessionStorage(webClient.getCurrentWindow()); assertEquals(0, sessionStorage.size()); - String html - = "\n" + String html = DOCTYPE_HTML + + "\n" + "\n" @@ -107,8 +107,8 @@ public void sessionStorage() throws Exception { assertEquals(1, sessionStorage.size()); assertEquals("Tom", sessionStorage.get("myCat")); - html - = "\n" + html = DOCTYPE_HTML + + "\n" + "\n" @@ -131,8 +131,8 @@ public void populateSessionStorage() throws Exception { sessionStorage.put("myCat", "Tom"); - final String html - = "\n" + final String html = DOCTYPE_HTML + + "\n" + "\n" diff --git a/src/test/java/org/htmlunit/StringWebResponseTest.java b/src/test/java/org/htmlunit/StringWebResponseTest.java index aa18ba7af65..a19a1cf3159 100644 --- a/src/test/java/org/htmlunit/StringWebResponseTest.java +++ b/src/test/java/org/htmlunit/StringWebResponseTest.java @@ -43,6 +43,9 @@ public void charset() { assertSame(UTF_8, webResponse.getContentCharset()); } + /** + * @throws Exception if the test fails + */ @Test public void charsetImplicit() { final StringWebResponse webResponse = new StringWebResponse("hello", URL_FIRST); @@ -54,7 +57,8 @@ public void charsetImplicit() { */ @Test public void charsetInContent() { - final String content = "\n" + final String content = DOCTYPE_HTML + + "\n" + "\n" + "\u010C\u00CDSLO"; final StringWebResponse webResponse = new StringWebResponse(content, UTF_8, URL_FIRST); @@ -63,9 +67,13 @@ public void charsetInContent() { assertEquals(content, webResponse.getContentAsString()); } + /** + * @throws Exception if the test fails + */ @Test public void charsetInContentImplicit() { - final String content = "\n" + final String content = DOCTYPE_HTML + + "\n" + "\n" + "\u010C\u00CDSLO"; final StringWebResponse webResponse = new StringWebResponse(content, URL_FIRST); @@ -75,11 +83,12 @@ public void charsetInContentImplicit() { } /** - * @throws IOException + * @throws IOException in case of error */ @Test public void inputStream() throws IOException { - final String content = "\n" + final String content = DOCTYPE_HTML + + "\n" + "\n" + "\u010C\u00CDSLO"; final StringWebResponse webResponse = new StringWebResponse(content, URL_FIRST); diff --git a/src/test/java/org/htmlunit/TopLevelWindowTest.java b/src/test/java/org/htmlunit/TopLevelWindowTest.java index 6cdbe6a52c2..49e837ab55b 100644 --- a/src/test/java/org/htmlunit/TopLevelWindowTest.java +++ b/src/test/java/org/htmlunit/TopLevelWindowTest.java @@ -191,7 +191,8 @@ public void webWindowClosed(final WebWindowEvent event) { window.setJobManager(mgr); final MockWebConnection conn = getMockWebConnection(); - conn.setDefaultResponse(""); + conn.setDefaultResponse(DOCTYPE_HTML + + ""); client.getPage(URL_FIRST); assertEquals(1, jobCount.intValue()); @@ -210,10 +211,13 @@ public void history() throws Exception { final History history = window.getHistory(); final MockWebConnection conn = getMockWebConnection(); - conn.setResponse(URL_FIRST, "foo\n" - + "bar"); - conn.setResponse(URL_SECOND, "foo"); - conn.setResponse(URL_THIRD, "foo"); + conn.setResponse(URL_FIRST, DOCTYPE_HTML + + "foo\n" + + "bar"); + conn.setResponse(URL_SECOND, DOCTYPE_HTML + + "foo"); + conn.setResponse(URL_THIRD, DOCTYPE_HTML + + "foo"); assertEquals(0, history.getLength()); assertEquals(-1, history.getIndex()); @@ -305,7 +309,7 @@ public void history() throws Exception { */ @Test public void onBeforeUnloadCalledOnClose() throws Exception { - final String html = "abc"; + final String html = DOCTYPE_HTML + "abc"; final List