parent
d07b9181fe
commit
50eee42668
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue