UNPKG

9.21 kBJavaScriptView Raw
1/**
2 * @license Angular v8.2.14
3 * (c) 2010-2019 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { ɵglobal, NgZone, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, NgModule, APP_ID } from '@angular/core';
8import { ɵgetDOM, ɵBrowserDomAdapter, BrowserModule, ɵELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser';
9
10/**
11 * @fileoverview added by tsickle
12 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
13 */
14/** @type {?} */
15let browserDetection;
16class BrowserDetection {
17 /**
18 * @private
19 * @return {?}
20 */
21 get _ua() {
22 if (typeof this._overrideUa === 'string') {
23 return this._overrideUa;
24 }
25 return ɵgetDOM() ? ɵgetDOM().getUserAgent() : '';
26 }
27 /**
28 * @return {?}
29 */
30 static setup() { browserDetection = new BrowserDetection(null); }
31 /**
32 * @param {?} ua
33 */
34 constructor(ua) { this._overrideUa = ua; }
35 /**
36 * @return {?}
37 */
38 get isFirefox() { return this._ua.indexOf('Firefox') > -1; }
39 /**
40 * @return {?}
41 */
42 get isAndroid() {
43 return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
44 this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
45 this._ua.indexOf('IEMobile') == -1;
46 }
47 /**
48 * @return {?}
49 */
50 get isEdge() { return this._ua.indexOf('Edge') > -1; }
51 /**
52 * @return {?}
53 */
54 get isIE() { return this._ua.indexOf('Trident') > -1; }
55 /**
56 * @return {?}
57 */
58 get isWebkit() {
59 return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
60 this._ua.indexOf('IEMobile') == -1;
61 }
62 /**
63 * @return {?}
64 */
65 get isIOS7() {
66 return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
67 this._ua.indexOf('IEMobile') == -1;
68 }
69 /**
70 * @return {?}
71 */
72 get isSlow() { return this.isAndroid || this.isIE || this.isIOS7; }
73 // The Intl API is only natively supported in Chrome, Firefox, IE11 and Edge.
74 // This detector is needed in tests to make the difference between:
75 // 1) IE11/Edge: they have a native Intl API, but with some discrepancies
76 // 2) IE9/IE10: they use the polyfill, and so no discrepancies
77 /**
78 * @return {?}
79 */
80 get supportsNativeIntlApi() {
81 return !!((/** @type {?} */ (ɵglobal))).Intl && ((/** @type {?} */ (ɵglobal))).Intl !== ((/** @type {?} */ (ɵglobal))).IntlPolyfill;
82 }
83 /**
84 * @return {?}
85 */
86 get isChromeDesktop() {
87 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
88 this._ua.indexOf('Edge') == -1;
89 }
90 // "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
91 // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
92 /**
93 * @return {?}
94 */
95 get isOldChrome() {
96 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
97 this._ua.indexOf('Edge') == -1;
98 }
99 /**
100 * @return {?}
101 */
102 get supportsCustomElements() { return (typeof ((/** @type {?} */ (ɵglobal))).customElements !== 'undefined'); }
103 /**
104 * @return {?}
105 */
106 get supportsDeprecatedCustomCustomElementsV0() {
107 return (typeof ((/** @type {?} */ (document))).registerElement !== 'undefined');
108 }
109 /**
110 * @return {?}
111 */
112 get supportsRegExUnicodeFlag() { return RegExp.prototype.hasOwnProperty('unicode'); }
113 /**
114 * @return {?}
115 */
116 get supportsShadowDom() {
117 /** @type {?} */
118 const testEl = document.createElement('div');
119 return (typeof testEl.attachShadow !== 'undefined');
120 }
121 /**
122 * @return {?}
123 */
124 get supportsDeprecatedShadowDomV0() {
125 /** @type {?} */
126 const testEl = (/** @type {?} */ (document.createElement('div')));
127 return (typeof testEl.createShadowRoot !== 'undefined');
128 }
129}
130if (false) {
131 /**
132 * @type {?}
133 * @private
134 */
135 BrowserDetection.prototype._overrideUa;
136}
137BrowserDetection.setup();
138/**
139 * @param {?} element
140 * @param {?} eventType
141 * @return {?}
142 */
143function dispatchEvent(element, eventType) {
144 ɵgetDOM().dispatchEvent(element, ɵgetDOM().createEvent(eventType));
145}
146/**
147 * @param {?} html
148 * @return {?}
149 */
150function el(html) {
151 return (/** @type {?} */ (ɵgetDOM().firstChild(ɵgetDOM().content(ɵgetDOM().createTemplate(html)))));
152}
153/**
154 * @param {?} css
155 * @return {?}
156 */
157function normalizeCSS(css) {
158 return css.replace(/\s+/g, ' ')
159 .replace(/:\s/g, ':')
160 .replace(/'/g, '"')
161 .replace(/ }/g, '}')
162 .replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, (/**
163 * @param {...?} match
164 * @return {?}
165 */
166 (...match) => `url("${match[2]}")`))
167 .replace(/\[(.+)=([^"\]]+)\]/g, (/**
168 * @param {...?} match
169 * @return {?}
170 */
171 (...match) => `[${match[1]}="${match[2]}"]`));
172}
173/** @type {?} */
174const _selfClosingTags = ['br', 'hr', 'input'];
175/**
176 * @param {?} el
177 * @return {?}
178 */
179function stringifyElement(el /** TODO #9100 */) {
180 /** @type {?} */
181 let result = '';
182 if (ɵgetDOM().isElementNode(el)) {
183 /** @type {?} */
184 const tagName = ɵgetDOM().tagName(el).toLowerCase();
185 // Opening tag
186 result += `<${tagName}`;
187 // Attributes in an ordered way
188 /** @type {?} */
189 const attributeMap = ɵgetDOM().attributeMap(el);
190 /** @type {?} */
191 const sortedKeys = Array.from(attributeMap.keys()).sort();
192 for (const key of sortedKeys) {
193 /** @type {?} */
194 const lowerCaseKey = key.toLowerCase();
195 /** @type {?} */
196 let attValue = attributeMap.get(key);
197 if (typeof attValue !== 'string') {
198 result += ` ${lowerCaseKey}`;
199 }
200 else {
201 // Browsers order style rules differently. Order them alphabetically for consistency.
202 if (lowerCaseKey === 'style') {
203 attValue = attValue.split(/; ?/).filter((/**
204 * @param {?} s
205 * @return {?}
206 */
207 s => !!s)).sort().map((/**
208 * @param {?} s
209 * @return {?}
210 */
211 s => `${s};`)).join(' ');
212 }
213 result += ` ${lowerCaseKey}="${attValue}"`;
214 }
215 }
216 result += '>';
217 // Children
218 /** @type {?} */
219 const childrenRoot = ɵgetDOM().templateAwareRoot(el);
220 /** @type {?} */
221 const children = childrenRoot ? ɵgetDOM().childNodes(childrenRoot) : [];
222 for (let j = 0; j < children.length; j++) {
223 result += stringifyElement(children[j]);
224 }
225 // Closing tag
226 if (_selfClosingTags.indexOf(tagName) == -1) {
227 result += `</${tagName}>`;
228 }
229 }
230 else if (ɵgetDOM().isCommentNode(el)) {
231 result += `<!--${ɵgetDOM().nodeValue(el)}-->`;
232 }
233 else {
234 result += ɵgetDOM().getText(el);
235 }
236 return result;
237}
238/**
239 * @return {?}
240 */
241function createNgZone() {
242 return new NgZone({ enableLongStackTrace: true });
243}
244
245/**
246 * @fileoverview added by tsickle
247 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
248 */
249/**
250 * @return {?}
251 */
252function initBrowserTests() {
253 ɵBrowserDomAdapter.makeCurrent();
254 BrowserDetection.setup();
255}
256/** @type {?} */
257const _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
258/**
259 * Platform for testing
260 *
261 * \@publicApi
262 * @type {?}
263 */
264const platformBrowserTesting = createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
265const ɵ0 = createNgZone;
266/**
267 * NgModule for testing.
268 *
269 * \@publicApi
270 */
271class BrowserTestingModule {
272}
273BrowserTestingModule.decorators = [
274 { type: NgModule, args: [{
275 exports: [BrowserModule],
276 providers: [
277 { provide: APP_ID, useValue: 'a' },
278 ɵELEMENT_PROBE_PROVIDERS,
279 { provide: NgZone, useFactory: ɵ0 },
280 ]
281 },] }
282];
283
284/**
285 * @fileoverview added by tsickle
286 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
287 */
288
289/**
290 * @fileoverview added by tsickle
291 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
292 */
293
294/**
295 * @fileoverview added by tsickle
296 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
297 */
298
299/**
300 * Generated bundle index. Do not edit.
301 */
302
303export { createNgZone as ɵangular_packages_platform_browser_testing_testing_a, platformBrowserTesting, BrowserTestingModule };
304//# sourceMappingURL=testing.js.map