Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test: fix ms edge failures #13686

Closed
wants to merge 6 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions test/helpers/privateMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ function browserSupportsCssAnimations() {
return true;
}

function createMockStyleSheet(doc, wind) {
function createMockStyleSheet(doc, prefix) {
doc = doc ? doc[0] : document;
wind = wind || window;

var node = doc.createElement('style');
var head = doc.getElementsByTagName('head')[0];
Expand All @@ -63,6 +62,18 @@ function createMockStyleSheet(doc, wind) {
}
},

addPossiblyPrefixedRule: function(selector, styles) {
if (prefix) {
var prefixedStyles = styles.split(/\s*;\s*/g).map(function(style) {
return !style ? '' : prefix + style;
}).join('; ');

this.addRule(selector, prefixedStyles);
}

this.addRule(selector, styles);
},

destroy: function() {
head.removeChild(node);
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/privateMocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('private mocks', function() {

var doc = $document[0];
var count = doc.styleSheets.length;
var stylesheet = createMockStyleSheet($document, $window);
var stylesheet = createMockStyleSheet($document);
var elm;
runs(function() {
expect(doc.styleSheets.length).toBe(count + 1);
Expand Down
27 changes: 16 additions & 11 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ describe('$compile', function() {


describe('svg namespace transcludes', function() {
var ua = window.navigator.userAgent;
var isEdge = /Edge/.test(ua);

// this method assumes some sort of sized SVG element is being inspected.
function assertIsValidSvgCircle(elem) {
expect(isUnknownElement(elem)).toBe(false);
Expand Down Expand Up @@ -300,17 +303,19 @@ describe('$compile', function() {
}));

// NOTE: This test may be redundant.
it('should handle custom svg containers that transclude to foreignObject' +
' that transclude to custom svg containers that transclude to custom elements', inject(function() {
element = jqLite('<div><svg-container>' +
'<my-foreign-object><svg-container><svg-circle></svg-circle></svg-container></my-foreign-object>' +
'</svg-container></div>');
$compile(element.contents())($rootScope);
document.body.appendChild(element[0]);

var circle = element.find('circle');
assertIsValidSvgCircle(circle[0]);
}));
if (!isEdge) {
it('should handle custom svg containers that transclude to foreignObject' +
' that transclude to custom svg containers that transclude to custom elements', inject(function() {
element = jqLite('<div><svg-container>' +
'<my-foreign-object><svg-container><svg-circle></svg-circle></svg-container></my-foreign-object>' +
'</svg-container></div>');
$compile(element.contents())($rootScope);
document.body.appendChild(element[0]);

var circle = element.find('circle');
assertIsValidSvgCircle(circle[0]);
}));
}
}

it('should handle directives with templates that manually add the transclude further down', inject(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ describe('input', function() {

it('should validate if max is empty', function() {
$rootScope.maxVal = undefined;
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
$rootScope.value = new Date(3000, 11, 31, 23, 59, 59);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an explanation would be nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't feel like an explanation was required in the actual code, so I put it on the commit message instead. The problem is, I don't really know why MS Edge doesn't like the original Data, nor could I reproduce it independently (outside of the tests), but I figured it is not worth investigating further.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably has something to do with how MS Edge handles UTC -> local datetime conversion while overflowing 9999. E.g. with my UTC+2 timezone, the UTC value 9999-12-31T21:59:59.999 (which corresponds to 9999-12-31T23:59:59.999 local time) is fine, but the UTC value 9999-12-31T22:00:00.000 (which corresponds to +10000-01-01T00:00:00.000 local time) "confuses" MS Edge.

It may also have something to do with ISO 8601 defaulting to min. 4 digits per year, but permitting the expansion of the year representation but only by prior agreement between the sender and the receiver (whatever that means).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worries me...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked a little more into this: MS Edge does not seem to support years > 9999 after all.
(Demo: it's not possible to set the year to > 9999 on Edge)

So, I think this test fix is fine (since 9999 doesn't have any significant value for the test - we just need a later date).

Yet, while investigating this, I realized that our internal implementation of date-family inputs, do not support years > 9999.
I will make an issue for that (unless it's so on purpose).

$rootScope.$digest();

expect($rootScope.form.alias.$error.max).toBeFalsy();
Expand Down
4 changes: 2 additions & 2 deletions test/ng/directive/ngRepeatSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1491,11 +1491,11 @@ describe('ngRepeat animations', function() {
}));

it('should not change the position of the block that is being animated away via a leave animation',
inject(function($compile, $rootScope, $animate, $document, $window, $sniffer, $timeout) {
inject(function($compile, $rootScope, $animate, $document, $sniffer, $timeout) {
if (!$sniffer.transitions) return;

var item;
var ss = createMockStyleSheet($document, $window);
var ss = createMockStyleSheet($document);

try {

Expand Down
4 changes: 3 additions & 1 deletion test/ng/snifferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ describe('$sniffer', function() {
inject(function($sniffer, $window) {
var expectedPrefix;
var ua = $window.navigator.userAgent.toLowerCase();
if (/chrome/i.test(ua) || /safari/i.test(ua) || /webkit/i.test(ua)) {
if (/edge/i.test(ua)) {
expectedPrefix = 'Ms';
} else if (/chrome/i.test(ua) || /safari/i.test(ua) || /webkit/i.test(ua)) {
expectedPrefix = 'Webkit';
} else if (/firefox/i.test(ua)) {
expectedPrefix = 'Moz';
Expand Down
4 changes: 2 additions & 2 deletions test/ngAnimate/animateCssDriverSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ describe("ngAnimate $$animateCssDriver", function() {

element = jqLite('<div></div>');

return function($$animateCssDriver, $document, $window) {
return function($$animateCssDriver, $document) {
driver = function(details, cb) {
return $$animateCssDriver(details, cb || noop);
};
ss = createMockStyleSheet($document, $window);
ss = createMockStyleSheet($document);
};
}));

Expand Down
Loading