20
20
import com .google .gwt .thirdparty .guava .common .collect .ImmutableSet ;
21
21
import com .google .gwt .thirdparty .guava .common .collect .Maps ;
22
22
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
-
43
23
import org .apache .commons .logging .Log ;
44
24
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 ;
45
43
46
44
import java .io .IOException ;
47
45
import java .net .MalformedURLException ;
52
50
import java .util .List ;
53
51
import java .util .Map ;
54
52
import java .util .Set ;
53
+ import java .util .TimeZone ;
55
54
56
55
/**
57
56
* Launches a web-mode test via HTMLUnit.
@@ -105,6 +104,7 @@ public void run() {
105
104
webClient .setAlertHandler (this );
106
105
webClient .setIncorrectnessListener (this );
107
106
webClient .getOptions ().setThrowExceptionOnFailingStatusCode (false );
107
+ webClient .getOptions ().setFetchPolyfillEnabled (true );
108
108
// To receive exceptions from js side in the development mode, we need set this to 'true'.
109
109
// However, as htmlunit dies after throwing the exception, we still want it to be 'false'
110
110
// for web mode.
@@ -197,7 +197,7 @@ private static class HostedJavaScriptEngine extends JavaScriptEngine {
197
197
private final WebClient webClient ;
198
198
private final TreeLogger logger ;
199
199
200
- public HostedJavaScriptEngine (WebClient webClient , TreeLogger logger ) {
200
+ HostedJavaScriptEngine (WebClient webClient , TreeLogger logger ) {
201
201
super (webClient );
202
202
this .webClient = webClient ;
203
203
this .logger = logger ;
@@ -223,7 +223,7 @@ private static class WebJavaScriptEngine extends JavaScriptEngine {
223
223
private static final Log LOG = LogFactory .getLog (JavaScriptEngine .class );
224
224
private final WebClient webClient ;
225
225
226
- public WebJavaScriptEngine (WebClient webClient ) {
226
+ WebJavaScriptEngine (WebClient webClient ) {
227
227
super (webClient );
228
228
this .webClient = webClient ;
229
229
}
@@ -290,14 +290,16 @@ private void triggerOnError(Window w, ScriptException e) {
290
290
private static final Map <BrowserVersion , String > USER_AGENT_MAP = Maps .newHashMap ();
291
291
292
292
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″
294
295
addBrowser (BrowserVersion .EDGE , "safari" );
295
296
addBrowser (BrowserVersion .FIREFOX , "gecko1_8" );
296
297
addBrowser (BrowserVersion .CHROME , "safari" );
297
- addBrowser (BrowserVersion .INTERNET_EXPLORER , "gecko1_8" );
298
298
}
299
299
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 .getTimeZone ("GMT" )).build ();
301
303
BROWSER_MAP .put (browser .getNickname (), browser );
302
304
USER_AGENT_MAP .put (browser , userAgent );
303
305
}
0 commit comments