2020import com .google .gwt .thirdparty .guava .common .collect .ImmutableSet ;
2121import 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-
4323import org .apache .commons .logging .Log ;
4424import 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
4644import java .io .IOException ;
4745import java .net .MalformedURLException ;
5250import java .util .List ;
5351import java .util .Map ;
5452import 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 }
0 commit comments