Skip to content

Commit

Permalink
Hide overflow on successful resize (#30114)
Browse files Browse the repository at this point in the history
  • Loading branch information
caroqliu committed Sep 17, 2020
1 parent 77f880f commit 7fc4261
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extensions/amp-iframe/0.1/amp-iframe.js
Expand Up @@ -801,6 +801,11 @@ export class AmpIframe extends AMP.BaseElement {
if (newWidth !== undefined) {
this.element.setAttribute('width', newWidth);
}
this.element.overflowCallback(
/* overflown */ false,
newHeight,
newWidth
);
},
() => {}
);
Expand Down
17 changes: 17 additions & 0 deletions extensions/amp-iframe/0.1/test/test-amp-iframe.js
Expand Up @@ -693,6 +693,23 @@ describes.realWin(
expect(attemptChangeSize).to.be.calledWith(217, 114);
});

it('should hide overflow element after resize', async function () {
const ampIframe = createAmpIframe(env, {
src: iframeSrc,
sandbox: 'allow-scripts',
width: 100,
height: 100,
resizable: '',
});
await waitForAmpIframeLayoutPromise(doc, ampIframe);
const impl = await ampIframe.getImpl();
const overflowElement = impl.getOverflowElement();
overflowElement.classList.toggle('amp-visible', true);
impl.updateSize_(217, '114' /* be tolerant to string number */);
await timer.promise(IFRAME_MESSAGE_TIMEOUT);
expect(overflowElement.classList.contains('amp-visible')).to.be.false;
});

it('should resize amp-iframe when only height is provided', function* () {
const ampIframe = createAmpIframe(env, {
src: iframeSrc,
Expand Down

0 comments on commit 7fc4261

Please sign in to comment.