Skip to content

Commit e3d0ed4

Browse files
committed
test($compile): work around Chrome (Windows) bug with reported size for <foreignObject>
Chrome 53-54+ on Windows (only) reports a 25% larger size for `<foreignObject>` elements and their descendants (although the size is actually correct on the page). For example, `<foreignObject style="width: 100px; height: 100px;">...</foreignObject>`, will be reported by `getBoundingClientRect()` as being `125px` x `125px`, although it will be `100px` x `100px` as expected. Fixes angular#15333
1 parent b77defd commit e3d0ed4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/ng/compileSpec.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,12 @@ describe('$compile', function() {
452452
var testElem = element.find('div');
453453
expect(isHTMLElement(testElem[0])).toBe(true);
454454
var bounds = testElem[0].getBoundingClientRect();
455-
expect(bounds.width === 20 && bounds.height === 20).toBe(true);
455+
456+
// Support: Chrome 53-54+ (Windows 10)
457+
// `<foreignObject>` and its children are reported by `getBoundingClientRect()`
458+
// as 25% larger in each dimension than they actually are.
459+
expect(bounds.width).toBeGreaterThanOrEqual(20);
460+
expect(bounds.height).toBeGreaterThanOrEqual(20);
456461
}));
457462

458463
it('should handle custom svg containers that transclude to foreignObject that transclude html', inject(function() {
@@ -465,7 +470,12 @@ describe('$compile', function() {
465470
var testElem = element.find('div');
466471
expect(isHTMLElement(testElem[0])).toBe(true);
467472
var bounds = testElem[0].getBoundingClientRect();
468-
expect(bounds.width === 20 && bounds.height === 20).toBe(true);
473+
474+
// Support: Chrome 53-54+ (Windows 10)
475+
// `<foreignObject>` and its children are reported by `getBoundingClientRect()`
476+
// as 25% larger in each dimension than they actually are.
477+
expect(bounds.width).toBeGreaterThanOrEqual(20);
478+
expect(bounds.height).toBeGreaterThanOrEqual(20);
469479
}));
470480

471481
// NOTE: This test may be redundant.

0 commit comments

Comments
 (0)