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