Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: fix broken native resizing #12096

Merged
merged 2 commits into from
Aug 11, 2024
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/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