{"version":3,"file":"platform-browser-testing.umd.js","sources":["../../../../packages/platform-browser/testing/src/testing.ts","../../../../packages/platform-browser/testing/src/browser.ts","../../../../packages/platform-browser/testing/src/browser_util.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the platform-browser/testing package.\n */\nexport * from './browser';\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {APP_ID, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, Provider, createPlatformFactory, platformCore} from '@angular/core';\nimport {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter, ɵELEMENT_PROBE_PROVIDERS as ELEMENT_PROBE_PROVIDERS} from '@angular/platform-browser';\nimport {BrowserDetection, createNgZone} from './browser_util';\n\nfunction initBrowserTests() {\n BrowserDomAdapter.makeCurrent();\n BrowserDetection.setup();\n}\n\nconst _TEST_BROWSER_PLATFORM_PROVIDERS: Provider[] =\n [{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];\n\n/**\n * Platform for testing\n *\n * @stable\n */\nexport const platformBrowserTesting =\n createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);\n\n/**\n * NgModule for testing.\n *\n * @stable\n */\n\nexport class BrowserTestingModule {\nstatic decorators: DecoratorInvocation[] = [\n{ type: NgModule, args: [{\n exports: [BrowserModule],\n providers: [\n {provide: APP_ID, useValue: 'a'},\n ELEMENT_PROBE_PROVIDERS,\n {provide: NgZone, useFactory: createNgZone},\n ]\n}, ] },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {NgZone, ɵglobal as global} from '@angular/core';\nimport {ɵgetDOM as getDOM} from '@angular/platform-browser';\n\nexport let browserDetection: BrowserDetection;\n\nexport class BrowserDetection {\n private _overrideUa: string|null;\n private get _ua(): string {\n if (typeof this._overrideUa === 'string') {\n return this._overrideUa;\n }\n\n return getDOM() ? getDOM().getUserAgent() : '';\n }\n\n static setup() { browserDetection = new BrowserDetection(null); }\n\n constructor(ua: string|null) { this._overrideUa = ua; }\n\n get isFirefox(): boolean { return this._ua.indexOf('Firefox') > -1; }\n\n get isAndroid(): boolean {\n return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&\n this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&\n this._ua.indexOf('IEMobile') == -1;\n }\n\n get isEdge(): boolean { return this._ua.indexOf('Edge') > -1; }\n\n get isIE(): boolean { return this._ua.indexOf('Trident') > -1; }\n\n get isWebkit(): boolean {\n return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&\n this._ua.indexOf('IEMobile') == -1;\n }\n\n get isIOS7(): boolean {\n return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&\n this._ua.indexOf('IEMobile') == -1;\n }\n\n get isSlow(): boolean { return this.isAndroid || this.isIE || this.isIOS7; }\n\n // The Intl API is only natively supported in Chrome, Firefox, IE11 and Edge.\n // This detector is needed in tests to make the difference between:\n // 1) IE11/Edge: they have a native Intl API, but with some discrepancies\n // 2) IE9/IE10: they use the polyfill, and so no discrepancies\n get supportsNativeIntlApi(): boolean {\n return !!(global).Intl && (global).Intl !== (global).IntlPolyfill;\n }\n\n get isChromeDesktop(): boolean {\n return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&\n this._ua.indexOf('Edge') == -1;\n }\n\n // \"Old Chrome\" means Chrome 3X, where there are some discrepancies in the Intl API.\n // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).\n get isOldChrome(): boolean {\n return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&\n this._ua.indexOf('Edge') == -1;\n }\n}\n\nBrowserDetection.setup();\n\nexport function dispatchEvent(element: any, eventType: any): void {\n getDOM().dispatchEvent(element, getDOM().createEvent(eventType));\n}\n\nexport function el(html: string): HTMLElement {\n return getDOM().firstChild(getDOM().content(getDOM().createTemplate(html)));\n}\n\nexport function normalizeCSS(css: string): string {\n return css.replace(/\\s+/g, ' ')\n .replace(/:\\s/g, ':')\n .replace(/'/g, '\"')\n .replace(/ }/g, '}')\n .replace(/url\\((\\\"|\\s)(.+)(\\\"|\\s)\\)(\\s*)/g, (...match: string[]) => `url(\"${match[2]}\")`)\n .replace(/\\[(.+)=([^\"\\]]+)\\]/g, (...match: string[]) => `[${match[1]}=\"${match[2]}\"]`);\n}\n\nconst _singleTagWhitelist = ['br', 'hr', 'input'];\nexport function stringifyElement(el: any /** TODO #9100 */): string {\n let result = '';\n if (getDOM().isElementNode(el)) {\n const tagName = getDOM().tagName(el).toLowerCase();\n\n // Opening tag\n result += `<${tagName}`;\n\n // Attributes in an ordered way\n const attributeMap = getDOM().attributeMap(el);\n const keys: string[] = Array.from(attributeMap.keys()).sort();\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const attValue = attributeMap.get(key);\n if (typeof attValue !== 'string') {\n result += ` ${key}`;\n } else {\n result += ` ${key}=\"${attValue}\"`;\n }\n }\n result += '>';\n\n // Children\n const childrenRoot = getDOM().templateAwareRoot(el);\n const children = childrenRoot ? getDOM().childNodes(childrenRoot) : [];\n for (let j = 0; j < children.length; j++) {\n result += stringifyElement(children[j]);\n }\n\n // Closing tag\n if (_singleTagWhitelist.indexOf(tagName) == -1) {\n result += ``;\n }\n } else if (getDOM().isCommentNode(el)) {\n result += ``;\n } else {\n result += getDOM().getText(el);\n }\n\n return result;\n}\n\nexport function createNgZone(): NgZone {\n return new NgZone({enableLongStackTrace: true});\n}\n"],"names":["NgZone","APP_ID","BrowserModule","NgModule","ELEMENT_PROBE_PROVIDERS","ɵglobal","ɵgetDOM"],"mappings":";;;;;;;;;;;;;;;;;;AEkBA,IAAA,gBAAA,CAAA;AAEA,IAAA,gBAAA,IAAA,YAAA;IAYA,SAAA,gBAAA,CAAY,EAAZ,EAAA;QAAA,IAAA,CAAA,WAAA,GAAA,EAAA,CAAwC;KAAE;IAX1C,MAAA,CAAA,cAAA,CAAA,gBAAA,CAAA,SAAA,EAAA,KAAA,EAAA;QAAA,GAAA,EAAA,YAAA;YAEA,IAAA,OAAA,IAAA,CAAA,WAAA,KAAsC,QAAtC,EAAA;gBAEA,OAAA,IAAA,CAAA,WAAA,CAAA;aAEA;YAEM,OAANM,gCAAA,EAAA,GAAAA,gCAAA,EAAA,CAAA,YAAA,EAAA,GAAA,EAAA,CAAA;SACA;;;KAAA,CAAA,CAAA;IACA,gBAAA,CAAA,KAAY,GAAZ,YAAA,EAAiB,gBAAjB,GAAA,IAAA,gBAAwD,CAAC,IAAzD,CAAA,CAAA,EAAiE,CAAjE;IAEA,MAAA,CAAA,cAAA,CAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA;QAAA,GAAA,EAAA,YAAA,EAAA,OAAA,IAAA,CAAA,GAAA,CAAA,OAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,CAAA,EAAA;;;KAAA,CAAA,CAAA;IAEE,MAAF,CAAA,cAAA,CAAM,gBAAN,CAAA,SAAA,EAAA,WAAA,EAAA;QAAA,GAAA,EAAE,YAAF;YAEM,OAAN,IAAA,CAAA,GAAA,CAA+B,OAA/B,CAAuC,aAAvC,CAAA,GAAA,CAAyD,CAAC,IAAI,IAAI,CAAlE,GAAA,CAAA,OAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA;gBAEA,IAAc,CAAd,GAAA,C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