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
A4A: Do not set visibility hidden for iframe attached via A4A flow #4215
Conversation
Accidentally based from a4a upgradeCallback PR. Apologies. Please only refer to commit "Do not set visibility hidden when rendering via iframe from A4A" |
// Set opt_defaultVisible to true as 3p draw code never executed causing | ||
// render-start event never to fire which will remove visiblity hidden. | ||
this.apiHandler_.startUp( | ||
iframe, opt_isNonAmpCreative/* is3p */, true/* opt_defaultVisible */); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline comments go before the param.
You can rebase with |
Removed a4a upgrade callback changes. Back to @jridgewell Thanks! |
LGTM. You'll need to rebase of latest master, though. |
Reopening this one. @keithwrightbos, appears we have a test failure:
|
@jridgewell I believe this is unrelated to the changes I made however I believe I have pushed a fix. @tdrl I believe this occurred as a result of the structure you committed recently. |
@@ -403,7 +403,9 @@ describe('amp-a4a', () => { | |||
const doc = fixture.doc; | |||
const a4aElement = doc.createElement('amp-a4a'); | |||
const a4a = new AmpA4A(a4aElement); | |||
return a4a.maybeRenderAmpAd_(null).then(rendered => { | |||
a4a.adUrl_ = 'http://foo.com'; | |||
a4a.maybeRenderAmpAd_ = function() { return Promise.resolve(false); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right fix. maybeRenderAmpAd_()
should be able to handle a null
input. That should cause utf8FromArrayBuffer()
to throw an error. It looks like the missing bit is that utf8FromArrayBuffer()
is missing a .catch()
clause. (Alternatively, maybeRenderAmpAd_()
could just check for null
on input and return Promise.resolve(false)
immediately.)
I could make that change if you like, or you could on this PR. Happy either way.
What puzzles me is that this test passed when I submitted the previous PR. (Otherwise it wouldn't have gone in.) Once again, I'm suspicious of the unit test framework's reliability. :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went this route because the current documentation indicates ArrayBuffer
input cannot be null which given the code the calls it first checks that it
is not null makes sense to me:
return creative && this.maybeRenderAmpAd_(creative);
/**
- Render a validated AMP creative directly in the parent page.
- @param {!ArrayBuffer} bytes The creative, as raw bytes.
- @return {Promise} Whether the creative was successfully
-
rendered.
- @Private
*/
maybeRenderAmpAd_(bytes) { ... }
On Fri, Jul 29, 2016 at 11:30 AM, Terran Lane notifications@github.com
wrote:
In extensions/amp-a4a/0.1/test/test-amp-a4a.js
#4215 (comment):@@ -403,7 +403,9 @@ describe('amp-a4a', () => {
const doc = fixture.doc;
const a4aElement = doc.createElement('amp-a4a');
const a4a = new AmpA4A(a4aElement);
return a4a.maybeRenderAmpAd_(null).then(rendered => {
a4a.adUrl_ = 'http://foo.com';
a4a.maybeRenderAmpAd_ = function() { return Promise.resolve(false); }
I don't think this is the right fix. maybeRenderAmpAd_() should be able
to handle a null input. That should cause utf8FromArrayBuffer() to throw
an error. It looks like the missing bit is that utf8FromArrayBuffer() is
missing a .catch() clause. (Alternatively, maybeRenderAmpAd_() could just
check for null on input and return Promise.resolve(false) immediately.)I could make that change if you like, or you could on this PR. Happy
either way.What puzzles me is that this test passed when I submitted the previous
PR. (Otherwise it wouldn't have gone in.) Once again, I'm suspicious of the
unit test framework's reliability. :-(—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ampproject/amphtml/pull/4215/files/b61b2e8d312d2b3918f6723a42c14d28ac6728ee..ede9c7390fa511bd7f1fa11e994aa43e157ba889#r72811353,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABr0LyXRo0Lfe0kYrRH8Jpizdvccvx8Gks5qahyEgaJpZM4JVYV9
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... I think that's my mistake in writing the docs. :-) The output from validateAdResponse_()
can be null:
return verifySignature(
new Uint8Array(creative), signature, publicKeyInfos).then(isValid => {
return isValid ? creative : null;
});
And I think the cut-out for checking creative && ...
is knee-jerk more than anything.
The intended behavior is: "If the thing validates, then it should pass a valid creative ArrayBuffer
along. Anything else (i.e., null
) should be interpreted as invalid." But I lost track of who was responsible for handling the null
case. By adding the cut-out, I prevented null
from entering maybeRenderAmpAd()
in the pipeline flow. But then this test forced null
in. Since maybeRenderAmpAd
doesn't have a check for that, it errors when trying to convert null
to utf8.
I guess formerly that error was correctly interpreted as render failure, but now it's not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tdrl I agree that the output from validateAdResponse_ can be null but I think the creative && ... check is sufficient for now. As we have discussed offline, we need to rework the flow to handle empty creative (either from empty XHR response or empty creative from extract). I believe our plan was to check the state at each point within the promise chain flow as opposed to within each private function call (in other words as we are doing now as opposed to allowing empty creative state to be passed to validateAdResponse_).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok. I see what you're saying. This will end up changing in the future, as we tighten up the promise chain regardless. For the moment, though, your fix LGTM.
const a4aElement = doc.createElement('amp-a4a'); | ||
const a4a = new AmpA4A(a4aElement); | ||
a4a.adUrl_ = 'http://foo.com'; | ||
a4a.maybeRenderAmpAd_ = function() { return Promise.resolve(false); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a semicolon.
One last style nit to pass lint, then LGTM. |
@jridgewell - I fixed the remaining lint issue. Thanks |
…mpproject#4215) * Do not set visibility hidden when rendering via iframe from A4A * Fixes related to review * Do not set visibility hidden when rendering via iframe from A4A * Fixes related to review * fix test failure * Add missing semi-colon
…mpproject#4215) * Do not set visibility hidden when rendering via iframe from A4A * Fixes related to review * Do not set visibility hidden when rendering via iframe from A4A * Fixes related to review * fix test failure * Add missing semi-colon
Fixes #4212.