Skip to content

Commit c8595eb

Browse files
committed
cleanup
1 parent 2afdb71 commit c8595eb

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

src/main/java/org/htmlunit/BrowserVersion.java

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.TimeZone;
2727

2828
import org.apache.commons.io.FilenameUtils;
29-
import org.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration;
3029
import org.htmlunit.javascript.configuration.BrowserFeature;
3130
import org.htmlunit.javascript.configuration.SupportedBrowser;
3231
import org.htmlunit.util.MimeType;
@@ -64,26 +63,6 @@
6463
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
6564
public final class BrowserVersion implements Serializable {
6665

67-
/**
68-
* Application name the Netscape navigator series of browsers.
69-
*/
70-
private static final String NETSCAPE = "Netscape";
71-
72-
/**
73-
* United States English language identifier.
74-
*/
75-
private static final String LANGUAGE_ENGLISH_US = "en-US";
76-
77-
/**
78-
* United States.
79-
*/
80-
private static final String TIMEZONE_NEW_YORK = "America/New_York";
81-
82-
/**
83-
* The WIN32 platform.
84-
*/
85-
private static final String PLATFORM_WIN32 = "Win32";
86-
8766
/** Latest Firefox. */
8867
public static final BrowserVersion FIREFOX = new BrowserVersion(133, "FF");
8968

@@ -117,6 +96,7 @@ public final class BrowserVersion implements Serializable {
11796
+ FIREFOX_ESR.getBrowserVersionNumeric() + ".0) Gecko/20100101 Firefox/"
11897
+ FIREFOX_ESR.getBrowserVersionNumeric() + ".0";
11998
FIREFOX_ESR.buildId_ = "20181001000000";
99+
FIREFOX_ESR.vendor_ = "";
120100
FIREFOX_ESR.productSub_ = "20100101";
121101
FIREFOX_ESR.headerNamesOrdered_ = new String[] {
122102
HttpHeader.HOST,
@@ -152,6 +132,7 @@ public final class BrowserVersion implements Serializable {
152132
+ FIREFOX.getBrowserVersionNumeric() + ".0) Gecko/20100101 Firefox/"
153133
+ FIREFOX.getBrowserVersionNumeric() + ".0";
154134
FIREFOX.buildId_ = "20181001000000";
135+
FIREFOX.vendor_ = "";
155136
FIREFOX.productSub_ = "20100101";
156137
FIREFOX.headerNamesOrdered_ = new String[] {
157138
HttpHeader.HOST,
@@ -188,7 +169,6 @@ public final class BrowserVersion implements Serializable {
188169
CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/"
189170
+ CHROME.getBrowserVersionNumeric() + ".0.0.0 Safari/537.36";
190171

191-
CHROME.applicationCodeName_ = "Mozilla";
192172
CHROME.vendor_ = "Google Inc.";
193173
CHROME.productSub_ = "20030107";
194174
CHROME.headerNamesOrdered_ = new String[] {
@@ -234,7 +214,6 @@ public final class BrowserVersion implements Serializable {
234214
+ EDGE.getBrowserVersionNumeric() + ".0.0.0 Safari/537.36 Edg/"
235215
+ EDGE.getBrowserVersionNumeric() + ".0.0.0";
236216

237-
EDGE.applicationCodeName_ = "Mozilla";
238217
EDGE.vendor_ = "Google Inc.";
239218
EDGE.productSub_ = "20030107";
240219
EDGE.headerNamesOrdered_ = new String[] {
@@ -387,17 +366,17 @@ public final class BrowserVersion implements Serializable {
387366
private final int browserVersionNumeric_;
388367
private final String nickname_;
389368

390-
private String applicationCodeName_ = "Mozilla";
391-
private String applicationMinorVersion_ = "0";
369+
private String applicationCodeName_;
370+
private String applicationMinorVersion_;
392371
private String applicationName_;
393372
private String applicationVersion_;
394373
private String buildId_;
395374
private String productSub_;
396-
private String vendor_ = "";
397-
private Locale browserLocale_ = Locale.forLanguageTag(LANGUAGE_ENGLISH_US);
398-
private boolean onLine_ = true;
399-
private String platform_ = PLATFORM_WIN32;
400-
private TimeZone systemTimezone_ = TimeZone.getTimeZone(TIMEZONE_NEW_YORK);
375+
private String vendor_;
376+
private Locale browserLocale_;
377+
private boolean onLine_;
378+
private String platform_;
379+
private TimeZone systemTimezone_;
401380
private String userAgent_;
402381
private final Set<BrowserVersionFeatures> features_;
403382
private String acceptEncodingHeader_;
@@ -423,7 +402,15 @@ public final class BrowserVersion implements Serializable {
423402
browserVersionNumeric_ = browserVersionNumeric;
424403
nickname_ = nickname;
425404

426-
applicationName_ = NETSCAPE;
405+
applicationCodeName_ = "Mozilla";
406+
applicationMinorVersion_ = "0";
407+
applicationName_ = "Netscape";
408+
onLine_ = true;
409+
platform_ = "Win32";
410+
411+
browserLocale_ = Locale.forLanguageTag("en-US");
412+
systemTimezone_ = TimeZone.getTimeZone("America/New_York");
413+
427414
acceptEncodingHeader_ = "gzip, deflate, br";
428415
htmlAcceptHeader_ = "*/*";
429416
imgAcceptHeader_ = "*/*";
@@ -468,7 +455,7 @@ else if (isFirefox()) {
468455
final BrowserFeature browserFeature = field.getAnnotation(BrowserFeature.class);
469456
if (browserFeature != null) {
470457
for (final SupportedBrowser browser : browserFeature.value()) {
471-
if (AbstractJavaScriptConfiguration.isCompatible(expectedBrowser, browser)) {
458+
if (expectedBrowser == browser) {
472459
features_.add(features);
473460
}
474461
}

src/main/java/org/htmlunit/javascript/configuration/AbstractJavaScriptConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ else if (annotation instanceof JsxConstructorAlias) {
357357

358358
private static boolean isSupported(final SupportedBrowser[] browsers, final SupportedBrowser expectedBrowser) {
359359
for (final SupportedBrowser browser : browsers) {
360-
if (isCompatible(browser, expectedBrowser)) {
360+
if (browser == expectedBrowser) {
361361
return true;
362362
}
363363
}
@@ -369,7 +369,10 @@ private static boolean isSupported(final SupportedBrowser[] browsers, final Supp
369369
* @param browser1 the first {@link SupportedBrowser}
370370
* @param browser2 the second {@link SupportedBrowser}
371371
* @return whether the two {@link SupportedBrowser} are compatible or not
372+
*
373+
* @deprecated as of version 4.8.0; will be removed without replacement
372374
*/
375+
@Deprecated
373376
public static boolean isCompatible(final SupportedBrowser browser1, final SupportedBrowser browser2) {
374377
return browser1 == browser2;
375378
}

0 commit comments

Comments
 (0)