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

Ensure fluid params get passed in SRA request #19539

Merged
merged 2 commits into from
Nov 30, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,14 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
getA4aAnalyticsConfig() {
return getCsiAmpAnalyticsConfig();
}

/**
* @return {boolean} True if 'fluid' is one of the requested sizes, false
* otherwise.
*/
isFluidRequest() {
return this.isFluidRequest_;
}
}

AMP.extension(TAG, '0.1', AMP => {
Expand Down
22 changes: 21 additions & 1 deletion extensions/amp-ad-network-doubleclick-impl/0.1/sra-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const TFCD = 'tagForChildDirectedTreatment';
const SRA_JOINERS = [
combineInventoryUnits, getCookieOptOut, getAdks, getSizes, getTfcd, isAdTest,
getTargetingAndExclusions, getExperimentIds, getIdentity, getForceSafeframe,
getPageOffsets, getContainers];
getPageOffsets, getContainers, getIsFluid];

/**
* @param {!Array<!./amp-ad-network-doubleclick-impl.AmpAdNetworkDoubleclickImpl>} impls
Expand Down Expand Up @@ -276,6 +276,26 @@ export function getContainers(impls) {
return hasAmpContainer ? {'acts': result.join('|')} : null;
}

/**
* Combine fluid settings for each block via comma separator.
* @param {!Array<!./amp-ad-network-doubleclick-impl.AmpAdNetworkDoubleclickImpl>} impls
* @return {?Object<string,string>}
* @visibleForTesting
*/
export function getIsFluid(impls) {
let hasFluid = false;
const result = [];
impls.forEach(impl => {
if (impl.isFluidRequest()) {
hasFluid = true;
result.push('height');
} else {
result.push('0');
}
});
return hasFluid ? {'fluid': result.join()} : null;
}

/**
* @param {?Object<string, (!Array<string>|string)>} targeting
* @param {?(!Array<string>|string)} categoryExclusions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describes.realWin('DoubleClick Fast Fetch Fluid', realWinConfig, env => {
});

it('should be fluid enabled', () => {
expect(impl.isFluidRequest_).to.be.true;
expect(impl.isFluidRequest()).to.be.true;
});

it('should have a supported layout', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
getExperimentIds,
getForceSafeframe,
getIdentity,
getIsFluid,
getPageOffsets,
getSizes,
getTargetingAndExclusions,
Expand Down Expand Up @@ -248,6 +249,12 @@ describes.realWin('Doubleclick SRA', config , env => {
parentElement: {tagName: 'AMP-STICKY-AD'}}}};
expect(getContainers(impls)).to.jsonEqual({'acts': '|ac|ac,sa'});
});
it('should combine fluid state', () => {
impls[0] = {isFluidRequest: () => true};
impls[1] = {isFluidRequest: () => false};
impls[2] = {isFluidRequest: () => true};
expect(getIsFluid(impls)).to.jsonEqual({'fluid': 'height,0,height'});
});
});

describe('#SRA AMP creative unlayoutCallback', () => {
Expand Down