Skip to content

Commit

Permalink
Core: fix broken native resizing (#12096)
Browse files Browse the repository at this point in the history
* Core: fix broken native resizing

* fix test
  • Loading branch information
dgirardi authored Aug 11, 2024
1 parent b74b366 commit 09e7484
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/secureCreatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function handleNativeRequest(reply, data, adObject) {
reply(getAllAssetsMessage(data, adObject));
break;
default:
handleNativeMessage(data, adObject, {resizeFn: getResizer(adObject)})
handleNativeMessage(data, adObject, {resizeFn: getResizer(data.adId, adObject)})
}
}

Expand Down
47 changes: 47 additions & 0 deletions test/spec/unit/secureCreatives_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,53 @@ describe('secureCreatives', () => {
stubEmit.withArgs(EVENTS.BID_WON, adResponse).calledOnce;
});
});

describe('resizing', () => {
let container, slot;
before(() => {
const [gtag, atag] = [window.googletag, window.apntag];
delete window.googletag;
delete window.apntag;
after(() => {
window.googletag = gtag;
window.apntag = atag;
})
})
beforeEach(() => {
pushBidResponseToAuction({
adUnitCode: 'mock-au'
});
container = document.createElement('div');
container.id = 'mock-au';
slot = document.createElement('div');
container.appendChild(slot);
document.body.appendChild(container)
});
afterEach(() => {
if (container) {
document.body.removeChild(container);
}
})
it('should handle resize request', () => {
const ev = makeEvent({
data: JSON.stringify({
adId: bidId,
message: 'Prebid Native',
action: 'resizeNativeHeight',
width: 123,
height: 321
}),
source: {
postMessage: sinon.stub()
},
origin: 'any origin'
});
return receive(ev).then(() => {
expect(slot.style.width).to.eql('123px');
expect(slot.style.height).to.eql('321px');
});
})
})
});

describe('Prebid Event', () => {
Expand Down

0 comments on commit 09e7484

Please sign in to comment.