Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

VBrowserDetails.java 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.shared;
  17. import java.io.Serializable;
  18. import java.util.Locale;
  19. /**
  20. * Class that parses the user agent string from the browser and provides
  21. * information about the browser. Used internally by
  22. * {@link com.vaadin.client.BrowserInfo} and
  23. * {@link com.vaadin.server.WebBrowser}. Should not be used directly.
  24. *
  25. * @author Vaadin Ltd.
  26. * @since 6.3
  27. */
  28. public class VBrowserDetails implements Serializable {
  29. private boolean isGecko = false;
  30. private boolean isWebKit = false;
  31. private boolean isPresto = false;
  32. private boolean isTrident = false;
  33. private boolean isChromeFrameCapable = false;
  34. private boolean isChromeFrame = false;
  35. private boolean isSafari = false;
  36. private boolean isChrome = false;
  37. private boolean isFirefox = false;
  38. private boolean isOpera = false;
  39. private boolean isIE = false;
  40. private boolean isEdge = false;
  41. private boolean isPhantomJS = false;
  42. private boolean isWindowsPhone;
  43. private boolean isIPad;
  44. private boolean isIPhone;
  45. private boolean isChromeOS;
  46. private OperatingSystem os = OperatingSystem.UNKNOWN;
  47. public enum OperatingSystem {
  48. UNKNOWN, WINDOWS, MACOSX, LINUX, IOS, ANDROID, CHROMEOS;
  49. }
  50. private float browserEngineVersion = -1;
  51. private int browserMajorVersion = -1;
  52. private int browserMinorVersion = -1;
  53. private String browserVersion;
  54. private int osMajorVersion = -1;
  55. private int osMinorVersion = -1;
  56. /**
  57. * Create an instance based on the given user agent.
  58. *
  59. * @param userAgent
  60. * User agent as provided by the browser.
  61. */
  62. public VBrowserDetails(String userAgent) {
  63. userAgent = userAgent.toLowerCase(Locale.ROOT);
  64. // browser engine name
  65. isGecko = userAgent.indexOf("gecko") != -1
  66. && userAgent.indexOf("webkit") == -1
  67. && userAgent.indexOf("trident/") == -1;
  68. isPresto = userAgent.indexOf(" presto/") != -1;
  69. isTrident = userAgent.indexOf("trident/") != -1;
  70. isWebKit = !isTrident && userAgent.indexOf("applewebkit") != -1;
  71. // browser name
  72. isChrome = userAgent.indexOf(" chrome/") != -1
  73. || userAgent.indexOf(" crios/") != -1;
  74. isOpera = userAgent.indexOf("opera") != -1;
  75. isIE = userAgent.indexOf("msie") != -1 && !isOpera
  76. && (userAgent.indexOf("webtv") == -1);
  77. // IE 11 no longer contains MSIE in the user agent
  78. isIE = isIE || isTrident;
  79. isPhantomJS = userAgent.indexOf("phantomjs/") != -1;
  80. isFirefox = userAgent.indexOf(" firefox/") != -1
  81. || userAgent.indexOf("fxios/") != -1;
  82. isSafari = !isChrome && !isIE && !isPhantomJS && !isFirefox
  83. && userAgent.indexOf("safari") != -1;
  84. if (userAgent.indexOf(" edge/") != -1) {
  85. isEdge = true;
  86. isChrome = false;
  87. isOpera = false;
  88. isIE = false;
  89. isSafari = false;
  90. isFirefox = false;
  91. isWebKit = false;
  92. isGecko = false;
  93. isPhantomJS = false;
  94. }
  95. // chromeframe
  96. isChromeFrameCapable = userAgent.indexOf("chromeframe") != -1;
  97. isChromeFrame = isChromeFrameCapable && !isChrome;
  98. // Rendering engine version
  99. try {
  100. if (isGecko) {
  101. int rvPos = userAgent.indexOf("rv:");
  102. if (rvPos >= 0) {
  103. String tmp = userAgent.substring(rvPos + 3);
  104. tmp = tmp.replaceFirst("(\\.[0-9]+).+", "$1");
  105. browserEngineVersion = Float.parseFloat(tmp);
  106. }
  107. } else if (isWebKit) {
  108. String tmp = userAgent
  109. .substring(userAgent.indexOf("webkit/") + 7);
  110. tmp = tmp.replaceFirst("([0-9]+)[^0-9].+", "$1");
  111. browserEngineVersion = Float.parseFloat(tmp);
  112. } else if (isTrident) {
  113. String tmp = userAgent
  114. .substring(userAgent.indexOf("trident/") + 8);
  115. tmp = tmp.replaceFirst("([0-9]+\\.[0-9]+).*", "$1");
  116. browserEngineVersion = Float.parseFloat(tmp);
  117. if (browserEngineVersion > 7) {
  118. browserEngineVersion = 7;
  119. }
  120. } else if (isEdge) {
  121. browserEngineVersion = 0;
  122. }
  123. } catch (Exception e) {
  124. // Browser engine version parsing failed
  125. System.err.println(
  126. "Browser engine version parsing failed for: " + userAgent);
  127. }
  128. // Browser version
  129. try {
  130. if (isIE) {
  131. if (userAgent.indexOf("msie") == -1) {
  132. // IE 11+
  133. int rvPos = userAgent.indexOf("rv:");
  134. if (rvPos >= 0) {
  135. int i = rvPos + "rv:".length();
  136. browserVersion = findBrowserVersion(userAgent, i);
  137. parseVersionString(browserVersion);
  138. }
  139. } else if (isTrident) {
  140. // See
  141. // https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#TriToken
  142. setIEMode((int) browserEngineVersion + 4);
  143. } else {
  144. int i = userAgent.indexOf("msie ") + 5;
  145. browserVersion = findBrowserVersion(userAgent, i);
  146. parseVersionString(browserVersion);
  147. }
  148. } else if (isFirefox) {
  149. int i = userAgent.indexOf(" firefox/");
  150. if (i != -1) {
  151. i += " firefox/".length();
  152. } else {
  153. i = userAgent.indexOf(" fxios/") + " fxios/".length();
  154. }
  155. browserVersion = findBrowserVersion(userAgent, i);
  156. parseVersionString(browserVersion);
  157. } else if (isChrome) {
  158. int i = userAgent.indexOf(" chrome/");
  159. if (i != -1) {
  160. i += " chrome/".length();
  161. } else {
  162. i = userAgent.indexOf(" crios/") + " crios/".length();
  163. }
  164. browserVersion = findBrowserVersion(userAgent, i);
  165. parseVersionString(browserVersion);
  166. } else if (isSafari) {
  167. int i = userAgent.indexOf(" version/") + 9;
  168. browserVersion = findBrowserVersion(userAgent, i);
  169. parseVersionString(browserVersion);
  170. } else if (isOpera) {
  171. int i = userAgent.indexOf(" version/");
  172. if (i != -1) {
  173. // Version present in Opera 10 and newer
  174. i += 9; // " version/".length
  175. } else {
  176. i = userAgent.indexOf("opera/") + 6;
  177. }
  178. browserVersion = findBrowserVersion(userAgent, i);
  179. parseVersionString(browserVersion);
  180. } else if (isEdge) {
  181. int i = userAgent.indexOf(" edge/") + 6;
  182. browserVersion = findBrowserVersion(userAgent, i);
  183. parseVersionString(browserVersion);
  184. } else if (isPhantomJS) {
  185. String prefix = " phantomjs/";
  186. int i = userAgent.indexOf(prefix) + prefix.length();
  187. browserVersion = findBrowserVersion(userAgent, i);
  188. parseVersionString(browserVersion);
  189. }
  190. } catch (Exception e) {
  191. // Browser version parsing failed
  192. System.err.println(
  193. "Browser version parsing failed for: " + userAgent);
  194. }
  195. // Operating system
  196. if (userAgent.contains("windows ")) {
  197. os = OperatingSystem.WINDOWS;
  198. isWindowsPhone = userAgent.contains("windows phone");
  199. } else if (userAgent.contains("android")) {
  200. os = OperatingSystem.ANDROID;
  201. parseAndroidVersion(userAgent);
  202. } else if (userAgent.contains("linux")) {
  203. os = OperatingSystem.LINUX;
  204. } else if (userAgent.contains("macintosh")
  205. || userAgent.contains("mac osx")
  206. || userAgent.contains("mac os x")) {
  207. isIPad = userAgent.contains("ipad");
  208. isIPhone = userAgent.contains("iphone");
  209. if (isIPad || userAgent.contains("ipod") || isIPhone) {
  210. os = OperatingSystem.IOS;
  211. parseIOSVersion(userAgent);
  212. } else {
  213. os = OperatingSystem.MACOSX;
  214. }
  215. } else if (userAgent.contains("; cros ")) {
  216. os = OperatingSystem.CHROMEOS;
  217. isChromeOS = true;
  218. parseChromeOSVersion(userAgent);
  219. }
  220. }
  221. // (X11; CrOS armv7l 6946.63.0)
  222. private void parseChromeOSVersion(String userAgent) {
  223. int start = userAgent.indexOf("; cros ");
  224. if (start == -1) {
  225. return;
  226. }
  227. int end = userAgent.indexOf(')', start);
  228. if (end == -1) {
  229. return;
  230. }
  231. int cur = end;
  232. while (cur >= start && userAgent.charAt(cur) != ' ') {
  233. cur--;
  234. }
  235. if (cur == start) {
  236. return;
  237. }
  238. String osVersionString = userAgent.substring(cur + 1, end);
  239. String[] parts = osVersionString.split("\\.");
  240. parseChromeOsVersion(parts);
  241. }
  242. private void parseChromeOsVersion(String[] parts) {
  243. osMajorVersion = -1;
  244. osMinorVersion = -1;
  245. if (parts.length > 2) {
  246. try {
  247. osMajorVersion = Integer.parseInt(parts[1]);
  248. } catch (Exception e) {
  249. }
  250. try {
  251. osMinorVersion = Integer.parseInt(parts[0]);
  252. } catch (Exception e) {
  253. }
  254. }
  255. }
  256. private void parseAndroidVersion(String userAgent) {
  257. // Android 5.1;
  258. if (!userAgent.contains("android")) {
  259. return;
  260. }
  261. String osVersionString = safeSubstring(userAgent,
  262. userAgent.indexOf("android ") + "android ".length(),
  263. userAgent.length());
  264. osVersionString = safeSubstring(osVersionString, 0,
  265. osVersionString.indexOf(";"));
  266. String[] parts = osVersionString.split("\\.");
  267. parseOsVersion(parts);
  268. }
  269. private void parseIOSVersion(String userAgent) {
  270. // OS 5_1 like Mac OS X
  271. if (!userAgent.contains("os ") || !userAgent.contains(" like mac")) {
  272. return;
  273. }
  274. String osVersionString = safeSubstring(userAgent,
  275. userAgent.indexOf("os ") + 3, userAgent.indexOf(" like mac"));
  276. String[] parts = osVersionString.split("_");
  277. parseOsVersion(parts);
  278. }
  279. private void parseOsVersion(String[] parts) {
  280. osMajorVersion = -1;
  281. osMinorVersion = -1;
  282. if (parts.length >= 1) {
  283. try {
  284. osMajorVersion = Integer.parseInt(parts[0]);
  285. } catch (Exception e) {
  286. }
  287. }
  288. if (parts.length >= 2) {
  289. try {
  290. osMinorVersion = Integer.parseInt(parts[1]);
  291. } catch (Exception e) {
  292. }
  293. // Some Androids report version numbers as "2.1-update1"
  294. if (osMinorVersion == -1 && parts[1].contains("-")) {
  295. try {
  296. osMinorVersion = Integer.parseInt(
  297. parts[1].substring(0, parts[1].indexOf('-')));
  298. } catch (Exception ee) {
  299. }
  300. }
  301. }
  302. }
  303. private void parseVersionString(String versionString) {
  304. int idx = versionString.indexOf('.');
  305. if (idx < 0) {
  306. idx = versionString.length();
  307. }
  308. browserMajorVersion = Integer
  309. .parseInt(safeSubstring(versionString, 0, idx));
  310. int idx2 = versionString.indexOf('.', idx + 1);
  311. if (idx2 < 0) {
  312. idx2 = versionString.length();
  313. }
  314. try {
  315. browserMinorVersion = Integer
  316. .parseInt(safeSubstring(versionString, idx + 1, idx2)
  317. .replaceAll("[^0-9].*", ""));
  318. } catch (NumberFormatException e) {
  319. // leave the minor version unmodified (-1 = unknown)
  320. }
  321. }
  322. private String safeSubstring(String string, int beginIndex, int endIndex) {
  323. if (beginIndex < 0) {
  324. beginIndex = 0;
  325. }
  326. if (endIndex < 0 || endIndex > string.length()) {
  327. endIndex = string.length();
  328. }
  329. return string.substring(beginIndex, endIndex);
  330. }
  331. private String findBrowserVersion(String userAgent, int startIndex) {
  332. int index = startIndex;
  333. int length = userAgent.length();
  334. while (index < length) {
  335. char c = userAgent.charAt(index);
  336. // Accept letter, digit, underscore and dot characters
  337. if (!(Character.isLetter(c) || Character.isDigit(c) || c == '_'
  338. || c == '.')) {
  339. break;
  340. }
  341. index++;
  342. }
  343. return userAgent.substring(startIndex, index);
  344. }
  345. /**
  346. * Tests if the browser is Firefox.
  347. *
  348. * @return true if it is Firefox, false otherwise
  349. */
  350. public boolean isFirefox() {
  351. return isFirefox;
  352. }
  353. /**
  354. * Tests if the browser is using the Gecko engine.
  355. *
  356. * @return true if it is Gecko, false otherwise
  357. */
  358. public boolean isGecko() {
  359. return isGecko;
  360. }
  361. /**
  362. * Tests if the browser is using the WebKit engine.
  363. *
  364. * @return true if it is WebKit, false otherwise
  365. */
  366. public boolean isWebKit() {
  367. return isWebKit;
  368. }
  369. /**
  370. * Tests if the browser is using the Presto engine.
  371. *
  372. * @return true if it is Presto, false otherwise
  373. */
  374. public boolean isPresto() {
  375. return isPresto;
  376. }
  377. /**
  378. * Tests if the browser is using the Trident engine.
  379. *
  380. * @since 7.1.7
  381. * @return true if it is Trident, false otherwise
  382. */
  383. public boolean isTrident() {
  384. return isTrident;
  385. }
  386. /**
  387. * Tests if the browser is Safari.
  388. *
  389. * @return true if it is Safari, false otherwise
  390. */
  391. public boolean isSafari() {
  392. return isSafari;
  393. }
  394. /**
  395. * Tests if the browser is Safari or runs on IOS (covering also Chrome on
  396. * iOS).
  397. *
  398. * @return true if it is Safari or running on IOS, false otherwise
  399. * @since 8.1
  400. */
  401. public boolean isSafariOrIOS() {
  402. return isSafari() || isIOS();
  403. }
  404. /**
  405. * Tests if the browser is Chrome.
  406. *
  407. * @return true if it is Chrome, false otherwise
  408. */
  409. public boolean isChrome() {
  410. return isChrome;
  411. }
  412. /**
  413. * Tests if the browser is capable of running ChromeFrame.
  414. *
  415. * @return true if it has ChromeFrame, false otherwise
  416. */
  417. public boolean isChromeFrameCapable() {
  418. return isChromeFrameCapable;
  419. }
  420. /**
  421. * Tests if the browser is running ChromeFrame.
  422. *
  423. * @return true if it is ChromeFrame, false otherwise
  424. */
  425. public boolean isChromeFrame() {
  426. return isChromeFrame;
  427. }
  428. /**
  429. * Tests if the browser is Opera.
  430. *
  431. * @return true if it is Opera, false otherwise
  432. */
  433. public boolean isOpera() {
  434. return isOpera;
  435. }
  436. /**
  437. * Tests if the browser is Internet Explorer.
  438. *
  439. * @return true if it is Internet Explorer, false otherwise
  440. */
  441. public boolean isIE() {
  442. return isIE;
  443. }
  444. /**
  445. * Tests if the browser is Edge.
  446. *
  447. * @since 7.5.3
  448. * @return true if it is Edge, false otherwise
  449. */
  450. public boolean isEdge() {
  451. return isEdge;
  452. }
  453. /**
  454. * Tests if the browser is PhantomJS.
  455. *
  456. * @return true if it is PhantomJS, false otherwise
  457. */
  458. public boolean isPhantomJS() {
  459. return isPhantomJS;
  460. }
  461. /**
  462. * Returns the version of the browser engine. For WebKit this is an integer
  463. * e.g., 532.0. For gecko it is a float e.g., 1.8 or 1.9.
  464. *
  465. * @return The version of the browser engine
  466. */
  467. public float getBrowserEngineVersion() {
  468. return browserEngineVersion;
  469. }
  470. /**
  471. * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome
  472. * 4, 8 for Internet Explorer 8.
  473. * <p>
  474. * Note that Internet Explorer 8 and newer will return the document mode so
  475. * IE8 rendering as IE7 will return 7.
  476. * </p>
  477. *
  478. * @return The major version of the browser.
  479. */
  480. public final int getBrowserMajorVersion() {
  481. return browserMajorVersion;
  482. }
  483. /**
  484. * Returns the browser minor version e.g., 5 for Firefox 3.5.
  485. *
  486. * @see #getBrowserMajorVersion()
  487. *
  488. * @return The minor version of the browser, or -1 if not known/parsed.
  489. */
  490. public final int getBrowserMinorVersion() {
  491. return browserMinorVersion;
  492. }
  493. /**
  494. * Gets the complete browser version as string.
  495. *
  496. * @return the complete browser version or {@code null} if unknown
  497. */
  498. public final String getBrowserVersion() {
  499. return browserVersion;
  500. }
  501. /**
  502. * Sets the version for IE based on the documentMode. This is used to return
  503. * the correct the correct IE version when the version from the user agent
  504. * string and the value of the documentMode property do not match.
  505. *
  506. * @param documentMode
  507. * The current document mode
  508. */
  509. public void setIEMode(int documentMode) {
  510. browserMajorVersion = documentMode;
  511. browserMinorVersion = 0;
  512. browserVersion = browserMajorVersion + "." + browserMinorVersion;
  513. }
  514. /**
  515. * Tests if the browser is run on Windows.
  516. *
  517. * @return true if run on Windows, false otherwise
  518. */
  519. public boolean isWindows() {
  520. return os == OperatingSystem.WINDOWS;
  521. }
  522. /**
  523. * Tests if the browser is run on Windows Phone.
  524. *
  525. * @return true if run on Windows Phone, false otherwise
  526. * @since 7.3.2
  527. */
  528. public boolean isWindowsPhone() {
  529. return isWindowsPhone;
  530. }
  531. /**
  532. * Tests if the browser is run on Mac OSX.
  533. *
  534. * @return true if run on Mac OSX, false otherwise
  535. */
  536. public boolean isMacOSX() {
  537. return os == OperatingSystem.MACOSX;
  538. }
  539. /**
  540. * Tests if the browser is run on Linux.
  541. *
  542. * @return true if run on Linux, false otherwise
  543. */
  544. public boolean isLinux() {
  545. return os == OperatingSystem.LINUX;
  546. }
  547. /**
  548. * Tests if the browser is run on Android.
  549. *
  550. * @return true if run on Android, false otherwise
  551. */
  552. public boolean isAndroid() {
  553. return os == OperatingSystem.ANDROID;
  554. }
  555. /**
  556. * Tests if the browser is run in iOS.
  557. *
  558. * @return true if run in iOS, false otherwise
  559. */
  560. public boolean isIOS() {
  561. return os == OperatingSystem.IOS;
  562. }
  563. /**
  564. * Tests if the browser is run on iPhone.
  565. *
  566. * @return true if run on iPhone, false otherwise
  567. * @since 7.3.3
  568. */
  569. public boolean isIPhone() {
  570. return isIPhone;
  571. }
  572. /**
  573. * Tests if the browser is run on iPad.
  574. *
  575. * @return true if run on iPad, false otherwise
  576. * @since 7.3.3
  577. */
  578. public boolean isIPad() {
  579. return isIPad;
  580. }
  581. /**
  582. * Tests if the browser is run on Chrome OS (e.g. a Chromebook).
  583. *
  584. * @return true if run on Chrome OS, false otherwise
  585. * @since 8.1.1
  586. */
  587. public boolean isChromeOS() {
  588. return isChromeOS;
  589. }
  590. /**
  591. * Returns the major version of the operating system. Currently only
  592. * supported for mobile devices (iOS/Android)
  593. *
  594. * @return The major version or -1 if unknown
  595. */
  596. public int getOperatingSystemMajorVersion() {
  597. return osMajorVersion;
  598. }
  599. /**
  600. * Returns the minor version of the operating system. Currently only
  601. * supported for mobile devices (iOS/Android)
  602. *
  603. * @return The minor version or -1 if unknown
  604. */
  605. public int getOperatingSystemMinorVersion() {
  606. return osMinorVersion;
  607. }
  608. /**
  609. * Checks if the browser is so old that it simply won't work with a Vaadin
  610. * application.
  611. *
  612. * @return true if the browser won't work, false if not the browser is
  613. * supported or might work
  614. */
  615. public boolean isTooOldToFunctionProperly() {
  616. if (isIE() && getBrowserMajorVersion() < 11) {
  617. return true;
  618. }
  619. // Webkit 533 in Safari 4.1+, Android 2.2+, iOS 4+
  620. // All iOS browsers use Safari as their engine.
  621. if ((isSafari() || isIOS()) && getBrowserEngineVersion() < 533) {
  622. return true;
  623. }
  624. // Firefox for iOS uses a different versioning scheme and will
  625. // fail the test. Since it is already covered by the iOS test
  626. // above, ignore it here.
  627. if (isFirefox() && !isIOS() && getBrowserMajorVersion() < 45) {
  628. return true;
  629. }
  630. if (isOpera() && getBrowserMajorVersion() < 11) {
  631. return true;
  632. }
  633. return false;
  634. }
  635. /**
  636. * Checks whether the browser should support ES6 based on its vendor and
  637. * version number.
  638. *
  639. * @return true if the browser supports ES6
  640. * @since 8.1
  641. */
  642. public boolean isEs6Supported() {
  643. // Safari 10+
  644. if (isSafari() && getBrowserMajorVersion() >= 10) {
  645. return true;
  646. }
  647. // Firefox 51+
  648. if (isFirefox() && getBrowserMajorVersion() >= 51) {
  649. return true;
  650. }
  651. // Opera 36+
  652. if (isOpera() && getBrowserMajorVersion() >= 36) {
  653. return true;
  654. }
  655. // Chrome 49+
  656. if (isChrome() && getBrowserMajorVersion() >= 49) {
  657. return true;
  658. }
  659. // Edge 15.15063+
  660. if (isEdge() && (getBrowserMajorVersion() > 15
  661. || (getBrowserMajorVersion() == 15
  662. && getBrowserMinorVersion() >= 15063))) {
  663. return true;
  664. }
  665. return false;
  666. }
  667. }