Skip to content

Adding a4a support to TripleLift amp-ads#6884

Merged
lannka merged 1 commit intoampproject:masterfrom
triplelift:feature/triplelift-a4a
Jan 12, 2017
Merged

Adding a4a support to TripleLift amp-ads#6884
lannka merged 1 commit intoampproject:masterfrom
triplelift:feature/triplelift-a4a

Conversation

@szach
Copy link
Copy Markdown
Contributor

@szach szach commented Jan 5, 2017

Issue #6883

@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

Copy link
Copy Markdown
Contributor

@keithwrightbos keithwrightbos left a comment

Choose a reason for hiding this comment

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

Test coverage?

import {AmpA4A} from '../../amp-a4a/0.1/amp-a4a';
import {base64UrlDecodeToBytes} from '../../../src/utils/base64';

const AMP_SIGNATURE_HEADER = 'X-AmpAdSignature';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add /** @type {string} */ here and below

/**
* @param {!Element} element
*/
constructor(element) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given you're only calling super, why is this necessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was actually in our template code as a placeholder, to show where initialization code could go. I'm adding comments to the template code that this is an optional block and can be removed if there is no content.


/** @override */
extractCreativeAndSignature(responseText, responseHeaders) {
var signature = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

replace var with let


/** @override */
isValidElement() {
return this.element.hasAttribute('src') && this.isAmpAdElement();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you should check for the src attribute within isA4A predicate as isValidElement returning false will cause the ad request to be dropped meaning it does not fallback to 3p

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest at least the same check as you have in your current 3p implementation (https://github.com/ampproject/amphtml/blob/master/ads/triplelift.js):
validateSrcPrefix('https://ib.3lift.com/', src);


/** @override */
getAdUrl() {
return this.element.getAttribute('src').replace(TRIPLELIFT_BASE_URL, TRIPLELIFT_BASE_A4A_URL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you want to verify that the src attribute has the TRIPLELIFT_BASE_URL to start? I noticed that you're 3p implementation includes validateSrcPrefix('https://ib.3lift.com/'. Without it, this could allow a callout to ANY XHR CORS end point (e.g. src to doubleclick). This is supplied by the publisher so what if it includes javascript(sendMeYourCookies())?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add check in the config use A4A predicate as well as isValidElement. Both will ensure proper value well before getAdUrl would execute.

*/
export function tripleliftIsA4AEnabled(win, element) {
const a4aRequested = element.getAttribute('data-use-a4a');
return !!a4aRequested;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just
return !!element.getAttribute('data-use-a4a');

@keithwrightbos
Copy link
Copy Markdown
Contributor

I have reopened the PR. Sorry I did not see notifications because the PR was closed.
@lannka & @jridgewell to look ASAP given we are hoping to get into today's canary cut

@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.


/** @override */
isValidElement() {
return this.isAmpAdElement();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add check for src attribute and starting with base url you expect just to be safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was being overly cautious... we do not need to include it

sandbox.restore();
});

describe('#isValidElement', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a negative test here (create instance of amp-ad-network-triplelift element instead of amp-ad) as well as checks regarding src.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed

@szach szach force-pushed the feature/triplelift-a4a branch 2 times, most recently from 745bc5b to f2f1af4 Compare January 11, 2017 20:33
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@keithwrightbos keithwrightbos requested a review from lannka January 11, 2017 20:34
@szach szach force-pushed the feature/triplelift-a4a branch 3 times, most recently from 9519e59 to 0b5bc58 Compare January 11, 2017 22:09
import {createElementWithAttributes} from '../../../../src/dom';
import {createIframePromise} from '../../../../testing/iframe';

describe.only('triplelift-a4a-config', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove only

@lannka lannka self-assigned this Jan 12, 2017
@szach szach force-pushed the feature/triplelift-a4a branch from 0b5bc58 to 072ba30 Compare January 12, 2017 01:15
@lannka lannka merged commit 0027e1d into ampproject:master Jan 12, 2017
jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants