Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#499: Upgrade to HtmlUnit 4.x #503

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
40 changes: 14 additions & 26 deletions doc/internal-doc/api.sig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Signature file v4.1
#Version 8.0.0
#Version 8.2.0

CLSS public abstract com.xceptance.xlt.api.actions.AbstractAction
cons protected init(com.xceptance.xlt.api.actions.AbstractAction,java.lang.String)
Expand Down Expand Up @@ -2095,6 +2095,7 @@ cons public init(org.openqa.selenium.Capabilities,org.openqa.selenium.Capabiliti
fld public final static java.lang.String BROWSER_LANGUAGE_CAPABILITY = "browserLanguage"
fld public final static java.lang.String DOWNLOAD_IMAGES_CAPABILITY = "downloadImages"
fld public final static java.lang.String JAVASCRIPT_ENABLED = "javascriptEnabled"
innr protected HtmlUnitWebDriverOptions
innr protected abstract interface static JavaScriptResultsCollection
innr protected static ElementsMap
intf org.openqa.selenium.HasCapabilities
Expand Down Expand Up @@ -2349,6 +2350,12 @@ meth public static <%0 extends java.lang.Object> java.util.List<{%%0}> of({%%0},
meth public void replaceAll(java.util.function.UnaryOperator<{java.util.List%0}>)
meth public void sort(java.util.Comparator<? super {java.util.List%0}>)

CLSS public abstract interface !annotation org.jspecify.annotations.NullMarked
anno 0 java.lang.annotation.Documented()
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[MODULE, PACKAGE, TYPE, METHOD, CONSTRUCTOR])
intf java.lang.annotation.Annotation

CLSS public abstract interface !annotation org.junit.runner.RunWith
anno 0 java.lang.annotation.Inherited()
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
Expand Down Expand Up @@ -2376,43 +2383,21 @@ meth public abstract void downloadFile(java.lang.String,java.nio.file.Path) thro
meth public void requireDownloadsEnabled(org.openqa.selenium.Capabilities)

CLSS public abstract interface org.openqa.selenium.JavascriptExecutor
meth public !varargs java.lang.Object executeScript(org.openqa.selenium.ScriptKey,java.lang.Object[])
meth public abstract !varargs java.lang.Object executeAsyncScript(java.lang.String,java.lang.Object[])
meth public abstract !varargs java.lang.Object executeScript(java.lang.String,java.lang.Object[])
meth public java.util.Set<org.openqa.selenium.ScriptKey> getPinnedScripts()
meth public org.openqa.selenium.ScriptKey pin(java.lang.String)
meth public void unpin(org.openqa.selenium.ScriptKey)

CLSS public abstract interface org.openqa.selenium.PrintsPage
meth public abstract org.openqa.selenium.Pdf print(org.openqa.selenium.print.PrintOptions)

CLSS public abstract interface org.openqa.selenium.SearchContext
anno 0 org.jspecify.annotations.NullMarked()
meth public abstract java.util.List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By)
meth public abstract org.openqa.selenium.WebElement findElement(org.openqa.selenium.By)

CLSS public abstract interface org.openqa.selenium.TakesScreenshot
anno 0 org.jspecify.annotations.NullMarked()
meth public abstract <%0 extends java.lang.Object> {%%0} getScreenshotAs(org.openqa.selenium.OutputType<{%%0}>)

CLSS public abstract interface org.openqa.selenium.WebDriver
innr public abstract interface static Navigation
innr public abstract interface static Options
innr public abstract interface static TargetLocator
innr public abstract interface static Timeouts
innr public abstract interface static Window
intf org.openqa.selenium.SearchContext
meth public abstract java.lang.String getCurrentUrl()
meth public abstract java.lang.String getPageSource()
meth public abstract java.lang.String getTitle()
meth public abstract java.lang.String getWindowHandle()
meth public abstract java.util.List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By)
meth public abstract java.util.Set<java.lang.String> getWindowHandles()
meth public abstract org.openqa.selenium.WebDriver$Navigation navigate()
meth public abstract org.openqa.selenium.WebDriver$Options manage()
meth public abstract org.openqa.selenium.WebDriver$TargetLocator switchTo()
meth public abstract org.openqa.selenium.WebElement findElement(org.openqa.selenium.By)
meth public abstract void close()
meth public abstract void get(java.lang.String)
meth public abstract void quit()

CLSS public abstract interface org.openqa.selenium.bidi.HasBiDi
meth public abstract java.util.Optional<org.openqa.selenium.bidi.BiDi> maybeGetBiDi()
Expand Down Expand Up @@ -2609,6 +2594,7 @@ cons public init(java.net.URL,org.openqa.selenium.Capabilities,boolean)
cons public init(org.openqa.selenium.Capabilities)
cons public init(org.openqa.selenium.Capabilities,boolean)
cons public init(org.openqa.selenium.remote.CommandExecutor,org.openqa.selenium.Capabilities)
fld protected org.openqa.selenium.Capabilities capabilities
innr protected RemoteTargetLocator
innr protected RemoteWebDriverOptions
innr public final static !enum When
Expand Down Expand Up @@ -2654,6 +2640,8 @@ meth public org.openqa.selenium.federatedcredentialmanagement.FederatedCredentia
meth public org.openqa.selenium.remote.CommandExecutor getCommandExecutor()
meth public org.openqa.selenium.remote.ErrorHandler getErrorHandler()
meth public org.openqa.selenium.remote.FileDetector getFileDetector()
meth public org.openqa.selenium.remote.Network network()
meth public org.openqa.selenium.remote.Script script()
meth public org.openqa.selenium.remote.SessionId getSessionId()
meth public org.openqa.selenium.virtualauthenticator.VirtualAuthenticator addVirtualAuthenticator(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions)
meth public static org.openqa.selenium.remote.RemoteWebDriverBuilder builder()
Expand All @@ -2672,7 +2660,7 @@ meth public void setErrorHandler(org.openqa.selenium.remote.ErrorHandler)
meth public void setFileDetector(org.openqa.selenium.remote.FileDetector)
meth public void setLogLevel(java.util.logging.Level)
supr java.lang.Object
hfds LOG,capabilities,converter,elementLocation,errorHandler,executeMethod,executor,fileDetector,level,localLogs,remoteLogs,sessionId
hfds LOG,WEBDRIVER_REMOTE_ENABLE_TRACING,converter,elementLocation,errorHandler,executeMethod,executor,fileDetector,level,localLogs,remoteLogs,remoteNetwork,remoteScript,sessionId
hcls RemoteAlert,RemoteNavigation,RemoteVirtualAuthenticator

CLSS public abstract interface org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator
Expand Down
45 changes: 20 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<asm.version>9.4</asm.version>
<htmlunit.version>3.11.0</htmlunit.version>
<htmlunit.version>4.6.0</htmlunit.version>
<httpclient.version>4.5.14</httpclient.version>
<jetty.version>9.4.53.v20231009</jetty.version>
<log4j.version>2.22.1</log4j.version>
<jetty.version>9.4.56.v20240826</jetty.version>
<log4j.version>2.24.1</log4j.version>
<powermock.version>2.0.9</powermock.version>
<selenium.version>4.17.0</selenium.version>
<htmlunitdriver.version>4.17.0</htmlunitdriver.version>
<selenium.version>4.26.0</selenium.version>
<htmlunitdriver.version>4.26.0</htmlunitdriver.version>
<copyright>Copyright (c) ${project.inceptionYear}-2024 ${project.organization.name}</copyright>
</properties>

Expand Down Expand Up @@ -132,32 +132,32 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.16.1</version>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.17.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.0</version>
<version>1.3.4</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.10.0</version>
<version>3.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -185,6 +185,11 @@
<artifactId>htmlunit-cssparser</artifactId>
<version>${htmlunit.version}</version>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit-websocket-client</artifactId>
<version>${htmlunit.version}</version>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit-xpath</artifactId>
Expand All @@ -210,17 +215,7 @@
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>neko-htmlunit</artifactId>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.8.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>${jetty.version}</version>
<version>${htmlunit.version}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
Expand Down Expand Up @@ -538,14 +533,14 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>6.53.0</version>
<version>6.55.0</version>
<scope>test</scope>
</dependency>
<!-- HtmlUnit -->
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit4</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
Expand Down Expand Up @@ -595,7 +590,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.6.0</version>
<version>10.20.1</version>
<scope>test</scope>
</dependency>
<!-- Cobertura -->
Expand Down
1 change: 0 additions & 1 deletion samples/testsuite-performance/config/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ com.xceptance.xlt.http.responseId.headerName = X-XLT-ResponseId
## Indicates the browser to simulate. Possible values are:
## - "FF" ...... Firefox (default)
## - "FF_ESR" .. Firefox ESR
## - "IE" ...... Internet Explorer
## - "CH" ...... Chrome
## - "EDGE" .... Edge
## This setting is important for the user agent string and for the JavaScript
Expand Down
1 change: 0 additions & 1 deletion samples/testsuite-posters/config/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ com.xceptance.xlt.http.responseId.headerName = X-XLT-ResponseId
## Indicates the browser to simulate. Possible values are:
## - "FF" ...... Firefox (default)
## - "FF_ESR" .. Firefox ESR
## - "IE" ...... Internet Explorer
## - "CH" ...... Chrome
## - "EDGE" .... Edge
## This setting is important for the user agent string and for the JavaScript
Expand Down
1 change: 0 additions & 1 deletion samples/testsuite-showcases/config/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ com.xceptance.xlt.http.responseId.headerName = X-XLT-ResponseId
## Indicates the browser to simulate. Possible values are:
## - "FF" ...... Firefox (default)
## - "FF_ESR" .. Firefox ESR
## - "IE" ...... Internet Explorer
## - "CH" ...... Chrome
## - "EDGE" .... Edge
## This setting is important for the user agent string and for the JavaScript
Expand Down
1 change: 0 additions & 1 deletion samples/testsuite-template/config/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ com.xceptance.xlt.http.responseId.headerName = X-XLT-ResponseId
## Indicates the browser to simulate. Possible values are:
## - "FF" ...... Firefox (default)
## - "FF_ESR" .. Firefox ESR
## - "IE" ...... Internet Explorer
## - "CH" ...... Chrome
## - "EDGE" .... Edge
## This setting is important for the user agent string and for the JavaScript
Expand Down
1 change: 0 additions & 1 deletion samples/testsuite-xlt/config/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ com.xceptance.xlt.http.responseId.headerName = X-XLT-ResponseId
## Indicates the browser to simulate. Possible values are:
## - "FF" ...... Firefox (default)
## - "FF_ESR" .. Firefox ESR
## - "IE" ...... Internet Explorer
## - "CH" ...... Chrome
## - "EDGE" .... Edge
## This setting is important for the user agent string and for the JavaScript
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/xceptance/xlt/engine/XltJavaScriptEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public Object callFunction(final HtmlPage htmlPage, final Function function, fin
* {@inheritDoc}
*/
@Override
public Script compile(final HtmlPage htmlPage, final String sourceCode, final String sourceName, final int startLine)
public Script compile(final HtmlPage owningPage, final Scriptable scope, final String sourceCode, final String sourceName,
final int startLine)
{
Script script;

Expand All @@ -138,7 +139,7 @@ public Script compile(final HtmlPage htmlPage, final String sourceCode, final St
{
final String sourceFileName = getSourceFileName(sourceName, sourceCode);

script = compileScript(htmlPage, sourceCode, sourceName, startLine, sourceFileName);
script = compileScript(owningPage, scope, sourceCode, sourceName, startLine, sourceFileName);

// script can be null
if (script != null)
Expand All @@ -155,7 +156,7 @@ public Script compile(final HtmlPage htmlPage, final String sourceCode, final St
{
// someone messed around with our XltCache so we have to compile the script each time
final String sourceFileName = getSourceFileName(sourceName, sourceCode);
script = compileScript(htmlPage, sourceCode, sourceName, startLine, sourceFileName);
script = compileScript(owningPage, scope, sourceCode, sourceName, startLine, sourceFileName);
}

return script;
Expand All @@ -165,7 +166,7 @@ public Script compile(final HtmlPage htmlPage, final String sourceCode, final St
* {@inheritDoc}
*/
@Override
public Object execute(final HtmlPage htmlPage, final Script script)
public Object execute(final HtmlPage htmlPage, final Scriptable scope, final Script script)
{
final Object result;

Expand All @@ -177,7 +178,7 @@ public Object execute(final HtmlPage htmlPage, final Script script)

try
{
result = super.execute(htmlPage, script);
result = super.execute(htmlPage, scope, script);
}
finally
{
Expand All @@ -194,7 +195,7 @@ public Object execute(final HtmlPage htmlPage, final Script script)
}
else
{
result = super.execute(htmlPage, script);
result = super.execute(htmlPage, scope, script);
}

return result;
Expand All @@ -221,11 +222,12 @@ public HtmlUnitContextFactory getContextFactory()
* @param startLine
* the line at which the script source starts
* @param sourceFileName
* @param sourceFileName
* the source file name to use for logging
* @return the generated script
*/
private Script compileScript(final HtmlPage htmlPage, final String sourceCode, final String sourceName, final int startLine,
final String sourceFileName)
private Script compileScript(final HtmlPage owningPage, final Scriptable scope, final String sourceCode, final String sourceName,
final int startLine, String sourceFileName)
{
final Script script;

Expand All @@ -236,7 +238,7 @@ private Script compileScript(final HtmlPage htmlPage, final String sourceCode, f

try
{
script = super.compile(htmlPage, sourceCode, sourceName, startLine);
script = super.compile(owningPage, scope, sourceCode, sourceName, startLine);
}
catch (final RuntimeException e)
{
Expand All @@ -259,7 +261,7 @@ private Script compileScript(final HtmlPage htmlPage, final String sourceCode, f
}
else
{
script = super.compile(htmlPage, sourceCode, sourceName, startLine);
script = super.compile(owningPage, scope, sourceCode, sourceName, startLine);
}

return script;
Expand Down
Loading