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

Render outstream safeframe #3159

Merged
merged 3 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions src/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ Renderer.prototype.process = function() {
}
}
};

/**
* Render the bid returned by the adapter
* @param {Object} renderer Renderer object installed by adapter
* @param {Object} bid Bid response
*/
export function executeRenderer(renderer, bid) {
renderer.render(bid);
}
3 changes: 2 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createHook } from 'src/hook';
import { sessionLoader } from 'src/debugging';
import includes from 'core-js/library/fn/array/includes';
import { adunitCounter } from './adUnits';
import { executeRenderer } from './Renderer';

const $$PREBID_GLOBAL$$ = getGlobal();
const CONSTANTS = require('./constants.json');
Expand Down Expand Up @@ -249,7 +250,7 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
utils.insertElement(creativeComment, doc, 'body');

if (renderer && renderer.url) {
renderer.render(bid);
executeRenderer(renderer, bid);
} else if ((doc === document && !utils.inIframe()) || mediaType === 'video') {
const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`;
emitAdRenderFail(PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid);
Expand Down
9 changes: 6 additions & 3 deletions src/secureCreatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EVENTS } from './constants';
import { isSlotMatchingAdUnitCode } from './utils';
import { auctionManager } from './auctionManager';
import find from 'core-js/library/fn/array/find';
import { executeRenderer } from './Renderer';

const BID_WON = EVENTS.BID_WON;

Expand Down Expand Up @@ -53,9 +54,11 @@ function receiveMessage(ev) {
}

function sendAdToCreative(adObject, remoteDomain, source) {
const { adId, ad, adUrl, width, height } = adObject;

if (adId) {
const { adId, ad, adUrl, width, height, renderer } = adObject;
// rendering for outstream safeframe
if (renderer && renderer.url) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this logic into a separate function so it sits in one place? For example, it's also in pbjs.renderAd().

executeRenderer(renderer, adObject);
} else if (adId) {
resizeRemoteCreative(adObject);
source.postMessage(JSON.stringify({
message: 'Prebid Response',
Expand Down