test: add Intl polyfill and run Intl tests in all browsers (#10471)
This commit is contained in:
parent
562c8263dc
commit
1b5e2b5129
|
@ -18,6 +18,14 @@ export function main() {
|
|||
var date: Date;
|
||||
var pipe: DatePipe;
|
||||
|
||||
// TODO: reactivate the disabled expectations once emulators are fixed in SauceLabs
|
||||
// In some old versions of Chrome in Android emulators, time formatting returns dates in the
|
||||
// timezone of the VM host,
|
||||
// instead of the device timezone. Same symptoms as
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=406382
|
||||
// This happens locally and in SauceLabs, so some checks are disabled to avoid failures.
|
||||
// Tracking issue: https://github.com/angular/angular/issues/11187
|
||||
|
||||
beforeEach(() => {
|
||||
date = DateWrapper.create(2015, 6, 15, 9, 3, 1);
|
||||
pipe = new DatePipe('en-US');
|
||||
|
@ -26,81 +34,99 @@ export function main() {
|
|||
it('should be marked as pure',
|
||||
() => { expect(new PipeResolver().resolve(DatePipe).pure).toEqual(true); });
|
||||
|
||||
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||
// https://github.com/angular/angular/issues/3333
|
||||
// Have to restrict to Chrome as IE uses a different formatting
|
||||
if (browserDetection.supportsIntlApi && browserDetection.isChromeDesktop) {
|
||||
describe('supports', () => {
|
||||
it('should support date', () => { expect(() => pipe.transform(date)).not.toThrow(); });
|
||||
it('should support int', () => { expect(() => pipe.transform(123456789)).not.toThrow(); });
|
||||
it('should support numeric strings',
|
||||
() => { expect(() => pipe.transform('123456789')).not.toThrow(); });
|
||||
describe('supports', () => {
|
||||
it('should support date', () => { expect(() => pipe.transform(date)).not.toThrow(); });
|
||||
it('should support int', () => { expect(() => pipe.transform(123456789)).not.toThrow(); });
|
||||
it('should support numeric strings',
|
||||
() => { expect(() => pipe.transform('123456789')).not.toThrow(); });
|
||||
|
||||
it('should support decimal strings',
|
||||
() => { expect(() => pipe.transform('123456789.11')).not.toThrow(); });
|
||||
it('should support decimal strings',
|
||||
() => { expect(() => pipe.transform('123456789.11')).not.toThrow(); });
|
||||
|
||||
it('should support ISO string',
|
||||
() => { expect(() => pipe.transform('2015-06-15T21:43:11Z')).not.toThrow(); });
|
||||
it('should support ISO string',
|
||||
() => { expect(() => pipe.transform('2015-06-15T21:43:11Z')).not.toThrow(); });
|
||||
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({})).toThrow();
|
||||
expect(() => pipe.transform('')).toThrow();
|
||||
});
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({})).toThrow();
|
||||
expect(() => pipe.transform('')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('transform', () => {
|
||||
it('should format each component correctly', () => {
|
||||
expect(pipe.transform(date, 'y')).toEqual('2015');
|
||||
expect(pipe.transform(date, 'yy')).toEqual('15');
|
||||
expect(pipe.transform(date, 'M')).toEqual('6');
|
||||
expect(pipe.transform(date, 'MM')).toEqual('06');
|
||||
expect(pipe.transform(date, 'MMM')).toEqual('Jun');
|
||||
expect(pipe.transform(date, 'MMMM')).toEqual('June');
|
||||
expect(pipe.transform(date, 'd')).toEqual('15');
|
||||
expect(pipe.transform(date, 'E')).toEqual('Mon');
|
||||
expect(pipe.transform(date, 'EEEE')).toEqual('Monday');
|
||||
describe('transform', () => {
|
||||
it('should format each component correctly', () => {
|
||||
expect(pipe.transform(date, 'y')).toEqual('2015');
|
||||
expect(pipe.transform(date, 'yy')).toEqual('15');
|
||||
expect(pipe.transform(date, 'M')).toEqual('6');
|
||||
expect(pipe.transform(date, 'MM')).toEqual('06');
|
||||
expect(pipe.transform(date, 'MMM')).toEqual('Jun');
|
||||
expect(pipe.transform(date, 'MMMM')).toEqual('June');
|
||||
expect(pipe.transform(date, 'd')).toEqual('15');
|
||||
expect(pipe.transform(date, 'E')).toEqual('Mon');
|
||||
expect(pipe.transform(date, 'EEEE')).toEqual('Monday');
|
||||
if (!browserDetection.isOldChrome) {
|
||||
expect(pipe.transform(date, 'h')).toEqual('9');
|
||||
expect(pipe.transform(date, 'hh')).toEqual('09');
|
||||
expect(pipe.transform(date, 'HH')).toEqual('09');
|
||||
expect(pipe.transform(date, 'j')).toEqual('9 AM');
|
||||
}
|
||||
// IE and Edge can't format a date to minutes and seconds without hours
|
||||
if (!browserDetection.isEdge && !browserDetection.isIE ||
|
||||
!browserDetection.supportsNativeIntlApi) {
|
||||
if (!browserDetection.isOldChrome) {
|
||||
expect(pipe.transform(date, 'HH')).toEqual('09');
|
||||
}
|
||||
expect(pipe.transform(date, 'm')).toEqual('3');
|
||||
expect(pipe.transform(date, 's')).toEqual('1');
|
||||
expect(pipe.transform(date, 'mm')).toEqual('03');
|
||||
expect(pipe.transform(date, 'ss')).toEqual('01');
|
||||
expect(pipe.transform(date, 'Z')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should format common multi component patterns', () => {
|
||||
expect(pipe.transform(date, 'E, M/d/y')).toEqual('Mon, 6/15/2015');
|
||||
expect(pipe.transform(date, 'E, M/d')).toEqual('Mon, 6/15');
|
||||
expect(pipe.transform(date, 'MMM d')).toEqual('Jun 15');
|
||||
expect(pipe.transform(date, 'dd/MM/yyyy')).toEqual('15/06/2015');
|
||||
expect(pipe.transform(date, 'MM/dd/yyyy')).toEqual('06/15/2015');
|
||||
expect(pipe.transform(date, 'yMEd')).toEqual('20156Mon15');
|
||||
expect(pipe.transform(date, 'MEd')).toEqual('6Mon15');
|
||||
expect(pipe.transform(date, 'MMMd')).toEqual('Jun15');
|
||||
expect(pipe.transform(date, 'yMMMMEEEEd')).toEqual('Monday, June 15, 2015');
|
||||
}
|
||||
expect(pipe.transform(date, 'Z')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should format common multi component patterns', () => {
|
||||
expect(pipe.transform(date, 'E, M/d/y')).toEqual('Mon, 6/15/2015');
|
||||
expect(pipe.transform(date, 'E, M/d')).toEqual('Mon, 6/15');
|
||||
expect(pipe.transform(date, 'MMM d')).toEqual('Jun 15');
|
||||
expect(pipe.transform(date, 'dd/MM/yyyy')).toEqual('15/06/2015');
|
||||
expect(pipe.transform(date, 'MM/dd/yyyy')).toEqual('06/15/2015');
|
||||
expect(pipe.transform(date, 'yMEd')).toEqual('20156Mon15');
|
||||
expect(pipe.transform(date, 'MEd')).toEqual('6Mon15');
|
||||
expect(pipe.transform(date, 'MMMd')).toEqual('Jun15');
|
||||
expect(pipe.transform(date, 'yMMMMEEEEd')).toEqual('Monday, June 15, 2015');
|
||||
// IE and Edge can't format a date to minutes and seconds without hours
|
||||
if (!browserDetection.isEdge && !browserDetection.isIE ||
|
||||
!browserDetection.supportsNativeIntlApi) {
|
||||
expect(pipe.transform(date, 'ms')).toEqual('31');
|
||||
}
|
||||
if (!browserDetection.isOldChrome) {
|
||||
expect(pipe.transform(date, 'jm')).toEqual('9:03 AM');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should format with pattern aliases', () => {
|
||||
expect(pipe.transform(date, 'medium')).toEqual('Jun 15, 2015, 9:03:01 AM');
|
||||
expect(pipe.transform(date, 'short')).toEqual('6/15/2015, 9:03 AM');
|
||||
expect(pipe.transform(date, 'dd/MM/yyyy')).toEqual('15/06/2015');
|
||||
expect(pipe.transform(date, 'MM/dd/yyyy')).toEqual('06/15/2015');
|
||||
expect(pipe.transform(date, 'fullDate')).toEqual('Monday, June 15, 2015');
|
||||
expect(pipe.transform(date, 'longDate')).toEqual('June 15, 2015');
|
||||
expect(pipe.transform(date, 'mediumDate')).toEqual('Jun 15, 2015');
|
||||
expect(pipe.transform(date, 'shortDate')).toEqual('6/15/2015');
|
||||
it('should format with pattern aliases', () => {
|
||||
if (!browserDetection.isOldChrome) {
|
||||
// IE and Edge do not add a coma after the year in these 2 cases
|
||||
if ((browserDetection.isEdge || browserDetection.isIE) &&
|
||||
browserDetection.supportsNativeIntlApi) {
|
||||
expect(pipe.transform(date, 'medium')).toEqual('Jun 15, 2015 9:03:01 AM');
|
||||
expect(pipe.transform(date, 'short')).toEqual('6/15/2015 9:03 AM');
|
||||
} else {
|
||||
expect(pipe.transform(date, 'medium')).toEqual('Jun 15, 2015, 9:03:01 AM');
|
||||
expect(pipe.transform(date, 'short')).toEqual('6/15/2015, 9:03 AM');
|
||||
}
|
||||
}
|
||||
expect(pipe.transform(date, 'MM/dd/yyyy')).toEqual('06/15/2015');
|
||||
expect(pipe.transform(date, 'fullDate')).toEqual('Monday, June 15, 2015');
|
||||
expect(pipe.transform(date, 'longDate')).toEqual('June 15, 2015');
|
||||
expect(pipe.transform(date, 'mediumDate')).toEqual('Jun 15, 2015');
|
||||
expect(pipe.transform(date, 'shortDate')).toEqual('6/15/2015');
|
||||
if (!browserDetection.isOldChrome) {
|
||||
expect(pipe.transform(date, 'mediumTime')).toEqual('9:03:01 AM');
|
||||
expect(pipe.transform(date, 'shortTime')).toEqual('9:03 AM');
|
||||
});
|
||||
|
||||
it('should remove bidi control characters',
|
||||
() => { expect(pipe.transform(date, 'MM/dd/yyyy').length).toEqual(10); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it('should remove bidi control characters',
|
||||
() => { expect(pipe.transform(date, 'MM/dd/yyyy').length).toEqual(10); });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,73 +12,78 @@ import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
|||
|
||||
export function main() {
|
||||
describe('Number pipes', () => {
|
||||
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||
// https://github.com/angular/angular/issues/3333
|
||||
// Have to restrict to Chrome as IE uses a different formatting
|
||||
if (browserDetection.supportsIntlApi && browserDetection.isChromeDesktop) {
|
||||
describe('DecimalPipe', () => {
|
||||
var pipe: DecimalPipe;
|
||||
describe('DecimalPipe', () => {
|
||||
var pipe: DecimalPipe;
|
||||
|
||||
beforeEach(() => { pipe = new DecimalPipe('en-US'); });
|
||||
beforeEach(() => { pipe = new DecimalPipe('en-US'); });
|
||||
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(12345)).toEqual('12,345');
|
||||
expect(pipe.transform(123, '.2')).toEqual('123.00');
|
||||
expect(pipe.transform(1, '3.')).toEqual('001');
|
||||
expect(pipe.transform(1.1, '3.4-5')).toEqual('001.1000');
|
||||
expect(pipe.transform(1.123456, '3.4-5')).toEqual('001.12346');
|
||||
expect(pipe.transform(1.1234)).toEqual('1.123');
|
||||
});
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(12345)).toEqual('12,345');
|
||||
expect(pipe.transform(123, '.2')).toEqual('123.00');
|
||||
expect(pipe.transform(1, '3.')).toEqual('001');
|
||||
expect(pipe.transform(1.1, '3.4-5')).toEqual('001.1000');
|
||||
expect(pipe.transform(1.123456, '3.4-5')).toEqual('001.12346');
|
||||
expect(pipe.transform(1.1234)).toEqual('1.123');
|
||||
});
|
||||
|
||||
it('should support strings', () => {
|
||||
expect(pipe.transform('12345')).toEqual('12,345');
|
||||
expect(pipe.transform('123', '.2')).toEqual('123.00');
|
||||
expect(pipe.transform('1', '3.')).toEqual('001');
|
||||
expect(pipe.transform('1.1', '3.4-5')).toEqual('001.1000');
|
||||
expect(pipe.transform('1.123456', '3.4-5')).toEqual('001.12346');
|
||||
expect(pipe.transform('1.1234')).toEqual('1.123');
|
||||
});
|
||||
it('should support strings', () => {
|
||||
expect(pipe.transform('12345')).toEqual('12,345');
|
||||
expect(pipe.transform('123', '.2')).toEqual('123.00');
|
||||
expect(pipe.transform('1', '3.')).toEqual('001');
|
||||
expect(pipe.transform('1.1', '3.4-5')).toEqual('001.1000');
|
||||
expect(pipe.transform('1.123456', '3.4-5')).toEqual('001.12346');
|
||||
expect(pipe.transform('1.1234')).toEqual('1.123');
|
||||
});
|
||||
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform(new Object())).toThrowError();
|
||||
expect(() => pipe.transform('123abc')).toThrowError();
|
||||
});
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform(new Object())).toThrowError();
|
||||
expect(() => pipe.transform('123abc')).toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('PercentPipe', () => {
|
||||
var pipe: PercentPipe;
|
||||
describe('PercentPipe', () => {
|
||||
var pipe: PercentPipe;
|
||||
|
||||
beforeEach(() => { pipe = new PercentPipe('en-US'); });
|
||||
beforeEach(() => { pipe = new PercentPipe('en-US'); });
|
||||
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(1.23)).toEqual('123%');
|
||||
expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(new Object())).toThrowError(); });
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(normalize(pipe.transform(1.23))).toEqual('123%');
|
||||
expect(normalize(pipe.transform(1.2, '.2'))).toEqual('120.00%');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(new Object())).toThrowError(); });
|
||||
});
|
||||
});
|
||||
|
||||
describe('CurrencyPipe', () => {
|
||||
var pipe: CurrencyPipe;
|
||||
describe('CurrencyPipe', () => {
|
||||
var pipe: CurrencyPipe;
|
||||
|
||||
beforeEach(() => { pipe = new CurrencyPipe('en-US'); });
|
||||
beforeEach(() => { pipe = new CurrencyPipe('en-US'); });
|
||||
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(123)).toEqual('USD123.00');
|
||||
expect(pipe.transform(12, 'EUR', false, '.1')).toEqual('EUR12.0');
|
||||
expect(pipe.transform(5.1234, 'USD', false, '.0-3')).toEqual('USD5.123');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(new Object())).toThrowError(); });
|
||||
describe('transform', () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
// In old Chrome, default formatiing for USD is different
|
||||
if (browserDetection.isOldChrome) {
|
||||
expect(normalize(pipe.transform(123))).toEqual('USD123');
|
||||
} else {
|
||||
expect(normalize(pipe.transform(123))).toEqual('USD123.00');
|
||||
}
|
||||
expect(normalize(pipe.transform(12, 'EUR', false, '.1'))).toEqual('EUR12.0');
|
||||
expect(normalize(pipe.transform(5.1234, 'USD', false, '.0-3'))).toEqual('USD5.123');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(new Object())).toThrowError(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Between the symbol and the number, Edge adds a no breaking space and IE11 adds a standard space
|
||||
function normalize(s: string): string {
|
||||
return s.replace(/\u00A0| /g, '');
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: true
|
||||
isChromeDesktop: true,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Chrome mobile',
|
||||
|
@ -35,7 +36,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Firefox',
|
||||
|
@ -47,7 +49,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'IE9',
|
||||
|
@ -59,7 +62,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'IE10',
|
||||
|
@ -71,7 +75,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'IE11',
|
||||
|
@ -83,7 +88,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'IEMobile',
|
||||
|
@ -95,7 +101,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Edge',
|
||||
|
@ -107,7 +114,8 @@ export function main() {
|
|||
isWebkit: false,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Android4.1',
|
||||
|
@ -119,7 +127,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Android4.2',
|
||||
|
@ -131,7 +140,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Android4.3',
|
||||
|
@ -143,7 +153,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Android4.4',
|
||||
|
@ -155,7 +166,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: true
|
||||
},
|
||||
{
|
||||
name: 'Safari7',
|
||||
|
@ -167,7 +179,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'Safari8',
|
||||
|
@ -179,7 +192,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'iOS7',
|
||||
|
@ -191,7 +205,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: true,
|
||||
isSlow: true,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
},
|
||||
{
|
||||
name: 'iOS8',
|
||||
|
@ -203,7 +218,8 @@ export function main() {
|
|||
isWebkit: true,
|
||||
isIOS7: false,
|
||||
isSlow: false,
|
||||
isChromeDesktop: false
|
||||
isChromeDesktop: false,
|
||||
isOldChrome: false
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -218,6 +234,7 @@ export function main() {
|
|||
expect(bd.isIOS7).toBe(StringMapWrapper.get(browser, 'isIOS7'));
|
||||
expect(bd.isSlow).toBe(StringMapWrapper.get(browser, 'isSlow'));
|
||||
expect(bd.isChromeDesktop).toBe(StringMapWrapper.get(browser, 'isChromeDesktop'));
|
||||
expect(bd.isOldChrome).toBe(StringMapWrapper.get(browser, 'isOldChrome'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue