Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/nativeAssetManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export function newNativeAssetManager(win, nativeTag, mkMessenger = prebidMessen
stopListening();
const resize = () => requestHeightResize(
bid.adId,
(document.body.clientHeight || document.body.offsetHeight),
(document.body.clientHeight || document.body.offsetHeight || document.documentElement.scrollHeight),
document.body.clientWidth > 1 ? document.body.clientWidth : undefined
);
document.readyState === 'complete' ? resize() : window.onload = resize;
Expand Down
20 changes: 16 additions & 4 deletions test/spec/nativeAssetManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,26 @@ describe('nativeAssetManager', () => {
expect(win.document.body.innerHTML).to.include(`<a href="http://www.example.com" target="_blank" class="pb-click">new value</a>`);
});

function getResizeRequest() {
return win.parent.postMessage.args
.map(([msg]) => JSON.parse(msg))
.find((msg) => msg.action === 'resizeNativeHeight')
}

it('should not request width resize if width is 1', () => {
sandbox.stub(document.body, 'clientWidth').get(() => 1);
const nativeAssetManager = makeManager();
nativeAssetManager.loadAssets(AD_ID);
const resizeRequest = win.parent.postMessage.args
.map(([msg]) => JSON.parse(msg))
.find((msg) => msg.action === 'resizeNativeHeight')
expect(resizeRequest.width).to.not.exist;
expect(getResizeRequest().width).to.not.exist;
});

it('should use scrollHeight if offsetHeight & clientHeight are 0', () => {
sandbox.stub(document.body, 'clientHeight').get(() => 0);
sandbox.stub(document.body, 'offsetHeight').get(() => 0);
sandbox.stub(document.documentElement, 'scrollHeight').get(() => 123);
const nativeAssetManager = makeManager();
nativeAssetManager.loadAssets(AD_ID);
expect(getResizeRequest().height).to.eql(123);
})

it('should set the iframe to the width of the container', () => {
Expand Down