blob: 8440be758f59db53eb505868d2d894bcaf7ab412 [file] [log] [blame]
{"version":3,"file":"testing.js","sources":["../../../../../../packages/platform-browser/testing/src/browser_util.ts","../../../../../../packages/platform-browser/testing/src/browser.ts","../../../../../../packages/platform-browser/testing/src/testing.ts","../../../../../../packages/platform-browser/testing/public_api.ts","../../../../../../packages/platform-browser/testing/index.ts","../../../../../../packages/platform-browser/testing/testing.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\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 !!(<any>global).Intl && (<any>global).Intl !== (<any>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 get supportsCustomElements() { return (typeof(<any>global).customElements !== 'undefined'); }\n\n get supportsDeprecatedCustomCustomElementsV0() {\n return (typeof(document as any).registerElement !== 'undefined');\n }\n\n get supportsRegExUnicodeFlag(): boolean { return RegExp.prototype.hasOwnProperty('unicode'); }\n\n get supportsShadowDom() {\n const testEl = document.createElement('div');\n return (typeof testEl.attachShadow !== 'undefined');\n }\n\n get supportsDeprecatedShadowDomV0() {\n const testEl = document.createElement('div') as any;\n return (typeof testEl.createShadowRoot !== 'undefined');\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 <HTMLElement>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 _selfClosingTags = ['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 sortedKeys = Array.from(attributeMap.keys()).sort();\n for (const key of sortedKeys) {\n const lowerCaseKey = key.toLowerCase();\n let attValue = attributeMap.get(key);\n\n if (typeof attValue !== 'string') {\n result += ` ${lowerCaseKey}`;\n } else {\n // Browsers order style rules differently. Order them alphabetically for consistency.\n if (lowerCaseKey === 'style') {\n attValue = attValue.split(/; ?/).filter(s => !!s).sort().map(s => `${s};`).join(' ');\n }\n\n result += ` ${lowerCaseKey}=\"${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 (_selfClosingTags.indexOf(tagName) == -1) {\n result += `</${tagName}>`;\n }\n } else if (getDOM().isCommentNode(el)) {\n result += `<!--${getDOM().nodeValue(el)}-->`;\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","/**\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, StaticProvider, 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: StaticProvider[] =\n [{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];\n\n/**\n * Platform for testing\n *\n * @publicApi\n */\nexport const platformBrowserTesting =\n createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);\n\n/**\n * NgModule for testing.\n *\n * @publicApi\n */\n@NgModule({\n exports: [BrowserModule],\n providers: [\n {provide: APP_ID, useValue: 'a'},\n ELEMENT_PROBE_PROVIDERS,\n {provide: NgZone, useFactory: createNgZone},\n ]\n})\nexport class BrowserTestingModule {\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\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 */\n\n/// <reference types=\"jasmine\" />\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/testing';\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\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n\nexport {createNgZone as ɵangular_packages_platform_browser_testing_testing_a} from './src/browser_util';"],"names":["getDOM","global","BrowserDomAdapter","ELEMENT_PROBE_PROVIDERS"],"mappings":";;;;;;;;;;AAAA;;;;;;;AAaA;IAYE,0BAAY,EAAe;QAAI,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;KAAE;IAVvD,s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