Skip to content

Commit 94e6639

Browse files
committed
Update HtmlUnit to 4.11.1, update necessary dependencies
1 parent 15609b6 commit 94e6639

File tree

11 files changed

+100
-109
lines changed

11 files changed

+100
-109
lines changed

.github/workflows/full-check.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
- name: Checkout GWT tools into a sibling directory
3232
uses: actions/checkout@v4
3333
with:
34-
repository: 'gwtproject/tools'
34+
repository: 'zbynek/tools'
35+
ref: 'htmlunit-4'
3536
path: 'tools'
3637
- name: Set up JDK ${{ matrix.java-version }}
3738
# GWT requires Java 11+ to build

.github/workflows/quick-check.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
- name: Checkout GWT tools into a sibling directory
2020
uses: actions/checkout@v4
2121
with:
22-
repository: 'gwtproject/tools'
22+
repository: 'zbynek/tools'
23+
ref: 'htmlunit-4'
2324
path: 'tools'
2425
- name: Set up JDK ${{ matrix.java-version }}
2526
# GWT presently requires Java 11+ to build

dev/build.xml

+28-27
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,20 @@
8585
<include name="tomcat/tomcat-annotations-api-8.0.28.jar"/>
8686
<include name="apache/commons/commons-collections-3.2.2.jar"/>
8787
<!-- htmlunit dependencies not already included: BEGIN -->
88-
<include name="apache/http/httpclient-4.5.13.jar"/>
89-
<include name="apache/http/httpcore-4.4.13.jar"/>
90-
<include name="apache/http/httpmime-4.5.13.jar"/>
91-
<include name="apache/james/apache-mime4j-0.6.jar"/>
92-
<include name="apache/commons/commons-codec-1.10.jar"/>
93-
<include name="apache/commons/commons-io-2.4.jar"/>
94-
<include name="apache/commons/commons-lang3-3.4.jar"/>
95-
<include name="apache/commons/commons-logging-1.2.jar"/>
96-
<include name="htmlunit/htmlunit-2.55.0/htmlunit-cssparser-1.10.0.jar"/>
97-
<include name="htmlunit/htmlunit-2.55.0/htmlunit-2.55.0.jar"/>
98-
<include name="htmlunit/htmlunit-2.55.0/htmlunit-core-js-2.55.0.jar"/>
99-
<include name="htmlunit/htmlunit-2.55.0/neko-htmlunit-2.55.0.jar"/>
100-
<include name="htmlunit/htmlunit-2.55.0/salvation2-3.0.0.jar"/>
88+
<include name="apache/http/httpclient-4.5.14.jar"/>
89+
<include name="apache/http/httpcore-4.4.16.jar"/>
90+
<include name="apache/http/httpmime-4.5.14.jar"/>
91+
<include name="apache/commons/commons-codec-1.18.0.jar"/>
92+
<include name="apache/commons/commons-io-2.19.0.jar"/>
93+
<include name="apache/commons/commons-lang3-3.17.0.jar"/>
94+
<include name="apache/commons/commons-logging-1.3.5.jar"/>
95+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-cssparser-4.11.0.jar"/>
96+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-4.11.1.jar"/>
97+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-core-js-4.11.0.jar"/>
98+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-csp-4.11.0.jar"/>
99+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-websocket-client-4.11.0.jar"/>
100+
<include name="htmlunit/htmlunit-4.11.1/htmlunit-xpath-4.11.0.jar"/>
101+
<include name="htmlunit/htmlunit-4.11.1/neko-htmlunit-4.11.0.jar"/>
101102
<include name="cup/java-cup-11a.jar"/>
102103
<include name="xalan/xalan-2.7.1-nocup.jar"/>
103104
<include name="xerces/xerces-2_11_0/serializer-2.7.1.jar"/>
@@ -155,20 +156,20 @@
155156
<zipfileset
156157
src="${gwt.tools.lib}/apache/commons/commons-collections-3.2.2.jar"/>
157158
<!-- htmlunit dependencies not already included: BEGIN -->
158-
<zipfileset src="${gwt.tools.lib}/apache/http/httpclient-4.5.13.jar"/>
159-
<zipfileset src="${gwt.tools.lib}/apache/http/httpcore-4.4.13.jar"/>
160-
<zipfileset src="${gwt.tools.lib}/apache/http/httpmime-4.5.13.jar"/>
161-
<zipfileset src="${gwt.tools.lib}/apache/james/apache-mime4j-0.6.jar"/>
162-
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-codec-1.10.jar"/>
163-
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-io-2.4.jar"/>
164-
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-lang3-3.4.jar"/>
165-
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-logging-1.2.jar"/>
166-
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-2.55.0/htmlunit-cssparser-1.10.0.jar"/>
167-
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-2.55.0/htmlunit-2.55.0.jar"/>
168-
<zipfileset
169-
src="${gwt.tools.lib}/htmlunit/htmlunit-2.55.0/htmlunit-core-js-2.55.0.jar"/>
170-
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-2.55.0/neko-htmlunit-2.55.0.jar"/>
171-
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-2.55.0/salvation2-3.0.0.jar"/>
159+
<zipfileset src="${gwt.tools.lib}/apache/http/httpclient-4.5.14.jar"/>
160+
<zipfileset src="${gwt.tools.lib}/apache/http/httpcore-4.4.16.jar"/>
161+
<zipfileset src="${gwt.tools.lib}/apache/http/httpmime-4.5.14.jar"/>
162+
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-codec-1.18.0.jar"/>
163+
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-io-2.19.0.jar"/>
164+
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-lang3-3.17.0.jar"/>
165+
<zipfileset src="${gwt.tools.lib}/apache/commons/commons-logging-1.3.5.jar"/>
166+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-cssparser-4.11.0.jar"/>
167+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-4.11.1.jar"/>
168+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-core-js-4.11.0.jar"/>
169+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-csp-4.11.0.jar"/>
170+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-websocket-client-4.11.0.jar"/>
171+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/htmlunit-xpath-4.11.0.jar"/>
172+
<zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-4.11.1/neko-htmlunit-4.11.0.jar"/>
172173
<zipfileset src="${gwt.tools.lib}/cup/java-cup-11a.jar"/>
173174
<zipfileset src="${gwt.tools.lib}/xalan/xalan-2.7.1-nocup.jar"/>
174175
<zipfileset src="${gwt.tools.lib}/xerces/xerces-2_11_0/serializer-2.7.1.jar"/>

dev/core/src/com/google/gwt/dev/shell/HostedModePluginObject.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717

1818
import com.google.gwt.core.ext.TreeLogger;
1919

20-
import com.gargoylesoftware.htmlunit.WebClient;
21-
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
22-
import com.gargoylesoftware.htmlunit.javascript.host.Window;
23-
24-
import net.sourceforge.htmlunit.corejs.javascript.Context;
25-
import net.sourceforge.htmlunit.corejs.javascript.Function;
26-
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
27-
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
20+
import org.htmlunit.WebClient;
21+
import org.htmlunit.corejs.javascript.Context;
22+
import org.htmlunit.corejs.javascript.Function;
23+
import org.htmlunit.corejs.javascript.Scriptable;
24+
import org.htmlunit.corejs.javascript.ScriptableObject;
25+
import org.htmlunit.javascript.JavaScriptEngine;
26+
import org.htmlunit.javascript.host.Window;
2827

2928
import java.io.IOException;
30-
import java.util.Collections;
3129

3230
/**
3331
* HTMLUnit object that represents the hosted-mode plugin.
@@ -193,8 +191,8 @@ public boolean connect(String url, String sessionKey, String address,
193191
// Object[] with a success boolean and a value, and HtmlUnit will guard against this.
194192
// The simplest way to do that here is to mark java.lang.Object as the java equivalent
195193
// of some JS type - the name of the type doesn't matter.
196-
webClient.setActiveXObjectMap(Collections.singletonMap(
197-
"GwtLegacyDevModeExceptionOrReturnValue", "java.lang.Object"));
194+
// webClient.setActiveXObjectMap(Collections.singletonMap(
195+
// "GwtLegacyDevModeExceptionOrReturnValue", "java.lang.Object"));
198196

199197
try {
200198
HtmlUnitSessionHandler htmlUnitSessionHandler = new HtmlUnitSessionHandler(

dev/core/src/com/google/gwt/dev/shell/HtmlUnitSessionHandler.java

+14-28
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,20 @@
2323
import com.google.gwt.dev.shell.BrowserChannelClient.SessionHandlerClient;
2424
import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
2525

26-
import com.gargoylesoftware.htmlunit.ScriptException;
27-
import com.gargoylesoftware.htmlunit.ScriptResult;
28-
import com.gargoylesoftware.htmlunit.WebClient;
29-
import com.gargoylesoftware.htmlunit.WebWindow;
30-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
31-
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
32-
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
33-
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptableProxy;
34-
import com.gargoylesoftware.htmlunit.javascript.host.Window;
35-
36-
import net.sourceforge.htmlunit.corejs.javascript.ConsString;
37-
import net.sourceforge.htmlunit.corejs.javascript.Context;
38-
import net.sourceforge.htmlunit.corejs.javascript.Function;
39-
import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
40-
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
41-
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
42-
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
26+
import org.htmlunit.ScriptException;
27+
import org.htmlunit.ScriptResult;
28+
import org.htmlunit.WebClient;
29+
import org.htmlunit.WebWindow;
30+
import org.htmlunit.corejs.javascript.ConsString;
31+
import org.htmlunit.corejs.javascript.Context;
32+
import org.htmlunit.corejs.javascript.Function;
33+
import org.htmlunit.corejs.javascript.JavaScriptException;
34+
import org.htmlunit.corejs.javascript.Scriptable;
35+
import org.htmlunit.corejs.javascript.ScriptableObject;
36+
import org.htmlunit.corejs.javascript.Undefined;
37+
import org.htmlunit.html.HtmlPage;
38+
import org.htmlunit.javascript.JavaScriptEngine;
39+
import org.htmlunit.javascript.host.Window;
4340

4441
import java.util.Arrays;
4542
import java.util.HashMap;
@@ -187,8 +184,6 @@ public ExceptionOrReturnValue invoke(BrowserChannelClient channel, Value thisObj
187184
Object obj = makeJsvalFromValue(jsContext, thisObj);
188185
if (obj instanceof ScriptableObject) {
189186
jsThis = (ScriptableObject) obj;
190-
} else if (obj instanceof SimpleScriptableProxy<?>) {
191-
jsThis = ((SimpleScriptableProxy<SimpleScriptable>) obj).getDelegee();
192187
} else {
193188
logger.log(TreeLogger.ERROR, "Unable to convert " + obj + " to either "
194189
+ " ScriptableObject or SimpleScriptableProxy");
@@ -289,15 +284,6 @@ public Value makeValueFromJsval(Context jsContext, Object value) {
289284
return returnVal;
290285
}
291286
if (value instanceof Scriptable) {
292-
if (value instanceof SimpleScriptableProxy) {
293-
// HtmlUnit will return proxies to java for the window/document objects,
294-
// so that those objects can work after navigating away from the page.
295-
// However, GWTTestCase operates inside a single page session, so we
296-
// can unwrap these proxies to get the real instance. Without doing
297-
// this, the refToJsObject mapping would indicate that an object might
298-
// not equal itself
299-
value = ((SimpleScriptableProxy<?>) value).getDelegee();
300-
}
301287
if (value instanceof ScriptableObject) {
302288
/*
303289
* HACK: check for native types like NativeString. NativeString is

dev/core/src/com/google/gwt/dev/shell/JavaObject.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.google.gwt.dev.shell.BrowserChannel.SessionHandler.ExceptionOrReturnValue;
2222
import com.google.gwt.dev.shell.BrowserChannel.Value;
2323

24-
import net.sourceforge.htmlunit.corejs.javascript.Context;
25-
import net.sourceforge.htmlunit.corejs.javascript.Function;
26-
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
27-
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
28-
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
24+
import org.htmlunit.corejs.javascript.Context;
25+
import org.htmlunit.corejs.javascript.Function;
26+
import org.htmlunit.corejs.javascript.Scriptable;
27+
import org.htmlunit.corejs.javascript.ScriptableObject;
28+
import org.htmlunit.corejs.javascript.Undefined;
2929

3030
import java.io.IOException;
3131

dev/core/test/com/google/gwt/core/ext/linker/impl/SelectionScriptJavaScriptTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
import com.google.gwt.core.ext.linker.LinkerUtils;
2020

21-
import com.gargoylesoftware.htmlunit.AlertHandler;
22-
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
23-
import com.gargoylesoftware.htmlunit.MockWebConnection;
24-
import com.gargoylesoftware.htmlunit.Page;
25-
import com.gargoylesoftware.htmlunit.WebClient;
26-
2721
import junit.framework.TestCase;
2822

23+
import org.htmlunit.AlertHandler;
24+
import org.htmlunit.FailingHttpStatusCodeException;
25+
import org.htmlunit.MockWebConnection;
26+
import org.htmlunit.Page;
27+
import org.htmlunit.WebClient;
28+
2929
import java.io.IOException;
3030
import java.net.MalformedURLException;
3131
import java.net.URL;

maven/poms/gwt/gwt-dev/pom-template.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</exclusions>
9696
</dependency>
9797
<dependency>
98-
<groupId>net.sourceforge.htmlunit</groupId>
98+
<groupId>org.htmlunit</groupId>
9999
<artifactId>htmlunit</artifactId>
100100
</dependency>
101101
<dependency>

maven/poms/gwt/pom-template.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@
141141
<version>63.1</version>
142142
</dependency>
143143
<dependency>
144-
<groupId>net.sourceforge.htmlunit</groupId>
144+
<groupId>org.htmlunit</groupId>
145145
<artifactId>htmlunit</artifactId>
146-
<version>2.55.0</version>
146+
<version>4.11.1</version>
147147
</dependency>
148148
<dependency>
149149
<groupId>org.w3c.css</groupId>

user/src/com/google/gwt/junit/RunStyleHtmlUnit.java

+27-25
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,26 @@
2020
import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
2121
import com.google.gwt.thirdparty.guava.common.collect.Maps;
2222

23-
import com.gargoylesoftware.htmlunit.AlertHandler;
24-
import com.gargoylesoftware.htmlunit.BrowserVersion;
25-
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
26-
import com.gargoylesoftware.htmlunit.IncorrectnessListener;
27-
import com.gargoylesoftware.htmlunit.OnbeforeunloadHandler;
28-
import com.gargoylesoftware.htmlunit.Page;
29-
import com.gargoylesoftware.htmlunit.ScriptException;
30-
import com.gargoylesoftware.htmlunit.WebClient;
31-
import com.gargoylesoftware.htmlunit.WebWindow;
32-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
33-
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
34-
import com.gargoylesoftware.htmlunit.javascript.JavaScriptErrorListener;
35-
import com.gargoylesoftware.htmlunit.javascript.host.Window;
36-
import com.gargoylesoftware.htmlunit.util.WebClientUtils;
37-
38-
import net.sourceforge.htmlunit.corejs.javascript.Context;
39-
import net.sourceforge.htmlunit.corejs.javascript.Function;
40-
import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
41-
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
42-
4323
import org.apache.commons.logging.Log;
4424
import org.apache.commons.logging.LogFactory;
25+
import org.htmlunit.AlertHandler;
26+
import org.htmlunit.BrowserVersion;
27+
import org.htmlunit.FailingHttpStatusCodeException;
28+
import org.htmlunit.IncorrectnessListener;
29+
import org.htmlunit.OnbeforeunloadHandler;
30+
import org.htmlunit.Page;
31+
import org.htmlunit.ScriptException;
32+
import org.htmlunit.WebClient;
33+
import org.htmlunit.WebWindow;
34+
import org.htmlunit.corejs.javascript.Context;
35+
import org.htmlunit.corejs.javascript.Function;
36+
import org.htmlunit.corejs.javascript.JavaScriptException;
37+
import org.htmlunit.corejs.javascript.ScriptableObject;
38+
import org.htmlunit.html.HtmlPage;
39+
import org.htmlunit.javascript.JavaScriptEngine;
40+
import org.htmlunit.javascript.JavaScriptErrorListener;
41+
import org.htmlunit.javascript.host.Window;
42+
import org.htmlunit.util.WebClientUtils;
4543

4644
import java.io.IOException;
4745
import java.net.MalformedURLException;
@@ -52,6 +50,7 @@
5250
import java.util.List;
5351
import java.util.Map;
5452
import java.util.Set;
53+
import java.util.TimeZone;
5554

5655
/**
5756
* Launches a web-mode test via HTMLUnit.
@@ -105,6 +104,7 @@ public void run() {
105104
webClient.setAlertHandler(this);
106105
webClient.setIncorrectnessListener(this);
107106
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
107+
webClient.getOptions().setFetchPolyfillEnabled(true);
108108
// To receive exceptions from js side in the development mode, we need set this to 'true'.
109109
// However, as htmlunit dies after throwing the exception, we still want it to be 'false'
110110
// for web mode.
@@ -197,7 +197,7 @@ private static class HostedJavaScriptEngine extends JavaScriptEngine {
197197
private final WebClient webClient;
198198
private final TreeLogger logger;
199199

200-
public HostedJavaScriptEngine(WebClient webClient, TreeLogger logger) {
200+
HostedJavaScriptEngine(WebClient webClient, TreeLogger logger) {
201201
super(webClient);
202202
this.webClient = webClient;
203203
this.logger = logger;
@@ -223,7 +223,7 @@ private static class WebJavaScriptEngine extends JavaScriptEngine {
223223
private static final Log LOG = LogFactory.getLog(JavaScriptEngine.class);
224224
private final WebClient webClient;
225225

226-
public WebJavaScriptEngine(WebClient webClient) {
226+
WebJavaScriptEngine(WebClient webClient) {
227227
super(webClient);
228228
this.webClient = webClient;
229229
}
@@ -290,14 +290,16 @@ private void triggerOnError(Window w, ScriptException e) {
290290
private static final Map<BrowserVersion, String> USER_AGENT_MAP = Maps.newHashMap();
291291

292292
static {
293-
// “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0″
293+
// “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
294+
// Chrome/39.0.2171.71 Safari/537.36 Edge/12.0″
294295
addBrowser(BrowserVersion.EDGE, "safari");
295296
addBrowser(BrowserVersion.FIREFOX, "gecko1_8");
296297
addBrowser(BrowserVersion.CHROME, "safari");
297-
addBrowser(BrowserVersion.INTERNET_EXPLORER, "gecko1_8");
298298
}
299299

300-
private static void addBrowser(BrowserVersion browser, String userAgent) {
300+
private static void addBrowser(BrowserVersion baseBrowser, String userAgent) {
301+
BrowserVersion browser = new BrowserVersion.BrowserVersionBuilder(baseBrowser)
302+
.setSystemTimezone(TimeZone.getDefault()).build();
301303
BROWSER_MAP.put(browser.getNickname(), browser);
302304
USER_AGENT_MAP.put(browser, userAgent);
303305
}

user/test/com/google/gwt/emultest/java/util/DateTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,15 @@ public void testToLocaleString() {
573573
// /////////////////////////////
574574
Date accum1 = create(PAST);
575575
String a1 = accum1.toLocaleString();
576-
assertTrue(a1.indexOf("1890") != -1);
576+
assertTrue(a1 + " should describe 1/5/1890",
577+
a1.contains("1890") || a1.contains("1/5/90"));
577578
// /////////////////////////////
578579
// Future
579580
// /////////////////////////////
580581
Date accum2 = create(FUTURE);
581582
String a2 = accum2.toLocaleString();
582-
assertTrue(a2.indexOf("2030") != -1);
583+
assertTrue(a2 + " should describe 12/30/2030",
584+
a2.contains("2030") || a2.contains("12/30/2030"));
583585
}
584586
}
585587

0 commit comments

Comments
 (0)