diff --git a/modules/angular2/src/dom/browser_adapter.ts b/modules/angular2/src/dom/browser_adapter.ts index d0548f1fe2..d3bcf59e31 100644 --- a/modules/angular2/src/dom/browser_adapter.ts +++ b/modules/angular2/src/dom/browser_adapter.ts @@ -229,8 +229,17 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { getTitle(): string { return document.title; } setTitle(newTitle: string) { document.title = newTitle || ''; } elementMatches(n, selector: string): boolean { - return n instanceof HTMLElement && n.matches ? n.matches(selector) : - n.msMatchesSelector(selector); + var matches = false; + if (n instanceof HTMLElement) { + if (n.matches) { + matches = n.matches(selector); + } else if (n.msMatchesSelector) { + matches = n.msMatchesSelector(selector); + } else if (n.webkitMatchesSelector) { + matches = n.webkitMatchesSelector(selector); + } + } + return matches; } isTemplateElement(el: any): boolean { return el instanceof HTMLElement && el.nodeName == "TEMPLATE"; diff --git a/modules/angular2/src/test_lib/utils.ts b/modules/angular2/src/test_lib/utils.ts index d7af221771..f300155c35 100644 --- a/modules/angular2/src/test_lib/utils.ts +++ b/modules/angular2/src/test_lib/utils.ts @@ -36,6 +36,7 @@ export function normalizeCSS(css: string): string { css = StringWrapper.replaceAll(css, /\s+/g, ' '); css = StringWrapper.replaceAll(css, /:\s/g, ':'); css = StringWrapper.replaceAll(css, /'/g, '"'); + css = StringWrapper.replaceAll(css, / }/g, '}'); css = StringWrapper.replaceAllMapped(css, /url\(\"(.+)\\"\)/g, (match) => `url(${match[1]})`); css = StringWrapper.replaceAllMapped(css, /\[(.+)=([^"\]]+)\]/g, (match) => `[${match[1]}="${match[2]}"]`); @@ -86,14 +87,25 @@ export function stringifyElement(el): string { return result; } -// The Intl API is only properly supported in Chrome and Opera. +// The Intl API is only properly supported in recent Chrome and Opera. // Note: Edge is disguised as Chrome 42, so checking the "Edge" part is needed, // see https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx export function supportsIntlApi(): boolean { - return DOM.getUserAgent().indexOf('Chrome') > -1 && DOM.getUserAgent().indexOf('Edge') == -1; + return DOM.getUserAgent().indexOf('Chrome/4') > -1 && DOM.getUserAgent().indexOf('Edge') == -1; } // TODO(mlaval): extract all browser detection checks from all tests export function isFirefox(): boolean { return DOM.getUserAgent().indexOf("Firefox") > -1; } +export function isAndroid(): boolean { + var ua = DOM.getUserAgent(); + return ua.indexOf('Mozilla/5.0') > -1 && ua.indexOf('Android ') > -1 && + ua.indexOf('AppleWebKit') > -1 && ua.indexOf('Chrome') == -1; +} +export function isEdge(): boolean { + return DOM.getUserAgent().indexOf('Edge') > -1; +} +export function isIE(): boolean { + return DOM.getUserAgent().indexOf('Trident') > -1; +} diff --git a/modules/angular2/test/core/zone/ng_zone_spec.ts b/modules/angular2/test/core/zone/ng_zone_spec.ts index 39f29fbf4f..4351c47f15 100644 --- a/modules/angular2/test/core/zone/ng_zone_spec.ts +++ b/modules/angular2/test/core/zone/ng_zone_spec.ts @@ -10,21 +10,22 @@ import { xdescribe, xit, Log, - isInInnerZone + isInInnerZone, + isAndroid, + isEdge, + isIE } from 'angular2/test_lib'; import {PromiseCompleter, PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async'; import {BaseException} from 'angular2/src/facade/lang'; -import {DOM} from 'angular2/src/dom/dom_adapter'; import {NgZone} from 'angular2/src/core/zone/ng_zone'; -var isIEorEdge = - DOM.getUserAgent().indexOf("Trident") > -1 || DOM.getUserAgent().indexOf("Edge") > -1; +var needsLongerTimers = isAndroid() || isEdge() || isIE(); // Schedules a macrotask (using a timer) function macroTask(fn: Function, timer = 1): void { // adds longer timers for passing tests in IE and Edge - _zone.runOutsideAngular(() => TimerWrapper.setTimeout(fn, isIEorEdge ? timer : 1)); + _zone.runOutsideAngular(() => TimerWrapper.setTimeout(fn, needsLongerTimers ? timer : 1)); } // Schedules a microtasks (using a resolved promise .then()) diff --git a/sauce.conf.js b/sauce.conf.js index 83b97f7707..7c607c57c5 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -125,7 +125,8 @@ var aliases = { 'SAFARI': ['SL_SAFARI7', 'SL_SAFARI8'], 'BETA': ['SL_CHROMEBETA', 'SL_FIREFOXBETA'], 'DEV': ['SL_CHROMEDEV', 'SL_FIREFOXDEV'], - 'CI': ['SL_CHROME', 'SL_ANDROID5.1', 'SL_SAFARI8', 'SL_IOS8', 'SL_FIREFOX', 'SL_IE11', 'SL_IE10', 'SL_IE9'] + 'CI': ['SL_CHROME', 'SL_ANDROID5.1', 'SL_SAFARI8', 'SL_IOS8', 'SL_FIREFOX', 'SL_IE11', 'SL_IE10', 'SL_IE9', + 'SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4'] }; module.exports = {