testing.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * @license Angular v8.1.3
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { NgZone, ɵglobal, createPlatformFactory, platformCore, NgModule, APP_ID, PLATFORM_INITIALIZER } from '@angular/core';
  7. import { ɵgetDOM, BrowserModule, ɵELEMENT_PROBE_PROVIDERS, ɵBrowserDomAdapter } from '@angular/platform-browser';
  8. /**
  9. * @fileoverview added by tsickle
  10. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  11. */
  12. class BrowserDetection {
  13. /**
  14. * @private
  15. * @return {?}
  16. */
  17. get _ua() {
  18. if (typeof this._overrideUa === 'string') {
  19. return this._overrideUa;
  20. }
  21. return ɵgetDOM() ? ɵgetDOM().getUserAgent() : '';
  22. }
  23. /**
  24. * @return {?}
  25. */
  26. static setup() { }
  27. /**
  28. * @param {?} ua
  29. */
  30. constructor(ua) { this._overrideUa = ua; }
  31. /**
  32. * @return {?}
  33. */
  34. get isFirefox() { return this._ua.indexOf('Firefox') > -1; }
  35. /**
  36. * @return {?}
  37. */
  38. get isAndroid() {
  39. return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
  40. this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
  41. this._ua.indexOf('IEMobile') == -1;
  42. }
  43. /**
  44. * @return {?}
  45. */
  46. get isEdge() { return this._ua.indexOf('Edge') > -1; }
  47. /**
  48. * @return {?}
  49. */
  50. get isIE() { return this._ua.indexOf('Trident') > -1; }
  51. /**
  52. * @return {?}
  53. */
  54. get isWebkit() {
  55. return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
  56. this._ua.indexOf('IEMobile') == -1;
  57. }
  58. /**
  59. * @return {?}
  60. */
  61. get isIOS7() {
  62. return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
  63. this._ua.indexOf('IEMobile') == -1;
  64. }
  65. /**
  66. * @return {?}
  67. */
  68. get isSlow() { return this.isAndroid || this.isIE || this.isIOS7; }
  69. // The Intl API is only natively supported in Chrome, Firefox, IE11 and Edge.
  70. // This detector is needed in tests to make the difference between:
  71. // 1) IE11/Edge: they have a native Intl API, but with some discrepancies
  72. // 2) IE9/IE10: they use the polyfill, and so no discrepancies
  73. /**
  74. * @return {?}
  75. */
  76. get supportsNativeIntlApi() {
  77. return !!((/** @type {?} */ (ɵglobal))).Intl && ((/** @type {?} */ (ɵglobal))).Intl !== ((/** @type {?} */ (ɵglobal))).IntlPolyfill;
  78. }
  79. /**
  80. * @return {?}
  81. */
  82. get isChromeDesktop() {
  83. return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
  84. this._ua.indexOf('Edge') == -1;
  85. }
  86. // "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
  87. // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
  88. /**
  89. * @return {?}
  90. */
  91. get isOldChrome() {
  92. return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
  93. this._ua.indexOf('Edge') == -1;
  94. }
  95. /**
  96. * @return {?}
  97. */
  98. get supportsCustomElements() { return (typeof ((/** @type {?} */ (ɵglobal))).customElements !== 'undefined'); }
  99. /**
  100. * @return {?}
  101. */
  102. get supportsDeprecatedCustomCustomElementsV0() {
  103. return (typeof ((/** @type {?} */ (document))).registerElement !== 'undefined');
  104. }
  105. /**
  106. * @return {?}
  107. */
  108. get supportsRegExUnicodeFlag() { return RegExp.prototype.hasOwnProperty('unicode'); }
  109. /**
  110. * @return {?}
  111. */
  112. get supportsShadowDom() {
  113. /** @type {?} */
  114. const testEl = document.createElement('div');
  115. return (typeof testEl.attachShadow !== 'undefined');
  116. }
  117. /**
  118. * @return {?}
  119. */
  120. get supportsDeprecatedShadowDomV0() {
  121. /** @type {?} */
  122. const testEl = (/** @type {?} */ (document.createElement('div')));
  123. return (typeof testEl.createShadowRoot !== 'undefined');
  124. }
  125. }
  126. BrowserDetection.setup();
  127. /**
  128. * @return {?}
  129. */
  130. function createNgZone() {
  131. return new NgZone({ enableLongStackTrace: true });
  132. }
  133. /**
  134. * @fileoverview added by tsickle
  135. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  136. */
  137. /**
  138. * @return {?}
  139. */
  140. function initBrowserTests() {
  141. ɵBrowserDomAdapter.makeCurrent();
  142. BrowserDetection.setup();
  143. }
  144. /** @type {?} */
  145. const _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
  146. /**
  147. * Platform for testing
  148. *
  149. * \@publicApi
  150. * @type {?}
  151. */
  152. const platformBrowserTesting = createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
  153. const ɵ0 = createNgZone;
  154. /**
  155. * NgModule for testing.
  156. *
  157. * \@publicApi
  158. */
  159. class BrowserTestingModule {
  160. }
  161. BrowserTestingModule.decorators = [
  162. { type: NgModule, args: [{
  163. exports: [BrowserModule],
  164. providers: [
  165. { provide: APP_ID, useValue: 'a' },
  166. ɵELEMENT_PROBE_PROVIDERS,
  167. { provide: NgZone, useFactory: ɵ0 },
  168. ]
  169. },] }
  170. ];
  171. /**
  172. * @fileoverview added by tsickle
  173. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  174. */
  175. /**
  176. * @fileoverview added by tsickle
  177. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  178. */
  179. /**
  180. * @fileoverview added by tsickle
  181. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  182. */
  183. /**
  184. * Generated bundle index. Do not edit.
  185. */
  186. export { createNgZone as ɵangular_packages_platform_browser_testing_testing_a, platformBrowserTesting, BrowserTestingModule };
  187. //# sourceMappingURL=testing.js.map