testing.js 7.4 KB

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