test: add Intl polyfill and run Intl tests in all browsers (#10471)

This commit is contained in:
Marc Laval
2016-09-01 00:55:13 +02:00
committed by Martin Probst
parent 562c8263dc
commit 1b5e2b5129
5 changed files with 196 additions and 129 deletions

View File

@ -50,15 +50,25 @@ export class BrowserDetection {
get isSlow(): boolean { return this.isAndroid || this.isIE || this.isIOS7; }
// The Intl API is only properly supported in recent Chrome and Opera.
// Note: Edge is disguised as Chrome 42, so checking the "Edge" part is needed,
// see https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
get supportsIntlApi(): boolean { return !!(<any>global).Intl; }
// The Intl API is only natively supported in Chrome, Firefox, IE11 and Edge.
// This detector is needed in tests to make the difference between:
// 1) IE11/Edge: they have a native Intl API, but with some discrepancies
// 2) IE9/IE10: they use the polyfill, and so no discrepancies
get supportsNativeIntlApi(): boolean {
return !!(<any>global).Intl && (<any>global).Intl !== (<any>global).IntlPolyfill;
}
get isChromeDesktop(): boolean {
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
this._ua.indexOf('Edge') == -1;
}
// "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
// Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
get isOldChrome(): boolean {
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
this._ua.indexOf('Edge') == -1;
}
}
BrowserDetection.setup();