Skip to content

Commit

Permalink
Carve out flex slot expansion if the returned creative has a size tha…
Browse files Browse the repository at this point in the history
…t matches one that was requested.
  • Loading branch information
glevitzky committed Sep 19, 2019
1 parent f0119a5 commit 7a50dae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Expand Up @@ -1250,7 +1250,12 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
(returnedSizeDifferent && heightNotIncreased)
) {
this.attemptChangeSize(newHeight, newWidth).catch(() => {});
if (newWidth > width) {
if (
newWidth > width &&
// Nothing to adjust if the returned size was one that was requested.
this.parameterSize &&
this.parameterSize.indexOf(`${newWidth}x${newHeight}`) == -1
) {
this.adjustSlotPostExpansion_(newWidth);
}
}
Expand Down
Expand Up @@ -355,8 +355,18 @@ describes.realWin('amp-ad-network-doubleclick-impl', realWinConfig, env => {
newWidth: 400,
margin: '-375px',
},
{
direction: 'ltr',
parentWidth: 300,
newWidth: 200,
margin: '',
isMultiSizeResponse: true,
},
].forEach((testCase, testNum) => {
it(`should adjust slot CSS after expanding width #${testNum}`, () => {
impl.parameterSize = testCase.isMultiSizeResponse
? '320x50,200x50'
: '200x50';
sandbox.stub(impl, 'attemptChangeSize').callsFake((height, width) => {
impl.element.style.width = `${width}px`;
return {
Expand Down Expand Up @@ -390,8 +400,10 @@ describes.realWin('amp-ad-network-doubleclick-impl', realWinConfig, env => {
},
});
expect(impl.element.style[`margin${dirStr}`]).to.equal(testCase.margin);
// We use a fixed '11' value for z-index.
expect(impl.element.style.zIndex).to.equal('11');
if (!testCase.isMultiSizeResponse) {
// We use a fixed '30' value for z-index.
expect(impl.element.style.zIndex).to.equal('11');
}
});
});
});
Expand Down

0 comments on commit 7a50dae

Please sign in to comment.