1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { __values, __decorate } from 'tslib';
|
8 | import { ɵglobal, NgZone, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, NgModule, APP_ID } from '@angular/core';
|
9 | import { ɵgetDOM, ɵBrowserDomAdapter, BrowserModule, ɵELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var browserDetection;
|
19 | var BrowserDetection = (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 |
|
81 |
|
82 |
|
83 |
|
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 |
|
100 |
|
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 | }());
|
143 | BrowserDetection.setup();
|
144 | function dispatchEvent(element, eventType) {
|
145 | ɵgetDOM().dispatchEvent(element, ɵgetDOM().createEvent(eventType));
|
146 | }
|
147 | function el(html) {
|
148 | return ɵgetDOM().firstChild(ɵgetDOM().content(ɵgetDOM().createTemplate(html)));
|
149 | }
|
150 | function 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 | }
|
170 | var _selfClosingTags = ['br', 'hr', 'input'];
|
171 | function 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 |
|
177 | result += "<" + tagName;
|
178 |
|
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 |
|
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 |
|
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 |
|
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 | }
|
225 | function createNgZone() {
|
226 | return new NgZone({ enableLongStackTrace: true });
|
227 | }
|
228 |
|
229 | function initBrowserTests() {
|
230 | ɵBrowserDomAdapter.makeCurrent();
|
231 | BrowserDetection.setup();
|
232 | }
|
233 | var _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | var platformBrowserTesting = createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
|
240 | var ɵ0 = createNgZone;
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | var BrowserTestingModule = (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 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | export { createNgZone as ɵangular_packages_platform_browser_testing_testing_a, platformBrowserTesting, BrowserTestingModule, ɵ0 };
|
291 |
|