1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import * as i0 from '@angular/core';
|
8 | import { ɵglobal, NgZone, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, APP_ID, NgModule } from '@angular/core';
|
9 | import { ɵBrowserDomAdapter, BrowserModule } from '@angular/platform-browser';
|
10 | import { ɵgetDOM } from '@angular/common';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | class BrowserDetection {
|
20 | constructor(ua) {
|
21 | this._overrideUa = ua;
|
22 | }
|
23 | get _ua() {
|
24 | if (typeof this._overrideUa === 'string') {
|
25 | return this._overrideUa;
|
26 | }
|
27 | return ɵgetDOM() ? ɵgetDOM().getUserAgent() : '';
|
28 | }
|
29 | static setup() {
|
30 | return new BrowserDetection(null);
|
31 | }
|
32 | get isFirefox() {
|
33 | return this._ua.indexOf('Firefox') > -1;
|
34 | }
|
35 | get isAndroid() {
|
36 | return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
|
37 | this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
|
38 | this._ua.indexOf('IEMobile') == -1;
|
39 | }
|
40 | get isEdge() {
|
41 | return this._ua.indexOf('Edge') > -1;
|
42 | }
|
43 | get isIE() {
|
44 | return this._ua.indexOf('Trident') > -1;
|
45 | }
|
46 | get isWebkit() {
|
47 | return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
|
48 | this._ua.indexOf('IEMobile') == -1;
|
49 | }
|
50 | get isIOS7() {
|
51 | return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
|
52 | this._ua.indexOf('IEMobile') == -1;
|
53 | }
|
54 | get isSlow() {
|
55 | return this.isAndroid || this.isIE || this.isIOS7;
|
56 | }
|
57 | get isChromeDesktop() {
|
58 | return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
|
59 | this._ua.indexOf('Edge') == -1;
|
60 | }
|
61 |
|
62 |
|
63 | get isOldChrome() {
|
64 | return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
|
65 | this._ua.indexOf('Edge') == -1;
|
66 | }
|
67 | get supportsCustomElements() {
|
68 | return (typeof ɵglobal.customElements !== 'undefined');
|
69 | }
|
70 | get supportsDeprecatedCustomCustomElementsV0() {
|
71 | return (typeof document.registerElement !== 'undefined');
|
72 | }
|
73 | get supportsRegExUnicodeFlag() {
|
74 | return RegExp.prototype.hasOwnProperty('unicode');
|
75 | }
|
76 | get supportsShadowDom() {
|
77 | const testEl = document.createElement('div');
|
78 | return (typeof testEl.attachShadow !== 'undefined');
|
79 | }
|
80 | get supportsDeprecatedShadowDomV0() {
|
81 | const testEl = document.createElement('div');
|
82 | return (typeof testEl.createShadowRoot !== 'undefined');
|
83 | }
|
84 | }
|
85 | const browserDetection = BrowserDetection.setup();
|
86 | function dispatchEvent(element, eventType) {
|
87 | const evt = ɵgetDOM().getDefaultDocument().createEvent('Event');
|
88 | evt.initEvent(eventType, true, true);
|
89 | ɵgetDOM().dispatchEvent(element, evt);
|
90 | }
|
91 | function createMouseEvent(eventType) {
|
92 | const evt = ɵgetDOM().getDefaultDocument().createEvent('MouseEvent');
|
93 | evt.initEvent(eventType, true, true);
|
94 | return evt;
|
95 | }
|
96 | function el(html) {
|
97 | return getContent(createTemplate(html)).firstChild;
|
98 | }
|
99 | function normalizeCSS(css) {
|
100 | return css.replace(/\s+/g, ' ')
|
101 | .replace(/:\s/g, ':')
|
102 | .replace(/'/g, '"')
|
103 | .replace(/ }/g, '}')
|
104 | .replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, (...match) => `url("${match[2]}")`)
|
105 | .replace(/\[(.+)=([^"\]]+)\]/g, (...match) => `[${match[1]}="${match[2]}"]`);
|
106 | }
|
107 | function getAttributeMap(element) {
|
108 | const res = new Map();
|
109 | const elAttrs = element.attributes;
|
110 | for (let i = 0; i < elAttrs.length; i++) {
|
111 | const attrib = elAttrs.item(i);
|
112 | res.set(attrib.name, attrib.value);
|
113 | }
|
114 | return res;
|
115 | }
|
116 | const _selfClosingTags = ['br', 'hr', 'input'];
|
117 | function stringifyElement(el /** TODO #9100 */) {
|
118 | let result = '';
|
119 | if (ɵgetDOM().isElementNode(el)) {
|
120 | const tagName = el.tagName.toLowerCase();
|
121 |
|
122 | result += `<${tagName}`;
|
123 |
|
124 | const attributeMap = getAttributeMap(el);
|
125 | const sortedKeys = Array.from(attributeMap.keys()).sort();
|
126 | for (const key of sortedKeys) {
|
127 | const lowerCaseKey = key.toLowerCase();
|
128 | let attValue = attributeMap.get(key);
|
129 | if (typeof attValue !== 'string') {
|
130 | result += ` ${lowerCaseKey}`;
|
131 | }
|
132 | else {
|
133 |
|
134 | if (lowerCaseKey === 'style') {
|
135 | attValue = attValue.split(/; ?/).filter(s => !!s).sort().map(s => `${s};`).join(' ');
|
136 | }
|
137 | result += ` ${lowerCaseKey}="${attValue}"`;
|
138 | }
|
139 | }
|
140 | result += '>';
|
141 |
|
142 | const childrenRoot = templateAwareRoot(el);
|
143 | const children = childrenRoot ? childrenRoot.childNodes : [];
|
144 | for (let j = 0; j < children.length; j++) {
|
145 | result += stringifyElement(children[j]);
|
146 | }
|
147 |
|
148 | if (_selfClosingTags.indexOf(tagName) == -1) {
|
149 | result += `</${tagName}>`;
|
150 | }
|
151 | }
|
152 | else if (isCommentNode(el)) {
|
153 | result += `<!--${el.nodeValue}-->`;
|
154 | }
|
155 | else {
|
156 | result += el.textContent;
|
157 | }
|
158 | return result;
|
159 | }
|
160 | function createNgZone() {
|
161 | return new NgZone({ enableLongStackTrace: true, shouldCoalesceEventChangeDetection: false });
|
162 | }
|
163 | function isCommentNode(node) {
|
164 | return node.nodeType === Node.COMMENT_NODE;
|
165 | }
|
166 | function isTextNode(node) {
|
167 | return node.nodeType === Node.TEXT_NODE;
|
168 | }
|
169 | function getContent(node) {
|
170 | if ('content' in node) {
|
171 | return node.content;
|
172 | }
|
173 | else {
|
174 | return node;
|
175 | }
|
176 | }
|
177 | function templateAwareRoot(el) {
|
178 | return ɵgetDOM().isElementNode(el) && el.nodeName === 'TEMPLATE' ? getContent(el) : el;
|
179 | }
|
180 | function setCookie(name, value) {
|
181 |
|
182 |
|
183 | document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
|
184 | }
|
185 | function supportsWebAnimation() {
|
186 | return typeof Element.prototype['animate'] === 'function';
|
187 | }
|
188 | function hasStyle(element, styleName, styleValue) {
|
189 | const value = element.style[styleName] || '';
|
190 | return styleValue ? value == styleValue : value.length > 0;
|
191 | }
|
192 | function hasClass(element, className) {
|
193 | return element.classList.contains(className);
|
194 | }
|
195 | function sortedClassList(element) {
|
196 | return Array.prototype.slice.call(element.classList, 0).sort();
|
197 | }
|
198 | function createTemplate(html) {
|
199 | const t = ɵgetDOM().getDefaultDocument().createElement('template');
|
200 | t.innerHTML = html;
|
201 | return t;
|
202 | }
|
203 | function childNodesAsList(el) {
|
204 | const childNodes = el.childNodes;
|
205 | const res = [];
|
206 | for (let i = 0; i < childNodes.length; i++) {
|
207 | res[i] = childNodes[i];
|
208 | }
|
209 | return res;
|
210 | }
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | function initBrowserTests() {
|
220 | ɵBrowserDomAdapter.makeCurrent();
|
221 | BrowserDetection.setup();
|
222 | }
|
223 | const _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | const platformBrowserTesting = createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 | class BrowserTestingModule {
|
236 | }
|
237 | BrowserTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
238 | BrowserTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, exports: [BrowserModule] });
|
239 | BrowserTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, providers: [
|
240 | { provide: APP_ID, useValue: 'a' },
|
241 | { provide: NgZone, useFactory: createNgZone },
|
242 | ], imports: [BrowserModule] });
|
243 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, decorators: [{
|
244 | type: NgModule,
|
245 | args: [{
|
246 | exports: [BrowserModule],
|
247 | providers: [
|
248 | { provide: APP_ID, useValue: 'a' },
|
249 | { provide: NgZone, useFactory: createNgZone },
|
250 | ]
|
251 | }]
|
252 | }] });
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | export { BrowserTestingModule, platformBrowserTesting };
|
283 |
|