Make render-start respond to resize info#4842
Conversation
12343bd to
4eec2d7
Compare
3p/integration.js
Outdated
|
|
||
| function triggerRenderStart() { | ||
| nonSensitiveDataPostMessage('render-start'); | ||
| function triggerRenderStart(width, height) { |
There was a problem hiding this comment.
I copy the format from other function that postMessages. triggerRenderStart() and triggerRenderStart(width, height) both work, how can we represent this in our code and let 3p ad know?
There was a problem hiding this comment.
Let's make the param a opt_data object, for future extensibility.
A JS doc for this optional param would help.
We should also update ads/README.md.
There was a problem hiding this comment.
fixed. will add JS doc
| * @private | ||
| */ | ||
| sendEmbedInfo_(inViewport) { | ||
| if (!this.embedStateApi_) { |
There was a problem hiding this comment.
viewportCallback() can be called anytime after element build. this.embedStateApi_ may not be initiated when this function is called. Add the check here.
ads/README.md
Outdated
| - `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules. | ||
| - `window.context.reportRenderedEntityIdentifier` MUST be called by ads, when they know information about which creative was rendered into a particular ad frame and should contain information to allow identifying the creative. Consider including a small string identifying the ad network. This is used by AMP for reporting purposes. The value MUST NOT contain user data or personal identifiable information. | ||
| - `window.context.renderStart` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. | ||
| - `window.context.renderStart(opt_data)` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use opt_data object {width, height} to send the rendered ad size which AMP will use for resize. Please check Ad resizing part for more information. |
There was a problem hiding this comment.
... the returned ad size to request a resize. ...
Also, pls format opt_data into code style, same for {width, height}.
There was a problem hiding this comment.
Please also move this bullet point to the top (before noContentAvailable). And consider to change the wording from can to should, as we plan to push more ad networks to implement the new APIs.
There was a problem hiding this comment.
should we also do this for noContentAvailabe?
consider to change the wording from can to should
| it('should resolve and resize on message "render-start" w/ size if ' | ||
| + 'render-start is implemented by 3P', () => { | ||
| adImpl.adType = 'doubleclick'; | ||
| sandbox.stub(adImpl, 'attemptChangeSize', () => { |
There was a problem hiding this comment.
please verify the size is correctly passed to attemptChangeSize
ads/README.md
Outdated
| - `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules. | ||
| - `window.context.reportRenderedEntityIdentifier` MUST be called by ads, when they know information about which creative was rendered into a particular ad frame and should contain information to allow identifying the creative. Consider including a small string identifying the ad network. This is used by AMP for reporting purposes. The value MUST NOT contain user data or personal identifiable information. | ||
| - `window.context.renderStart` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. | ||
| - `window.context.renderStart(opt_data)` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use `opt_data` object of form `{width, height}` to send the returned ad size to request a resize. Please check Ad resizing part for more information. |
There was a problem hiding this comment.
Also add a link to "Ad resizing"
|
LGTM with some cosmetic nitpicks. |
ads/README.md
Outdated
| ### Methods available to the ad. | ||
|
|
||
| - `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules. | ||
| - `window.context.renderStart(opt_data)` is a function that the ad system should call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use `opt_data` object of form `{width, height}` to send the returned ad size to request a resize. Please check [Ad resizing](https://github.com/ampproject/amphtml/blob/master/ads/README.md#ad-resizing) for more information. |
There was a problem hiding this comment.
About the link, I think #ad-resizing should be enough?
This is to make
render-startAPI support multi-size ad. #3176It's also an improvement to ad load behavior #4022