UNPKG

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