How to use getVersionString method in Cypress

Best JavaScript code snippet using cypress

2_platform.js

Source:2_platform.js Github

copy

Full Screen

...20 *  New 3DS21 */22if( strPlatform === 'New Nintendo 3DS' || ( findString( strUserAgent, 'iPhone OS 6_0' ) && screenW === 320 && screenH === 240 ) ){23    platform         = WHAT_BROWSER_AM_I__PLATFORM_New3DS;24    platformVersion  = getVersionString( strUserAgent, 'NintendoBrowser/' );25    deviceTypeIsGame = true;26} else27/*----------------------------------------------------------------------------//28 *  3DS29 */30if( strPlatform === 'Nintendo 3DS' ){31    platform         = WHAT_BROWSER_AM_I__PLATFORM_N3DS;32    platformVersion  = getVersionString( strUserAgent, 'Version/' );33    versionWebKit    = 535; // 534:2.0.0-2J - 9.5.0-22J, 9.5.0-23J -34    versionNX        = platformVersion;35    deviceTypeIsGame = true;36} else37/*----------------------------------------------------------------------------//38 *  Nintendo Swicth39 */40if( strPlatform === 'Nintendo Swicth' ){41    platform         = WHAT_BROWSER_AM_I__PLATFORM_Switch;42    platformVersion  = getVersionString( strAppVersion, 'NintendoBrowser/' );43    deviceTypeIsGame = true;44} else45/*----------------------------------------------------------------------------//46 *  WiiU47 */48if( window.wiiu /* strPlatform === 'Nintendo WiiU' */ ){49    // https://www.nintendo.co.jp/hardware/wiiu/internetbrowser/index.html50    platform         = WHAT_BROWSER_AM_I__PLATFORM_WiiU;51    platformVersion  = getVersionString( strAppVersion, 'NintendoBrowser/' );52    // https://blog.gutyan.jp/entry/2015/01/31/NintendoBrowser53    // UブラウザにはNew3DS以上のUA切替機能がある。54    // platform始めUA以外のnavigatorのプロパティはいずれの場合も変更されない。55    engine        = WHAT_BROWSER_AM_I__ENGINE_WebKit; // UA 偽装で Chromium になるケースがあるのでここで設定56    engineVersion = getVersionString( strAppVersion, 'AppleWebKit/' ) ||57                    ( webkitCancelAnimationFrame ? 536 : 534 ); // 534:2.1.0J - 3.1.0J, 536:4.0.0J - 58    deviceTypeIsGame = true;59    if( !platformVersion ){60        platformVersion   = webkitCancelAnimationFrame ? 4 : 2;61        isPcSiteRequested = findString( strAppVersion, 'Macintosh;' ) || ( findString( strAppVersion, 'Windows NT' ) && !findString( strAppVersion, 'Touch' ) );62    };63} else64/*----------------------------------------------------------------------------//65 *  Wii66 */67if( isPresto && isPresto.wiiremote /* strPlatform === 'Nintendo Wii' */ ){68    // https://ja.wikipedia.org/wiki/%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%8D%E3%83%83%E3%83%88%E3%83%81%E3%83%A3%E3%83%B3%E3%83%8D%E3%83%AB69    // 2007年 4月12日版:Opera/9.10(Nintendo Wii; U; ; 1621; ja)70    // 2007年10月10日版:Opera/9.30(Nintendo Wii; U; ; 2047-7; ja)71    // 2009年 9月 1日版:Opera/9.30 (Nintendo Wii; U; ; 3642; ja)72    platform         = WHAT_BROWSER_AM_I__PLATFORM_Wii;73    platformVersion  = getVersionString( strUserAgent, 'Wii; U; ; ' );74    brand            = platform;75    brandVersion     = platformVersion;76    deviceTypeIsGame = true;77} else78/*----------------------------------------------------------------------------//79 *  PlayStation Vita80 */81if( strVersion = getVersionString( strUserAgent, 'PlayStation Vita ' ) ){82    // http://d.hatena.ne.jp/nakamura001/20111221/132448644583    // Mozilla/5.0 (PlayStation Vita 1.50) AppleWebKit/531.22.8 (KHTML, like Gecko) Silk/3.284    platform         = WHAT_BROWSER_AM_I__PLATFORM_PSVita;85    platformVersion  = strVersion;86    // versionWebKit = // 531, 536, 53787    brand            = platform;88    brandVersion     = strVersion;89    deviceTypeIsGame = true;90} else91/*----------------------------------------------------------------------------//92 *  PSP93 */94if( strVersion = getVersionString( strUserAgent, '(PlayStation Portable); ' ) ){95    // https://github.com/chitoku-k/SystemInfo/blob/master/systeminfo.js96    // http://www.jp.playstation.com/psp/dl/pdf/InternetBrowser_ContentGuideline-J_500.pdf97    // User-Agent: Mozilla/4.0 (PSP (PlayStation Portable); 2.00)98    platform         = WHAT_BROWSER_AM_I__PLATFORM_PSP;99    platformVersion  = strVersion;100    versionNetFront  = 3.3; // 多分101    brand            = platform;102    brandVersion     = strVersion;103    deviceTypeIsGame = true;104} else105/*----------------------------------------------------------------------------//106 *  PLAYSTATION 3107 */108if( strVersion = getVersionString( strUserAgent, 'PLAYSTATION 3; ' ) || getVersionString( strUserAgent, 'PLAYSTATION 3 ' ) ){109    platform         = WHAT_BROWSER_AM_I__PLATFORM_PS3;110    platformVersion  = strVersion;111    brand            = platform;112    brandVersion     = strVersion;113    if( conpareVersionString( '4.10', strVersion ) < 0 ){114        engine        = WHAT_BROWSER_AM_I__ENGINE_Sony;115        engineVersion = strVersion;116    };117    deviceTypeIsGame = true;118} else119/*----------------------------------------------------------------------------//120 *  XBox One121 */122if( findString( strUserAgent, 'Xbox One' ) ){123    platform         = WHAT_BROWSER_AM_I__PLATFORM_XboxOne;124    platformVersion  = 1;125    deviceTypeIsGame = true;126} else127/*----------------------------------------------------------------------------//128 *  XBox 360129 */130if( findString( strUserAgent, 'Xbox' ) ){131    platform         = WHAT_BROWSER_AM_I__PLATFORM_Xbox360;132    platformVersion  = 1;133    deviceTypeIsGame = true;134} else135/*----------------------------------------------------------------------------//136 *  Mylo2137 */138if( appVersion === 2 && findString( strUserAgent, 'Sony/COM2/' ) ){139    platform         = WHAT_BROWSER_AM_I__PLATFORM_Mylo;140    platformVersion  = 2;141    versionNetFront  = 3.4;142    brand            = platform;143    brandVersion     = 2;144    deviceTypeIsPDA  = true;145} else146/*----------------------------------------------------------------------------//147 *  iOS148 */149if( fromString( strPlatform, 'iP' ) || versioniOSWithUC || versioniOSWithPuffin || is_iPadOsPcSiteRequested ){150    if( versioniOSWithPuffin ){151        platformVersion = versioniOSWithPuffin;152        switch( puffinDeviceModel.substr( 0, 4 ) ){153            case 'iPho' :154                device        = WHAT_BROWSER_AM_I__DEVICE_iPhone;155                deviceVersion = getVersionString( puffinDeviceModel, device );156                deviceTypeIsPhone = true;157                break;158            case 'iPad' :159                device        = WHAT_BROWSER_AM_I__DEVICE_iPad;160                deviceVersion = getVersionString( puffinDeviceModel, device );161                deviceTypeIsTablet = true;162                break;163            case 'iPod' :164                device        = WHAT_BROWSER_AM_I__DEVICE_iPod;165                deviceVersion = getVersionString( puffinDeviceModel, device );166                deviceTypeIsMediaPlayer = true;167                break;168        };169    } else {170        if( versioniOSWithUC ){171            platformVersion = versioniOSWithUC;172        } else {173            platformVersion  = getVersionString( strAppVersion.split( '_' ).join( '.' ), 'OS ' );174            is_iOSOperaTurbo = !inObject( 'isSecureContext', window ); // createImageBitmap175            is_iOSDolphin    = inObject( 'enableWebGL', window );176            is_iOSBrave      = inObject( 'sameOrigin', window );177        };178        if( !platformVersion ) isPcSiteRequested = true;179        if( !platformVersion || isSleipnir_iOS ){ // Sleipnir は嘘のバージョンがUA文字列に設定されている180            platformVersion =181                // navigator[ 'mediaDevices'    ] ? 11.2 : // WebView では無効182                // https://github.com/BasqueVoIPMafia/cordova-plugin-iosrtc/issues/250#issuecomment-336240953183                window.PointerEvent        ? 13   :184                window.HTMLDataListElement ? 12.2 :185                Array.prototype.flat       ? 12   :186                navigator.sendBeacon       ? 11.3 :187                window.WebAssembly         ? 11.2 :188                window.HTMLMeterElement    ? 10.3 :189                window.Proxy               ? 10.2 :190                window.HTMLPictureElement  ?  9.3 :191                Number.isNaN               ?  9.2 :192                // http://uupaa.hatenablog.com/entry/2015/03/03/223344193                window.SharedWorker        ?194                    ( performance && performance.now ? 8.0 : 8.4 ) :195                docExecCmd                 ?  7.1 :196                window.webkitURL           ?  6.1 :197                window.Worker              ?  5.1 :198                int8Array                  ?  4.3 :199                AudioElement               ?  4.1 : 3.2;200        };201        dpRatio       = window.devicePixelRatio === 1;202        // 4:3 model203        v = screenW === screenH * 1.5 || screenW * 1.5 === screenH;204        if( fromString( strPlatform, 'iPhone' ) ){ // iPhone or iPhone Simulator205            device            = WHAT_BROWSER_AM_I__DEVICE_iPhone;206            deviceVersion     = v ? ( dpRatio ? { max : 3 } : { min : 4, max : 5 } ) : { max : 6 };207            deviceTypeIsPhone = true;208        } else if( fromString( strPlatform, 'iPad' ) || is_iPadOsPcSiteRequested ){ // iPad or iPad Simulator209            device             = WHAT_BROWSER_AM_I__DEVICE_iPad;210            deviceVersion      = dpRatio ? { max : 2 } : { min : 3 }; 211            deviceTypeIsTablet = true;212        } else if( fromString( strPlatform, 'iPod' ) ){213            device                  = WHAT_BROWSER_AM_I__DEVICE_iPod;214            deviceVersion           = v ? ( dpRatio ? { max : 3 } : 4 ) : { min : 5 };215            deviceTypeIsMediaPlayer = true;216        };217    };218    if( !versioniOSWithPuffin && // iPad iOS12.2 Puffin5.2.2 で fullscreenEnabled が存在の模様219        // ホーム画面から起動したWebページは navigator.standalone === true になっている。fullscreen API は無い。220        ( navigator.standalone ||221        // https://github.com/uupaa/WebApp2/blob/master/app/assets/modules/UserAgent.js222        // _isWebView_iOS(options)223        // iPhone 13 で fullscreenEnabled の判定が出来ない.224        // https://caniuse.com/#feat=fullscreen によると、iOS は12からなので、fullscreenEnabled による Safari/WebView の判定は 11 迄は動いたと仮定する225            ( ( deviceTypeIsTablet || platformVersion < 12 ) && inObject( 'webkitFullscreenEnabled', document ) ) ||226            ( 11 <= platformVersion && platformVersion < 13 && navigator.mediaDevices ) // 12迄は mediaDevices は Safari だけだった。227        )228    ){229        engine       = WHAT_BROWSER_AM_I__ENGINE_SafariMobile;230        brand        = WHAT_BROWSER_AM_I__BRAND_Safari;231        brandVersion = platformVersion;232    } else {233        maybe_iOSWebView = true;234        engine           = WHAT_BROWSER_AM_I__ENGINE_iOSWebView;235    };236    platform      = WHAT_BROWSER_AM_I__PLATFORM_iOS;237    engineVersion = platformVersion;238} else239/*----------------------------------------------------------------------------//240 *  Kobo241 */242if( findString( strUserAgent, 'Kobo' ) ){243// Mozilla/5.0 (Linux; U; Android 2.0; en-us;) AppleWebKit/533.1 (KHTML, like Gecko) Verson/4.0 Mobile Safari/533.1 (Kobo Touch)244    platform                = WHAT_BROWSER_AM_I__PLATFORM_Kobo;245    engine                  = WHAT_BROWSER_AM_I__ENGINE_AOSP;246    engineVersion           = 2.2;    247    brand                   = engine;248    brandVersion            = engineVersion;249    deviceTypeIsEBookReader = true;250    isAndroid               = true;251} else252/*----------------------------------------------------------------------------//253 *  Sony Reader254 */255if( findString( strUserAgent, 'EBRD' ) ){256// Mozilla/5.0 (Linux; U; ja-jp; EBRD1101; EXT) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1257    platform                = WHAT_BROWSER_AM_I__PLATFORM_SonyReader;258    //platformVersion         = 1;259    engine                  = WHAT_BROWSER_AM_I__ENGINE_AOSP;260    engineVersion           = 2.2;    261    brand                   = engine;262    brandVersion            = engineVersion;263    deviceTypeIsEBookReader = true;264} else265/*----------------------------------------------------------------------------//266 *  ChromeOS267 */268if( strVersion =269        getVersionString( strUserAgent, 'CrOS x86_64 '  ) ||270        getVersionString( strUserAgent, 'CrOS aarch64 ' ) ||271        getVersionString( strUserAgent, 'CrOS i686 '    ) ||272        getVersionString( strUserAgent, 'CrOS armv7l '  ) ){273    platform        = WHAT_BROWSER_AM_I__PLATFORM_ChromeOS;274    platformVersion = strVersion;275    deviceTypeIsPC  = true;276} else277/*----------------------------------------------------------------------------//278 *  FirefoxOS279 */280if( window.onmoztimechange !== undefined ){281    // https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Window/onmoztimechange282    // This API is available on Firefox OS for internal applications only.283    platform        = WHAT_BROWSER_AM_I__PLATFORM_FirefoxOS;284    platformVersion = versionGecko < 18.1 ? '1.0.1' :285                      versionGecko < 19   ? 1.1 :286                      versionGecko < 27   ? 1.2 :287                      versionGecko < 29   ? 1.3 :288                      versionGecko < 31   ? 1.4 :289                      versionGecko < 33   ? 2.0 :290                      versionGecko < 35   ? 2.1 :291                      versionGecko < 38   ? 2.2 :292                      versionGecko < 45   ? 2.5 :293                                            2.6; // Gecko 45294    // https://developer.mozilla.org/ja/docs/Web/HTTP/Gecko_user_agent_string_reference#Firefox_OS295    if( findString( strUserAgent, 'Mobile' ) ){296        deviceTypeIsPhone = true;297    } else if( findString( strUserAgent, 'Tablet' ) ){298        deviceTypeIsTablet = true;299    } else if( findString( strUserAgent, 'TV' ) ){300        deviceTypeIsTV = true;301    };302    // isFirefoxOS = window.pkcs11 /* 1.1 */ || window.SpecialPowers /* 1.4, 2.0, 2.1, 2.2 */ || window.home /* 1.4 */ || window.getInterface /* 1.4 */303} else304/*----------------------------------------------------------------------------//305 *  WebOS306 */307if( window.palmGetResource ){308    // https://developers.whatismybrowser.com/useragents/explore/operating_system_name/hp-webos/309    platform        = WHAT_BROWSER_AM_I__PLATFORM_WebOS;310    platformVersion = getVersionString( strUserAgent, 'webOS/' ) || getVersionString( strUserAgent, 'WEBOS' ) || getVersionString( strUserAgent, 'hpwOS/' );311    if( findString( strUserAgent, 'webOS.TV' ) || findString( strUserAgent, '/SmartTV' ) ){312        deviceTypeIsTV = true;313    } else {314        deviceTypeIsPhone = true;315    };316} else317/*----------------------------------------------------------------------------//318 *  Tizen319 */320if( strVersion = getVersionString( strUserAgent, 'Tizen ' ) ){321    platform          = WHAT_BROWSER_AM_I__PLATFORM_Tizen;322    platformVersion   = strVersion;323    brand             = WHAT_BROWSER_AM_I__ENGINE_Samsung;324    brandVersion      = verSamsung;325    engine            = brand;326    engineVersion     = brandVersion;327    deviceTypeIsPhone = true; // TODO deviceTypeIsTV = true;328} else329/*----------------------------------------------------------------------------//330 *  WindowsPhone331 */332if( strVersion = getVersionString( strUserAgent, 'Windows Phone ' ) || getVersionString( strAppVersion, 'Windows Phone OS ' ) || versionWPWithUC ){333    platform          = WHAT_BROWSER_AM_I__PLATFORM_WindowsPhone;334    platformVersion   = strVersion;335    deviceTypeIsPhone = true;336} else if( isEdgeHTML && strPlatform === 'ARM' ){337    platform          = WHAT_BROWSER_AM_I__PLATFORM_WindowsPhone;338    platformVersion   = 10;339    deviceTypeIsPhone = true;340    isPcSiteRequested = true;341} else if( isTrident && findString( strAppVersion, 'ZuneWP' ) ){ // ZuneWP はデスクトップモードで登場する342    platform          = WHAT_BROWSER_AM_I__PLATFORM_WindowsPhone;343    platformVersion   = versionTrident === 11 ? 8.1 :344                        versionTrident === 10 ? 8   :345                        versionTrident ===  9 ? 7.5 :346                        versionTrident ===  7 ? 7   : '?';347    deviceTypeIsPhone = true;348    isPcSiteRequested = true;349} else350/*----------------------------------------------------------------------------//351 *  Feature Phone352 */353// https://qiita.com/nao_tuboyaki/items/342bffd963f166393045354// ガラケーのフルブラウザ判定355if( findString( strUserAgent, 'FOMA;' ) ){356    platform          = WHAT_BROWSER_AM_I__PLATFORM_FeaturePhone;357    deviceTypeIsPhone = true;358} else if( findString( strUserAgent, 'SoftBank;' ) ){359    platform          = WHAT_BROWSER_AM_I__PLATFORM_FeaturePhone;360    deviceTypeIsPhone = true;361} else362/*----------------------------------------------------------------------------//363 *  Fire OS364 */365if( findString( strUserAgent, 'KFMUWI' ) ){366// https://developer.amazon.com/ja/docs/fire-tablets/ft-device-and-feature-specifications.html367/**368 * (2019, 9th Gen) Fire OS 6.3.0, Android 7.1.25369 * "KFMUWI"   Fire 7  370 */371    isFireOS           = true;372    platformVersion    = 6.3;373    deviceTypeIsTablet = true;374    isAndroidBased     = true;375} else if( findString( strUserAgent, 'KFKAWI' ) ){376/**377 * (2018, 8th Gen) Fire OS 6.0 => 6.3.0, Android 7.1.25378 * "KFKAWI"   Fire HD 8   379 */380    isFireOS           = true;381    platformVersion    = 6;382    deviceTypeIsTablet = true;383    isAndroidBased     = true;384} else if( findString( strUserAgent, 'KFSUWI' ) || findString( strUserAgent, 'KFAUWI' ) || findString( strUserAgent, 'KFDOWI' ) ){385/**386 * (2017, 7th Gen) Fire OS 5.3.3 => 5.3.6, Android 5.1.22387 * "KFSUWI"   Fire HD 10388 * "KFAUWI"   Fire 7389 * "KFDOWI"   Fire HD 8390 */  391    isFireOS           = true;392    platformVersion    = 5;393    deviceTypeIsTablet = true;394    isAndroidBased     = true;395} else if( findString( strUserAgent, 'KFGIWI' ) ){396/**397 * (2016, 6th Gen) Fire OS 5 => 5.3.6, Android 5.1.22398 * "KFGIWI"   Fire HD 8 (2016)399 */400    isFireOS           = true;401    platformVersion    = 5;402    deviceTypeIsTablet = true;403    isAndroidBased     = true;404} else if( findString( strUserAgent, 'KFARWI' ) || findString( strUserAgent, 'KFSAWA' ) || findString( strUserAgent, 'KFSAWI' ) ){405/**406 * (4th Gen) Fire OS 5, Android 5.1  , API level 22 (system update, available 2015)407 *           Fire OS 4, Android 4.4.2, API level 19408 * "KFARWI"   Fire HD 6409 * "KFSAWA"   Fire HDX 8.9 (WAN)410 * "KFSAWI"   Fire HDX 8.9 (Wi-Fi)411 */412    isFireOS           = true;413    platformVersion    = 5 <= parseFloat( versionAndroid ) ? 5 : 4;414    deviceTypeIsTablet = true;415    isAndroidBased     = true;416} else if( findString( strUserAgent, 'KFSOWI' ) || findString( strUserAgent, 'KFTHWA' ) || findString( strUserAgent, 'KFTHWI' ) || findString( strUserAgent, 'KFAPWA' ) || findString( strUserAgent, 'KFAPWI' ) ){417// https://dennou-note.blogspot.com/2014/02/kindle.html418/**419 * (第三世代)Fire OS 3.0。Android4.2.2(JellyBean / API level17)420 * "KFSOWI"   Kindle Fire HD421 * "KFTHWA"   Kindle Fire HDX (wan)422 * "KFTHWI"   Kindle Fire HDX (wi-fi)423 * "KFAPWA"   Kindle Fire HDX 8.9 (wan)424 * "KFAPWI"   Kindle Fire HDX 8.9 (wifi)425 */426    isFireOS           = true;427    platformVersion    = 3;428    deviceTypeIsTablet = true;429    isAndroidBased     = true;430} else if( findString( strUserAgent, 'KFOT' ) || findString( strUserAgent, 'KFTT' ) || findString( strUserAgent, 'KFJWA' ) || findString( strUserAgent, 'KFJWI' ) ){ 431/**432 * (第二世代)Android4.0.3( Ice Cream Sandwich / API level15)433 * "KFOT"     Kindle Fire434 * "KFTT"     Kindle Fire HD435 * "KFJWA"    Kindle Fire HD8.9 (wan)436 * "KFJWI"    Kindle Fire HD8.9 (wi-fi)437 */438    isFireOS           = true;439    platformVersion    = 2;440    deviceTypeIsTablet = true;441    isAndroidBased     = true;442} else if( findString( strUserAgent, 'Kindle Fire' ) ){443// (第一世代)Android 2.3.3(Gingerbread / API level10)444// "kindle Fire"   Kindle Fire445    isFireOS           = true;446    platformVersion    = 1;447    deviceTypeIsTablet = true;448    isAndroidBased     = true;449} else450/*----------------------------------------------------------------------------//451 *  Kindle paperwhite452 */453if( strVersion = getVersionString( strUserAgent, 'Kindle/' ) ){454// Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+455    platform                = WHAT_BROWSER_AM_I__PLATFORM_Kindle;456    platformVersion         = strVersion;457    engine                  = WHAT_BROWSER_AM_I__ENGINE_AOSP;458    engineVersion           = 2.2;    459    brand                   = engine;460    brandVersion            = engineVersion;461    deviceTypeIsEBookReader = true;462} else463/*----------------------------------------------------------------------------//464 *  FireTV465 */466if( isFirefoxForFireTV ){467    isFireOS          = true;468    platformVersion   = versionAndroid || versionFireOSThatFirefoxRequestingPcSite;469    deviceTypeIsTV    = true;470    isAndroidBased    = true;471    isPcSiteRequested = versionFireOSThatFirefoxRequestingPcSite;472// https://developer.amazon.com/ja/docs/fire-tv/user-agent-strings.html473} else if( findString( strUserAgent, 'AmazonWebAppPlatform' ) || findString( strUserAgent, '; AFT' ) ){474    isFireOS        = true;475    platformVersion = versionAndroid;476    deviceTypeIsTV  = true;477    isAndroidBased  = true;478} else479/*----------------------------------------------------------------------------//480 *  MeeGo481 */482if( findString( strUserAgent, 'MeeGo' ) ){483    platform = WHAT_BROWSER_AM_I__PLATFORM_MeeGo;484} else485/*----------------------------------------------------------------------------//486 *  Maemo487 */488// https://developer.mozilla.org/ja/docs/Web/HTTP/Gecko_user_agent_string_reference489// Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0) Gecko/20100101 Firefox/10.0 Fennec/10.0490if( findString( strUserAgent, 'Maemo' ) ){491    platform = WHAT_BROWSER_AM_I__PLATFORM_Maemo;492} else493/*----------------------------------------------------------------------------//494 *  WindowsMobile495 */496if( fromString( strUserAgent, 'Windows Mobile;' ) || versionIris ){497    platform        = WHAT_BROWSER_AM_I__PLATFORM_WindowsMobile;498    deviceTypeIsPDA = true;499} else500/*----------------------------------------------------------------------------//501 *  WinCE502 */503if( strPlatform === 'WinCE' ){504    platform        = WHAT_BROWSER_AM_I__PLATFORM_WinCE;505    deviceTypeIsPDA = true;506} else507/*----------------------------------------------------------------------------//508 *  Win16 Win32 Win64509 */510if( fromString( strPlatform, 'Win' ) ){511    platform        = strPlatform === 'Win16' ? WHAT_BROWSER_AM_I__PLATFORM_Win16 :512                      strPlatform === 'Win32' ? WHAT_BROWSER_AM_I__PLATFORM_Win32 :513                      strPlatform === 'Win64' ? WHAT_BROWSER_AM_I__PLATFORM_Win64 :514                                                WHAT_BROWSER_AM_I__PLATFORM_unknown;515    platformVersion = getVersionString( strUserAgent, 'Windows NT ' ) || getVersionString( strUserAgent, 'Windows ' );516    deviceTypeIsPC  = true;517} else518/*----------------------------------------------------------------------------//519 *  Mac520 */521if( fromString( strPlatform, 'Mac' ) ){522    platform        = strPlatform === 'Mac68K'    ? WHAT_BROWSER_AM_I__PLATFORM_Mac68K :523                      strPlatform === 'MacPowerPC' ||524                      strPlatform === 'MacPPC'    ? WHAT_BROWSER_AM_I__PLATFORM_MacPPC :525                      strPlatform === 'MacIntel'  ? WHAT_BROWSER_AM_I__PLATFORM_MacIntel :526                                                    WHAT_BROWSER_AM_I__PLATFORM_unknown;527    if( strVersion = getVersionString( strUserAgent.split( '_' ).join( '.' ), 'Mac OS X ' ) ){528        platformVersion = strVersion;529    };530    deviceTypeIsPC  = true;531    isMac           = true;532} else533/*----------------------------------------------------------------------------//534 *  BlackBerry535 */536if( findString( strUserAgent, 'BlackBerry' ) || findString( strUserAgent, 'BB10' ) ){537    platform          = WHAT_BROWSER_AM_I__PLATFORM_BlackBerry;538    platformVersion   = verVersion;539    deviceTypeIsPhone = true;540} else541/*----------------------------------------------------------------------------//542 *  SunOS543 */544if( findString( strUserAgent, 'SunOS' ) || findString( strUserAgent, 'Sun Solaris' ) ){545    platform       = WHAT_BROWSER_AM_I__PLATFORM_SunOS;546    deviceTypeIsPC = true;547} else548/*----------------------------------------------------------------------------//549 *  BSD550 */551if( findString( strUserAgent, 'FreeBSD' ) ){552    platform = WHAT_BROWSER_AM_I__PLATFORM_FreeBSD;553} else if( findString( strUserAgent, 'OpenBSD' ) ){554    platform = WHAT_BROWSER_AM_I__PLATFORM_OpenBSD;555} else if( findString( strUserAgent, 'NetBSD' ) ){556    platform = WHAT_BROWSER_AM_I__PLATFORM_NetBSD;557} else 558/*----------------------------------------------------------------------------//559 *  Android Fennec560 */561if( isAndroid && isGecko ){562    // PCモードの Android Firefox では platform に Android 0.0.0 が存在563    // Fennec41- 用564    // https://developer.mozilla.org/ja/docs/Gecko_user_agent_string_reference565    // バージョン 41 以降の Android 版 Firefox では platform トークンに Android バージョンが含まれます。566    // 相互運用性向上のため、Android 4 以前のバージョンでブラウザが動作している場合は 4.4 と出力します。567    // Android バージョン 4 以降では実際のバージョン番号が出力されます。568    // なお、Gecko エンジンはすべての Android バージョンに対して同じ機能を提供しています。    569    if( findString( strUserAgent, 'Android 4.4;' ) ){570        v = { min : 2.3 };571    } else if( 4 <= parseFloat( versionAndroid ) ){572        v = versionAndroid;573    } else {574        v = { min : 2.2 };575    };576    platformVersion = v;577    if( maybePCMode ) isPcSiteRequested = true;578} else579/*----------------------------------------------------------------------------//580 *  Android Presto581 */582if( isAndroid && isPresto ){583    if( versionAndroid ){584        v = versionAndroid;585    } else {586        v = { min : 1.6 };587        isPcSiteRequested = true;588    };589    platformVersion = v;590    if( findString( strUserAgent, 'Tablet' ) ){591        deviceTypeIsTablet = true;592    } else {593        deviceTypeIsPhone  = true;594    };595} else596/*----------------------------------------------------------------------------//597 *  Android598 */599if( versionAndroid ){600    platformVersion = versionAndroid;601    isAndroid       = true;602} else603/*----------------------------------------------------------------------------//604 *  Android PCSITE_REQUESTED605 */606if( maybeLinux && maybePCMode || maybeLunascapeAndroid || isSleipnirAndroid ){607    // https://ja.wikipedia.org/wiki/WebKit608    // http://www.au.kddi.com/developer/android/kishu/ua/609    // webkit version to Android version...610    surelyPcSiteRequested = true;611    // AOSP の判定は Version/ の有無. 但し「デスクトップ版で見る」場合、Version/ が居なくなる...612    // PC版で見る、にチェックが付いている場合、ユーザーエージェント文字列にも platform にも Android の文字列が存在しない(標準ブラウザ&Chrome)613    // Audio でタッチが必要か?の判定にとても困る...614    // ua には Linux x86_64 になっている strPlatform と矛盾する. ATOM CPU の場合は?615    if( verSamsung ){ // SamsungBrowser/2.0+ が Android4.4.4 から登場する616        v = { min : 4.4 };617    } else618    if( ( hasChromeObject && !maybeAOSP ) || hasOPRObject || versionOPR ){619        v = { min : 4 };620    } else {621        // https://developer.chrome.com/multidevice/webview/overview622        //   The WebView shipped with Android 4.4 (KitKat) is based on the same code as Chrome for Android version 30.623        //   This WebView does not have full feature parity with Chrome for Android and is given the version number 30.0.0.0.624        //   The updated WebView shipped with Android 4.4.3 has the version number 33.0.0.0.625        //   A developer preview WebView is shipping with the Android L Developer Preview. The developer preview version number is 36.0.0.0.626        // https://caniuse.com/#compare=chrome+30,chrome+31,chrome+32,chrome+33,chrome+34,chrome+35,chrome+36,chrome+37,android+4.4.3-4.4.4627        //   chrome30 と Android4.4.3 で未実装で Chrome36 で追加された "CSS touch-action property" を Android5+ の判定に使用。628        // https://qiita.com/DriftwoodJP/items/1916d5519857295622b2629        //   Android OS 5.0(Lollipop)から、Chromium WebView が OS から切り離され、Google Play から 「AndroidシステムのWebView」として更新できるようになった。630        //   この結果、端末ベンダー提供のパッチ適用に影響されずに更新されることになったが、この「ブラウザ」と Chrome for Android とは別物であることには注意が必要である。 631        v = versionAndroid =632            htmlStyle.touchAction !== undefined ? { min : 5 } : 633            docRegElm ? 4.4 :634            // ^______Chromium_____635            int8Array ? (636                !navigator.connection ? 4.4 : // AOSP637                ( !window.searchBoxJavaBridge_ && !hasChromeObject ) ? 4.2 : /* 4.1- には searchBoxJavaBridge_ と chrome が存在 */638                Number.isNaN ? 4.1 : 4 ) :639            534 <= versionWebKit ? 3 :640            533 <= versionWebKit ? ( AudioElement ? 2.3 : 2.2 ) :641            530 <= versionWebKit ? 2.0 : 1.5;642    643        if( maybeSamsung ){644            engine        = WHAT_BROWSER_AM_I__ENGINE_Samsung;645            engineVersion = maybeSamsung;646        };647    };648    platformVersion = v;649    isAndroid       = true;650} else651/*----------------------------------------------------------------------------//652 *  Android 5 ChromeWebView PCSITE_REQUESTED653 */654if( maybeChromeWebView ){655    platformVersion       = { min : 5 };656    isAndroid             = true;657    surelyPcSiteRequested = true;658} else659/*----------------------------------------------------------------------------//660 *  Linux661 */662if( maybeLinux ){663    if( findString(  strUserAgent, 'Ubuntu' ) ){664        platform = WHAT_BROWSER_AM_I__PLATFORM_Ubuntu;665    } else if( strVersion = getVersionString( strUserAgent, 'Mint/' ) ){666        platform        = WHAT_BROWSER_AM_I__PLATFORM_Mint;667        platformVersion = strVersion;668    } else if( strVersion = getVersionString( strUserAgent, 'Fedora/' ) ){669        platform        = WHAT_BROWSER_AM_I__PLATFORM_Fedora;670        platformVersion = strVersion;671    } else if( findString( strUserAgent, 'Gentoo' ) ){672        platform = WHAT_BROWSER_AM_I__PLATFORM_Gentoo;673    } else {674        platform = WHAT_BROWSER_AM_I__PLATFORM_Linux;675    };676};677if( isFireOS || ( isAndroid && surelyPcSiteRequested && versionSilk ) ){ // Silk & android & pcmode の場合、FireOS678    platform = WHAT_BROWSER_AM_I__PLATFORM_FireOS;679} else if( isAndroid ){680    platform = platform || WHAT_BROWSER_AM_I__PLATFORM_Android;...

Full Screen

Full Screen

1_packageGlobal.js

Source:1_packageGlobal.js Github

copy

Full Screen

...23    for( var k in obj ){24        if( k === name ) return true;25    };26};27function getVersionString( strTarget, strStart ){28    var ret = '', i = -1, charCode;29    if( strTarget = strTarget.split( strStart )[ 1 ] ){30        while( charCode = strTarget.charCodeAt( ++i ) ){31            if( ( 48 <= charCode && charCode <= 57 ) || charCode === 46 ){32                ret += strTarget.charAt( i );33            } else {34                break;35            };36        };37        i = ret.length;38        while( i ){39            if( ret.charCodeAt( --i ) === 46 ){40                ret = ret.substr( 0, i );41            } else {42                break;43            };44        };45    };46    return ret;47};48/**49 * @param {...(string|number)} _args50 * @return {string|number}51 */52function max( _args ){53    var args = arguments, i = 1, max = args[ 0 ], v;54    55    for( ; i < args.length; ++i ){56        if( conpareVersionString( max, v = args[ i ] ) < 0 ) max = v;57    };58    return max;59};60var engine, engineVersion, platform, platformVersion, brand, brandVersion, device, deviceVersion,61    62    conpareVersionString = ua.conpare,63    strUserAgent  = navigator.userAgent,64    strAppVersion = navigator.appVersion,65    appVersion    = parseFloat( strAppVersion ) || 0,66    strPlatform   = navigator.platform,67    html          = document.documentElement,68    htmlStyle     = html && html.style,69    docMode       = document.documentMode,70    screenW       = screen.width,71    screenH       = screen.height,72    AudioElement  = window.HTMLAudioElement,73    performance   = window.performance,74    int8Array     = window.Int8Array,75    isTouch       = window.ontouchstart !== undefined,76    verVersion    = getVersionString( strAppVersion, 'Version/' ) || getVersionString( strUserAgent, 'Version/' ),77    /*78     * http://qiita.com/takanamito/items/8c2b6bc24ea01381f1b5#_reference-8eedaa6525b73cd272b779     * インドネシアの特殊なブラウザ事情(Opera Mini,UC Browser Mini)80     */81    hasOperaMiniObject = window.operamini, // iOS Opera Mini には .operamini が無い. iOS 12.2 Opera Mini 16.0.1482    /*83     * http://help.dottoro.com/ljifbjwf.php84     * version method (opera)85     *   window.opera.buildNumber();86     *   window.opera.version();87     * 88     * kQuery.js89     *   opera.versionは8から実装90     */91    isPresto      = !hasOperaMiniObject && window.opera,92    versionPresto = isPresto && (93        ( isPresto.version && typeof isPresto.version === 'function' ) ? isPresto.version() : max( getVersionString( strUserAgent, 'Opera ' ), verVersion, appVersion )94    ),95    hasOPRObject  = window.opr, // 全ての Blink Opera に存在するわけではない?96    isTrident      = !isPresto && ( document.all || docMode ), // IE11 には .all が居ない .docMode == 1197    versionTrident = isTrident && (98        docMode               ? docMode :99        window.XMLHttpRequest ? ( document.getElementsByTagName ? 7 : 4 ) :100        document.compatMode   ? 6   :101        (0).toFixed           ? 5.5 :102        window.attachEvent    ? 5   : 4 ),103 104    isEdgeHTML      = !isTrident && html.msContentZoomFactor,105    hasChromeObject = !isEdgeHTML && ( window.chrome ||   // AOSP 4.1 にもいるので注意!106                                       window.chromium ), // Iron 3 は .chrome が居ない .chromium が居る, 5 では両方存在.107    // https://www.fxsitecompat.com/ja/docs/2017/moz-appearance-property-has-been-removed/108    // -moz-appearance プロパティが廃止されました -> 更新: この変更は Firefox 54 で予定されていましたが、延期されました。109    isGecko = !isTrident && // ie4 でエラーになる為110                  (function(){111                      for( var k in htmlStyle ){112                          if( fromString( k, 'Moz' ) ) return true;113                      };114                  })(),115                  // htmlStyle.MozAppearance !== undefined, // window.Components116    isUCWEB      = findString( strUserAgent, 'UCWEB' ),117    versionUCWEB = isUCWEB && getVersionString( strUserAgent, ' U2/' ),118    // https://developers.whatismybrowser.com/useragents/parse/244780-uc-browser-windows119    // UCWEB/2.0 (Windows; U; wds 8.10; en-US; NOKIA; RM-976_1115) U2/1.0.0 UCBrowser/4.2.1.541 U2/1.0.0 Mobile120    versionWPWithUC = isUCWEB && getVersionString( strUserAgent, '; wds ' ),// UC Browser121    // http://thadafinser.github.io/UserAgentParserComparison/v4/user-agent-detail/d4/26/d4262844-7040-4f5b-8f26-bf0477b215c3.html122    // UCWEB/2.0 (iOS; U; iPh OS 6_1_3; xx; iPh3,1) U2/1.0.0 UCBrowser/9.0.1.284 U2/1.0.0 Mobile123    versioniOSWithUC        = getVersionString( strUserAgent.split( '_' ).join( '.' ), '; iPh OS ' ),124    versionAndroidWithUCWEB = getVersionString( strUserAgent, '; Adr ' ), // Android for UC Browser Speed mode125    isYahooForAandroid = findString( strAppVersion, 'YJApp-ANDROID' ), // Android 7, Y!browser 2.5.56126    127    isAndroid  = findString( strPlatform, 'Android' ) ||128                 ( isGecko && findString( strAppVersion, 'Android' ) ) || /* Android2.3.5 Firefox3.1 */129                 isYahooForAandroid,130    versionAndroid = getVersionString( strPlatform , 'Android ' ) || getVersionString( strAppVersion, 'Android ' ) ||131                     getVersionString( strUserAgent, 'Android ' ) || versionAndroidWithUCWEB,132    maybeLinux  = findString( strPlatform, 'Linux' ), // Linux or Android133    // https://www.bit-hive.com/articles/20190820134    is_iPadOsPcSiteRequested = strPlatform === 'MacIntel' && navigator.standalone !== undefined,135// https://developers.whatismybrowser.com/useragents/parse/987005-pale-moon-windows-goanna136// TODO Goanna/20161201 になっている時がある…137    versionGoanna  = isGecko && getVersionString( strUserAgent, 'Goanna/' ),138    versionGecko   = !versionGoanna && isGecko && (139                         getVersionString( strUserAgent, 'rv:' ) ||140                         getVersionString( strUserAgent.substr( strUserAgent.indexOf( ') Gecko/' ) - 11 ), '; ' ) // for Gecko ~0.8.1141                     ),142    versionFirefox = getVersionString( strUserAgent, 'Firefox/' ), // Android9 + Firefox67.0 + PC_MOEDE で rv: が存在しない!143    versionOpera   = getVersionString( strUserAgent, 'Opera/' ),144    isSleipnir_iOS = window.FNRBrowser,145    versionWebKit = getNumber( strUserAgent, 'AppleWebKit/' ),146    versionChrome = getVersionString( strUserAgent, 'Chrome/' ),147    versionIron   = getVersionString( strAppVersion, 'Iron/' ), // Iron 3 には Chrome/ が居ない, Iron 5 は Iron/ Chrome/ の併記.148    versionOPR    = getVersionString( strUserAgent, 'OPR/' ),149    versionKHTML  = getVersionString( strAppVersion, 'KHTML/' ),150    versionIris   = getVersionString( strUserAgent.toLowerCase(), 'iris' ),151    versionFxiOS  = getVersionString( strUserAgent, 'FxiOS/' ),152    versionCriOS  = getVersionString( strUserAgent, 'CriOS/' ),153    versionEdgiOS = getVersionString( strUserAgent, 'EdgiOS/' ),154    versionSilk   = getVersionString( strUserAgent, 'Silk/' ),155    // https://issuetracker.google.com/issues/36957795156    //  Canvas clearRect failing to clear157    // https://stackoverflow.com/questions/14948720/is-it-possible-to-detect-samsung-stock-browser158    //  Is it possible to detect samsung stock browser159    // https://gist.github.com/poshaughnessy/5718717a04db20a02e9fdb3fc16e2258160    // https://gist.github.com/NielsLeenheer/4daa6a9ce7f4a0f4733d161    // https://developers.whatismybrowser.com/useragents/explore/software_name/samsung-browser/162    // スマホに登場するのは 4.4.4 以降で SamsungBrowser/2.0 から。163    // SMART-TV には /1.0 から。Tizen 2.3164    verSamsung   = getNumber( strUserAgent, 'SamsungBrowser/' ),165    // https://gist.github.com/uupaa/b25c9cf47bbeedea5a7f166    // Android 4.4 から Android Browser は Chrome WebView をベースにしているとのことなので、ちょっと古めの Chrome という扱いで良さそうです。167    maybeSamsung = !verSamsung && (function(){168        var unversionedDevices = (...

Full Screen

Full Screen

4_brand.js

Source:4_brand.js Github

copy

Full Screen

1if( !DEFINE_WHAT_BROWSER_AM_I__BRAND_ENABLED ){2    if( getVersionString( strAppVersion, 'OPT/' ) ){3        isPcSiteRequested = isPcSiteRequested || !findString( strAppVersion, 'Mobile/' );4    };5} else {6    if( !brand ){7    // https://qiita.com/Ungaahhhh/items/980316d11c55acecbfa58    // Edge のユーザーエージェントがいろいろとひどい9        if( strVersion =10            ( isEdgeHTML && getVersionString( strUserAgent, 'Edge/'   ) ) || // Win Edge11            getVersionString( strUserAgent, 'EdgA/'   ) || // Android12            versionEdgiOS || // iOS13            getVersionString( strUserAgent, 'Edg/'    )    // Chromium based Microsoft Edge(MSEdge)14        ){15            brand        = WHAT_BROWSER_AM_I__BRAND_Edge;16            brandVersion = strVersion;17        } else if( strVersion = getVersionString( strAppVersion, 'Coast/' ) ){18            brand        = WHAT_BROWSER_AM_I__BRAND_Coast;19            brandVersion = strVersion;20        } else if( is_iOSOperaTurbo ){21            brand        = WHAT_BROWSER_AM_I__BRAND_OperaTurbo;22        } else if( strVersion = getVersionString( strAppVersion, 'OPT/' ) ){23            brand             = WHAT_BROWSER_AM_I__BRAND_OperaTouch;24            brandVersion      = strVersion;25            isPcSiteRequested = isPcSiteRequested || !findString( strAppVersion, 'Mobile/' );26        } else 27    // https://himenaotaro.hatenablog.com/entry/20151011/144456426528    // YJApp-IOS ユーザエージェント(User Agent)29        if( strVersion = getVersionString( strUserAgent.toLowerCase(), 'ybrowser/' ) ){30            brand        = WHAT_BROWSER_AM_I__BRAND_Yahoo;31            brandVersion = strVersion;32        } else33        if( !isUCWEB && ( strVersion = getVersionString( strUserAgent, 'UCBrowser/' ) ) ){34            brand        = WHAT_BROWSER_AM_I__BRAND_UC;35            brandVersion = strVersion;36        } else37        if( versionSilk ){38            brand        = WHAT_BROWSER_AM_I__BRAND_Silk;39            brandVersion = versionSilk;40        } else41        if( strVersion = getVersionString( strUserAgent, 'Vivaldi/' ) ){42            brand        = WHAT_BROWSER_AM_I__BRAND_Vivaldi;43            brandVersion = strVersion;44        } else45        if( strVersion = getVersionString( strUserAgent, 'QQBrowser/' ) ){46            brand        = WHAT_BROWSER_AM_I__BRAND_QQ;47            brandVersion = strVersion;48        } else49        if( strVersion = getVersionString( strUserAgent, 'YaBrowser/' ) ){50            brand        = WHAT_BROWSER_AM_I__BRAND_Yandex;51            brandVersion = strVersion;52        } else53        if( strVersion = getVersionString( strUserAgent, 'coc_coc_browser/' ) ){54            brand        = WHAT_BROWSER_AM_I__BRAND_coccoc;55            brandVersion = strVersion;56        } else57        if( strVersion = getVersionString( strUserAgent, 'Camino/' ) ){58            brand        = WHAT_BROWSER_AM_I__BRAND_Camino;59            brandVersion = strVersion;60        } else61        if( findString( strUserAgent, 'SE 2.X MetaSr 1.0' ) ){62            brand = WHAT_BROWSER_AM_I__BRAND_Sogou;63        } else64    // https://developer.mozilla.org/ja/docs/Web/HTTP/Gecko_user_agent_string_reference65    // バージョン 6 より前では、 Focus for Android は Android WebView によって実現されていたため、以下の UA 文字列形式を使用していました。66    // Mozilla/5.0 (Linux; <Android Version> <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Version/4.0 Focus/<focusversion> Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>67    68        if( strVersion =69            getVersionString( strUserAgent, 'Focus/' ) || getVersionString( strUserAgent, 'Klar/' ) ||70            // https://apps.apple.com/jp/app/firefox-focus-e3-83-97-e3-83-a9-e3-82-a4-e3-83-90-e3/id105567733771            // iOS 12.2, Focus 8.1.2, (iOS 11.0以降)72            // https://en.wikipedia.org/wiki/Firefox_for_iOS#cite_note-1073            // Focus   : FxiOS が 8.x にも拘わらず、iOS のバージョンが 11 以上、を使って判定74            // Firefox : FxiOS が 9.x 以降が、iSO 11+ 対応を持って判定75            ( parseFloat( versionFxiOS ) < 9 && maybe_iOSWebView && 11 <= parseFloat( platformVersion ) && versionFxiOS )76        ){77            brand        = WHAT_BROWSER_AM_I__BRAND_Focus;78            brandVersion = strVersion;79        } else80        if( strVersion = getVersionString( strUserAgent, 'AOLBUILD/' ) || getVersionString( strUserAgent, 'AOL/' ) || getVersionString( strUserAgent, 'AOL ' ) ){81            brand        = WHAT_BROWSER_AM_I__BRAND_AOL;82            brandVersion = strVersion;83        } else84        if( strVersion = getVersionString( strUserAgent, 'IceDragon/' ) ){85            brand        = WHAT_BROWSER_AM_I__BRAND_IceDragon;86            brandVersion = strVersion;87        } else88        if( strVersion = getVersionString( strUserAgent, 'Iceweasel/' ) ){89            brand        = WHAT_BROWSER_AM_I__BRAND_Iceweasel;90            brandVersion = strVersion;91        } else92        if( strVersion = getVersionString( strUserAgent, 'TenFourFox/' ) ){93            brand        = WHAT_BROWSER_AM_I__BRAND_ITenFourFox;94            brandVersion = strVersion;95        } else96        if( strVersion = getVersionString( strUserAgent, 'Waterfox/' ) ){97            brand        = WHAT_BROWSER_AM_I__BRAND_Waterfox;98            brandVersion = strVersion;99        } else100        if( strVersion = getVersionString( strUserAgent, 'GNUzilla/' ) ){101            brand        = WHAT_BROWSER_AM_I__BRAND_GNUzilla;102            brandVersion = strVersion;103        } else104        if( strVersion = getVersionString( strUserAgent, 'SeaMonkey/' ) ){105            brand        = WHAT_BROWSER_AM_I__BRAND_SeaMonkey;106            brandVersion = strVersion;107        } else108        if( strVersion = getVersionString( strUserAgent, 'PaleMoon/' ) ){109            brand        = WHAT_BROWSER_AM_I__BRAND_PaleMoon;110            brandVersion = strVersion;111        } else112        if( strVersion = getVersionString( strUserAgent, 'Basilisk/' ) ){113            brand        = WHAT_BROWSER_AM_I__BRAND_Basilisk;114            brandVersion = strVersion;115        } else116        if( ( strVersion = getVersionString( strUserAgent, 'Maxthon/' ) ||117                           getVersionString( strUserAgent, 'Maxthon ' ) ||118                           getVersionString( strUserAgent, 'MXiOS/' )119            ) || findString( strUserAgent, 'Maxthon' ) ){120            brand        = WHAT_BROWSER_AM_I__BRAND_Maxthon;121            brandVersion = strVersion || 1;122        } else123        if( findString( strUserAgent, 'Avant Browser;' ) ){124            brand = WHAT_BROWSER_AM_I__BRAND_Avant;125        } else126        if( strVersion = getVersionString( strUserAgent, 'Konqueror/' ) ){127            brand        = WHAT_BROWSER_AM_I__BRAND_Konqueror;128            brandVersion = strVersion;129        } else130        if( strVersion = getVersionString( strUserAgent, 'Midori/' ) ){131            brand        = WHAT_BROWSER_AM_I__BRAND_Midori;132            brandVersion = strVersion;133        } else134        if( strVersion = getVersionString( strUserAgent, 'OmniWeb/' ) ){135            brand        = WHAT_BROWSER_AM_I__BRAND_OmniWeb;136            brandVersion = strVersion;137        } else138        if( strVersion = getVersionString( strUserAgent, 'Roccat/' ) ){139            brand        = WHAT_BROWSER_AM_I__BRAND_Roccat;140            brandVersion = strVersion;141        } else142        if( strVersion = getVersionString( strUserAgent, 'Epiphany/' ) ){143            brand        = WHAT_BROWSER_AM_I__BRAND_Epiphany;144            brandVersion = strVersion;145        } else146        if( strVersion = getVersionString( strUserAgent, 'WebPositive/' ) ){147            brand        = WHAT_BROWSER_AM_I__BRAND_WebPositive;148            brandVersion = strVersion;149        } else150        if( ( strVersion = getVersionString( strUserAgent, 'Iron/' ) ) || findString( strUserAgent, ' Iron ' ) ){151            brand        = WHAT_BROWSER_AM_I__BRAND_Iron;152            brandVersion = strVersion || ( hasChromeObject && versionChrome );153        } else154        if( strVersion = getVersionString( strUserAgent, 'Comodo Dragon/' ) ){155            brand        = WHAT_BROWSER_AM_I__BRAND_ComodoDragon;156            brandVersion = strVersion;157        } else158        if( ( strVersion = getVersionString( strUserAgent, 'Brave/' ) ) || findString( strUserAgent, ' Brave ' ) || is_iOSBrave ){159            brand        = WHAT_BROWSER_AM_I__BRAND_Brave;160            brandVersion = strVersion || ( hasChromeObject && versionChrome );161        } else162        if( strVersion = getVersionString( strUserAgent, 'Rockmelt/' ) ){163            brand        = WHAT_BROWSER_AM_I__BRAND_Rockmelt;164            brandVersion = strVersion;165        } else166        if( ( strVersion = getVersionString( strUserAgent, 'Sleipnir/' ) ) || isSleipnir_iOS || isSleipnirAndroid ){167            brand        = WHAT_BROWSER_AM_I__BRAND_Sleipnir;168            if( strVersion ){169                brandVersion = strVersion;170            };171        } else172        if( is_iOSDolphin ){173            brand = WHAT_BROWSER_AM_I__BRAND_Dolphin;174        } else175        if( strVersion = getVersionString( strUserAgent, 'Puffin/' ) ){176            brand        = WHAT_BROWSER_AM_I__BRAND_Puffin;177            brandVersion = strVersion;178        } else179        if( strVersion = getVersionString( strUserAgent, 'Dooble/' ) ){180            brand        = WHAT_BROWSER_AM_I__BRAND_Dooble;181            brandVersion = strVersion;182        } else183        if( strVersion = getVersionString( strUserAgent, 'Flock/' ) ){184            brand        = WHAT_BROWSER_AM_I__BRAND_Flock;185            brandVersion = strVersion;186        } else187        if( strVersion = getVersionString( strUserAgent, 'Galeon/' ) ){188            brand        = WHAT_BROWSER_AM_I__BRAND_Galeon;189            brandVersion = strVersion;190        } else191        if( strVersion = getVersionString( strUserAgent, 'Falkon/' ) ){192            brand        = WHAT_BROWSER_AM_I__BRAND_Falkon;193            brandVersion = strVersion;194        } else195        if( strVersion = getVersionString( strUserAgent, 'Iceape/' ) ){196            brand        = WHAT_BROWSER_AM_I__BRAND_Iceape;197            brandVersion = strVersion;198        } else199        if( strVersion = getVersionString( strUserAgent, 'K-Meleon/' ) ){200            brand        = WHAT_BROWSER_AM_I__BRAND_KMeleon;201            brandVersion = strVersion;202        } else203        if( strVersion = versionNX || getVersionString( strAppVersion, 'NX/' ) ){204            brand        = WHAT_BROWSER_AM_I__BRAND_NetFrontNX;205            brandVersion = strVersion;206        } else207        if( platform === WHAT_BROWSER_AM_I__PLATFORM_WiiU ){208            brand        = WHAT_BROWSER_AM_I__BRAND_NetFrontNX;209            brandVersion = 3;210        } else211    // Netscape Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3212    // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)213    // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20070321 Netscape/8.1.3214    // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6215        if( strVersion =216            getVersionString( strUserAgent, 'Netscape6/' ) || // NN6217            getVersionString( strUserAgent, 'Netscape/'  ) || // NN7-8218            getVersionString( strUserAgent, 'Navigator/' )    // NN9219        ){220            brand        = WHAT_BROWSER_AM_I__BRAND_NetscapeNavigator;221            brandVersion = strVersion;222        } else if( versionIris ){223            // http://archive.is/0trve224            // Mozilla/5.0 (Windows NT; U; en) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Iris/1.1.7 Safari/525.20225            brand        = WHAT_BROWSER_AM_I__BRAND_Iris;226            brandVersion = strVersion;227        // https://twitter.com/itozyun/status/1293709088501555200228        } else if( strVersion = getVersionString( strUserAgent, 'FBAV/' ) || findString( strAppVersion, 'FBAN/' ) ){229            brand        = WHAT_BROWSER_AM_I__BRAND_Facebook;230            brandVersion = strVersion;231        } else if( strVersion = getVersionString( strAppVersion, 'Line/' ) ){232            brand        = WHAT_BROWSER_AM_I__BRAND_LINE;233            brandVersion = strVersion;234        } else if( strVersion = getVersionString( strUserAgent, 'QtWebEngine/' ) ){235            brand        = WHAT_BROWSER_AM_I__BRAND_QtWebEngine;236            brandVersion = strVersion;237        } else if( strVersion = getVersionString( strUserAgent, 'QtWebKit/' ) ){238            brand        = WHAT_BROWSER_AM_I__BRAND_QtWebKit;239            brandVersion = strVersion;240        } else if( strVersion = getVersionString( strUserAgent, 'DuckDuckGo/' ) ){241            brand        = WHAT_BROWSER_AM_I__BRAND_DuckDuckGo;242            brandVersion = strVersion;243        } else if( strVersion = getVersionString( strUserAgent, 'Lunascape/' ) || maybeLunascapeAndroid ){244            brand        = WHAT_BROWSER_AM_I__BRAND_Lunascape;245            brandVersion = strVersion;246        } else if( strVersion = versionFxiOS || ( isGecko && ( versionFirefox || engineVersion ) ) ){247            brand        = WHAT_BROWSER_AM_I__BRAND_Firefox;248            brandVersion = strVersion;249        } else if( isOperaGX ){250            brand        = WHAT_BROWSER_AM_I__BRAND_OperaGX;251            brandVersion = versionOPR;252        } else if( strVersion = versionPresto || versionOPR || versionOpera ){253            brand        = WHAT_BROWSER_AM_I__BRAND_Opera;254            brandVersion = strVersion;255        } else if( isTrident ){256            brand        = WHAT_BROWSER_AM_I__BRAND_IE;257            brandVersion = engineVersion;...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...29  }30  return getVersionString.cache.get(versionPath);31};32const generateInvalidPointTrace = async (execPath, match, filePath, textEditor, point) => {33  const flake8Version = await getVersionString(execPath);34  const issueURL = 'https://github.com/AtomLinter/linter-flake8/issues/new';35  const title = encodeURIComponent(`Flake8 rule '${match[3]}' reported an invalid point`);36  const body = encodeURIComponent([37    `Flake8 reported an invalid point for the rule \`${match[3]}\`, ` +38    `with the messge \`${match[5]}\`.`,39    '', '',40    '<!-- If at all possible, please include code that shows this issue! -->',41    '', '',42    'Debug information:',43    `Atom version: ${atom.getVersion()}`,44    `Flake8 version: \`${flake8Version}\``,45  ].join('\n'));46  const newIssueURL = `${issueURL}?title=${title}&body=${body}`;47  return {...

Full Screen

Full Screen

pne_utils.js

Source:pne_utils.js Github

copy

Full Screen

...22function isPNE() {23  if (appjet.cache.fakePNE || appjet.config['etherpad.fakePNE']) {24    return true;25  }26  if (getVersionString()) {27    return true;28  }29  return false;30}31/**32 * Versioning scheme: we basically just use the apache scheme of MAJOR.MINOR.PATCH:33 *34 *     Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The35 *     basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API.36 *     MINOR versions retain source and binary compatibility with older minor versions, and37 *     changes in the PATCH level are perfectly compatible, forwards and backwards.38 */39function getVersionString() {40  return appjet.config['etherpad.pneVersion'];41}42function parseVersionString(x) {43  var parts = x.split('.');44  return {45    major: Number(parts[0] || 0),46    minor: Number(parts[1] || 0),47    patch: Number(parts[2] || 0)48  };49}50/* returns {major: int, minor: int, patch: int} */51function getVersionNumbers() {52  return parseVersionString(getVersionString());53}54function checkDbVersionUpgrade() {55  var dbVersionString = persistent_vars.get("db_pne_version");56  var runningVersionString = getVersionString();57  if (!dbVersionString) {58    println("Upgrading to Private Network Edition, version: "+runningVersionString);59    return;60  }61  var dbVersion = parseVersionString(dbVersionString);62  var runningVersion = getVersionNumbers();63  var trueRegex = /\s*true\s*/i;64  var force = trueRegex.test(appjet.config['etherpad.forceDbUpgrade']);65  if (!force && (runningVersion.major != dbVersion.major)) {66    println("Error: you are attempting to update an EtherPad["+dbVersionString+67            "] database to version ["+runningVersionString+"].  This is not possible.");68    println("Exiting...");69    System.exit(1);70  }71  if (!force && (runningVersion.minor < dbVersion.minor)) {72    println("Error: your etherpad database is at a newer version ["+dbVersionString+"] than"+73            " the current running etherpad ["+runningVersionString+"].  Please upgrade to the "+74            " latest version.");75    println("Exiting...");76    System.exit(1);77  }78  if (!force && (runningVersion.minor > (dbVersion.minor + 1))) {79    println("\n\nWARNING: you are attempting to upgrade from version "+dbVersionString+" to version "+80            runningVersionString+".  It is recommended that you upgrade one minor version at a time."+81            " (The \"minor\" version number is the second number separated by dots.  For example,"+82            " if you are running version 1.2, it is recommended that you upgrade to 1.3 and then 1.4 "+83            " instead of going directly from 1.2 to 1.4.");84    println("\n\nIf you really want to do this, you can force us to attempt the upgrade with "+85            " the --etherpad.forceDbUpgrade=true flag.");86    println("\n\nExiting...");87    System.exit(1);88  }89  if (runningVersion.minor > dbVersion.minor) {90    println("Upgrading database to version "+runningVersionString);91  }92}93function saveDbVersion() {94  var dbVersionString = persistent_vars.get("db_pne_version");95  if (getVersionString() != dbVersionString) {96    persistent_vars.put('db_pne_version', getVersionString());97    println("Upgraded Private Network Edition version to ["+getVersionString()+"]");98  }99}100// These are a list of some of the config vars documented in the PNE manual.  They are here101// temporarily, until we move them to the PNE config UI.102var _eepneAllowedConfigVars = [103  'configFile',104  'etherpad.soffice',105  'etherpad.useMySQL',106  'etherpad.SQL_JDBC_DRIVER',107  'etherpad.SQL_JDBC_URL',108  'etherpad.SQL_PASSWORD',109  'etherpad.SQL_USERNAME',110  'etherpad.adminPass',111  'etherpad.licenseKey',...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

...60        patch: currentVersion.patch + 161      }    62  }63}64function getVersionString(version) {65  return Object.values(version).map(v => v.toString()).join('.')66}67function writeUpdatedVersion(updatedVersion) {68  const updatedPackage = Object.assign({}, package)69  updatedPackage.version = getVersionString(updatedVersion)70  const packageJsonString = JSON.stringify(updatedPackage, (_, v) => v, 2)71  fs.writeFileSync('package.json', packageJsonString)72}73function update(currentVersion) {74  console.log('================= VERSIONING =================')75  console.info('Starting versioning process')76  const option = getOption(argv)77  console.info(`Current Version: ${getVersionString(currentVersion)}`)78  const updatedVersion = getUpdatedVersion(currentVersion, option)79  console.info(`${option.toUpperCase()} update -> ${getVersionString(updatedVersion)}`)80  writeUpdatedVersion(updatedVersion)81  console.info('The new version was written to package.json')82  console.info('Finished versioning process')83  if (option === 'dry') {84    console.info('Skipped publication process because of dry-run mode')85    process.exit(0)86  }87}88function rollback(currentVersion) {89  console.log('================= ROLLBACK =================')90  console.info('Starting versioning rollback')91  console.info(`Rollback to: ${getVersionString(currentVersion)}`)92  writeUpdatedVersion(currentVersion)93  console.info('The rollbacked version was written to package.json')94  console.info('Finished versioning rollback')95}96function publish() {97  console.log('================= PUBLISH =================')98  console.info('Starting publication process')99  console.info('Writing temporary directory for publication')100  fs.copySync('dist', 'tmp')101  fs.copyFileSync('package.json', 'tmp/package.json')102  console.info('Start publishing')103  console.time('Finished publising in')104  try {105    childProcess.execSync('cd tmp && yarn publish')...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...36            // @see https://github.com/cypress-io/cypress/issues/702037            foundBrowser.profilePath = path_1.default.join(os_1.default.homedir(), 'snap', 'chromium', 'current');38        }39    };40    return getVersionString(binary)41        .tap(maybeSetSnapProfilePath)42        .then(getVersion)43        .then((version) => {44        foundBrowser.version = version;45        return foundBrowser;46    })47        .catch(logAndThrowError);48}49function getVersionString(path) {50    (0, log_1.log)('finding version string using command "%s --version"', path);51    return bluebird_1.default.resolve(utils_1.utils.getOutput(path, ['--version']))52        .timeout(30000, `Timed out after 30 seconds getting browser version for ${path}`)53        .then((val) => val.stdout)54        .then((val) => val.trim())55        .then((val) => {56        (0, log_1.log)('stdout: %s', val);57        return val;58    });59}60exports.getVersionString = getVersionString;61function getVersionNumber(version, browser) {62    const regexExec = browser.versionRegex.exec(version);63    return regexExec ? regexExec[1] : version;...

Full Screen

Full Screen

helpers.js

Source:helpers.js Github

copy

Full Screen

...7  + ' node/' + process.version.replace('v', '');8describe('Version strings', function () {9  describe('getVersionString', function () {10    it('returns the current version, when unmodified', function () {11      var str = helpers.getVersionString();12      expect(str).to.equal(userAgent);13    });14  });15  describe('appendToVersionString', function () {16    it('appends a new value', function () {17      var str;18      helpers.appendToVersionString('foobar', '1.2');19      str = helpers.getVersionString();20      expect(str).to.equal(userAgent + ' foobar/1.2');21    });22  });23  describe('appendToVersionString', function () {24    it('should never overwrite an existing value', function () {25      var str;26      helpers.appendToVersionString('foobar', '1.3');27      str = helpers.getVersionString();28      // TODO that the order of these tests _matters_ bothers me29      expect(str).to.equal(userAgent + ' foobar/1.2 foobar/1.3');30    });31  });32  describe('appendToVersionStringWithoutVersion', function () {33    it('should never overwrite an existing value', function () {34      var str;35      helpers.appendToVersionString('foobar');36      str = helpers.getVersionString();37      // TODO that the order of these tests _matters_ bothers me38      expect(str).to.equal(userAgent + ' foobar/1.2 foobar/1.3 foobar');39    });40  });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress')2cypress.getVersionString().then(version => {3    console.log(version)4})5{6}7{8    "scripts": {9    }10}

Full Screen

Using AI Code Generation

copy

Full Screen

1var version = Cypress.version;2console.log('Cypress version is: ' + version);3var version = Cypress.version;4console.log('Cypress version is: ' + version);5var version = Cypress.version;6console.log('Cypress version is: ' + version);7var version = Cypress.version;8console.log('Cypress version is: ' + version);9var version = Cypress.version;10console.log('Cypress version is: ' + version);11var version = Cypress.version;12console.log('Cypress version is: ' + version);13var version = Cypress.version;14console.log('Cypress version is: ' + version);

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful