Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(browsers): fix failing tests in IE11 #3388

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/angular2/src/dom/browser_adapter.ts
Expand Up @@ -118,7 +118,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
firstChild(el): Node { return el.firstChild; }
nextSibling(el): Node { return el.nextSibling; }
parentElement(el): Node { return el.parentElement; }
parentElement(el): Node { return el.parentNode; }
childNodes(el): List<Node> { return el.childNodes; }
childNodesAsList(el): List<any> {
var childNodes = el.childNodes;
Expand All @@ -130,14 +130,14 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
clearNodes(el) {
while (el.firstChild) {
el.firstChild.remove();
el.removeChild(el.firstChild);
}
}
appendChild(el, node) { el.appendChild(node); }
removeChild(el, node) { el.removeChild(node); }
replaceChild(el: Node, newChild, oldChild) { el.replaceChild(newChild, oldChild); }
remove(node): Node {
node.remove();
node.parentNode.removeChild(node);
return node;
}
insertBefore(el, node) { el.parentNode.insertBefore(node, el); }
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/test_lib/utils.ts
Expand Up @@ -35,7 +35,7 @@ export function containsRegexp(input: string): RegExp {
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]}"]`);
Expand Down
36 changes: 18 additions & 18 deletions modules/angular2/test/core/zone/ng_zone_spec.ts
Expand Up @@ -182,7 +182,7 @@ function commonTests() {
macroTask(() => {
expect(_log.result()).toEqual('run; onTurnDone 1; onTurnDone 2; onEventDone');
async.done();
});
}, 80);
}));

it('should not allow onEventDone to cause further digests',
Expand All @@ -206,7 +206,7 @@ function commonTests() {
macroTask(() => {
expect(_log.result()).toEqual('run; onTurnDone; onEventDone');
async.done();
});
}, 80);
}));

it('should run async tasks scheduled inside onEventDone outside Angular zone',
Expand Down Expand Up @@ -247,7 +247,7 @@ function commonTests() {
// The microtask (async) is executed after the macrotask (run)
expect(_log.result()).toEqual('onTurnStart; run start; run end; async; onTurnDone');
async.done();
}, 50);
}, 80);
}));

it('should not run onTurnStart and onTurnDone for nested Zone.run',
Expand All @@ -268,7 +268,7 @@ function commonTests() {
.toEqual(
'onTurnStart; start run; nested run; end run; nested run microtask; onTurnDone');
async.done();
}, 50);
}, 80);
}));

it('should not run onTurnStart and onTurnDone for nested Zone.run invoked from onTurnDone',
Expand All @@ -286,7 +286,7 @@ function commonTests() {
expect(_log.result())
.toEqual('start run; onTurnDone:started; nested run; onTurnDone:finished');
async.done();
}, 50);
}, 80);
}));

it('should call onTurnStart and onTurnDone before and after each top-level run',
Expand Down Expand Up @@ -330,7 +330,7 @@ function commonTests() {
.toEqual(
'onTurnStart; run start; onTurnDone; onTurnStart; a then; b then; onTurnDone');
async.done();
}, 50);
}, 80);
}));

it('should run a function outside of the angular zone',
Expand Down Expand Up @@ -370,7 +370,7 @@ function commonTests() {
// Third VM Turn => execute the microtask (inside angular)
'onTurnStart; executedMicrotask; onTurnDone');
async.done();
}, 50);
}, 80);
}));

it('should call onTurnStart before executing a microtask scheduled in onTurnDone as well as ' +
Expand Down Expand Up @@ -400,7 +400,7 @@ function commonTests() {
// Second VM Turn => microtask enqueued from onTurnDone
'onTurnStart; executedMicrotask; onTurnDone(begin); onTurnDone(end)');
async.done();
}, 50);
}, 80);
}));

it('should call onTurnStart and onTurnDone for a scheduleMicrotask in onTurnDone triggered by ' +
Expand Down Expand Up @@ -435,7 +435,7 @@ function commonTests() {
// Second VM Turn => the microtask enqueued from onTurnDone
'onTurnStart; onTurnDone(executeMicrotask); onTurnDone(begin); onTurnDone(end)');
async.done();
}, 50);
}, 80);
}));

it('should execute promises scheduled in onTurnStart before promises scheduled in run',
Expand Down Expand Up @@ -490,7 +490,7 @@ function commonTests() {
// Second VM turn: execute the microtask from onTurnEnd
'onTurnStart(begin); onTurnStart(end); onTurnDone(executePromise); onTurnDone(begin); onTurnDone(end)');
async.done();
}, 50);
}, 80);
}));

it('should call onTurnStart and onTurnDone before and after each turn, respectively',
Expand All @@ -508,10 +508,10 @@ function commonTests() {
});
});

macroTask(() => { _zone.run(() => { completerA.resolve(null); }); }, 10);
macroTask(() => { _zone.run(() => { completerA.resolve(null); }); }, 20);


macroTask(() => { _zone.run(() => { completerB.resolve(null); }); }, 30);
macroTask(() => { _zone.run(() => { completerB.resolve(null); }); }, 40);

macroTask(() => {
expect(_log.result())
Expand All @@ -523,7 +523,7 @@ function commonTests() {
// Third VM turn
'onTurnStart; b then; onTurnDone');
async.done();
}, 60);
}, 80);
}));

it('should call onTurnStart and onTurnDone before and after (respectively) all turns in a chain',
Expand All @@ -543,7 +543,7 @@ function commonTests() {
expect(_log.result())
.toEqual('onTurnStart; run start; run end; async1; async2; onTurnDone');
async.done();
}, 50);
}, 80);
}));

it('should call onTurnStart and onTurnDone for promises created outside of run body',
Expand All @@ -565,7 +565,7 @@ function commonTests() {
expect(_log.result())
.toEqual('onTurnStart; zone run; onTurnDone; onTurnStart; promise then; onTurnDone');
async.done();
}, 50);
}, 80);
}));
});

Expand Down Expand Up @@ -596,7 +596,7 @@ function commonTests() {
expect(_errors.length).toBe(1);
expect(_errors[0]).toEqual(exception);
async.done();
}, 50);
}, 80);
}));

it('should call onError when onTurnDone throws and the zone is sync',
Expand All @@ -612,7 +612,7 @@ function commonTests() {
expect(_errors.length).toBe(1);
expect(_errors[0]).toEqual(exception);
async.done();
}, 50);
}, 80);
}));

it('should call onError when onTurnDone throws and the zone is async',
Expand All @@ -631,7 +631,7 @@ function commonTests() {
expect(_errors.length).toBe(1);
expect(_errors[0]).toEqual(exception);
async.done();
}, 50);
}, 80);
}));
});
}
48 changes: 24 additions & 24 deletions modules/angular2/test/directives/ng_style_spec.ts
Expand Up @@ -26,14 +26,14 @@ export function main() {

it('should add styles specified in an object literal',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var template = `<div [ng-style]="{'text-align': 'right'}"></div>`;
var template = `<div [ng-style]="{'max-width': '40px'}"></div>`;

tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('right');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('40px');

async.done();
});
Expand All @@ -48,16 +48,16 @@ export function main() {
.then((rootTC) => {
var expr: Map<string, any>;

rootTC.componentInstance.expr = {'text-align': 'right'};
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('right');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('40px');

expr = rootTC.componentInstance.expr;
expr['text-align'] = 'left';
expr['max-width'] = '30%';
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('left');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('30%');

async.done();
});
Expand All @@ -70,14 +70,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'text-align': 'right'};
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('right');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('40px');

StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('');

async.done();
Expand All @@ -91,16 +91,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'text-align': 'right'};
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('right');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
.toEqual('12px');

StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
.toEqual('12px');
Expand All @@ -116,19 +116,19 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'text-align': 'right'};
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
.toEqual('right');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
.toEqual('12px');

StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
.toEqual('12px');

rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
.toEqual('');

async.done();
Expand Down
6 changes: 6 additions & 0 deletions modules/angular2/test/forms/integration_spec.ts
Expand Up @@ -736,6 +736,11 @@ export function main() {
rootTC.componentInstance.form = form;
rootTC.detectChanges();

// In IE, the element needs to be appended to the real DOM,
// otherwise setting .selectionStart fails with "unspecified error"
var isIE = DOM.getUserAgent().indexOf("Trident") > -1;
if (isIE) DOM.appendChild(DOM.defaultDoc().body, rootTC.nativeElement);

var input = rootTC.query(By.css("input")).nativeElement;
input.value = "aa";
input.selectionStart = 1;
Expand All @@ -746,6 +751,7 @@ export function main() {

// selection start has not changed because we did not reset the value
expect(input.selectionStart).toEqual(1);
if (isIE) DOM.removeChild(DOM.defaultDoc().body, rootTC.nativeElement);
})));
});
});
Expand Down
8 changes: 4 additions & 4 deletions modules/angular2/test/render/dom/view/view_spec.ts
Expand Up @@ -129,10 +129,10 @@ export function main() {
});

it('should de-normalize style names', () => {
view.setElementStyle(0, 'textAlign', 'right');
expect(DOM.getStyle(el, 'text-align')).toEqual('right');
view.setElementStyle(0, 'textAlign', null);
expect(DOM.getStyle(el, 'text-align')).toEqual('');
view.setElementStyle(0, 'maxWidth', '40px');
expect(DOM.getStyle(el, 'max-width')).toEqual('40px');
view.setElementStyle(0, 'maxWidth', null);
expect(DOM.getStyle(el, 'max-width')).toEqual('');
});

});
Expand Down