Skip to content

Commit

Permalink
New validation rule for A4A meta tags. (#22917)
Browse files Browse the repository at this point in the history
* new rule.

* typo

* comments

* tests

* comments
  • Loading branch information
calebcordry authored Jul 3, 2019
1 parent f38db3d commit b66f2fa
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
10 changes: 10 additions & 0 deletions validator/testdata/amp4ads_feature_tests/amp_story_ad.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<!-- Specifies what type of landing page the user is direct to -->
<meta name="amp-cta-landing-page-type" content="NONAMP">

<!-- Specifies where the attribution icon will be loaded from (optional). -->
<meta name="amp4ads-vars-attribution-icon" content="https://placekitten.com/30/30">

<!-- Specifies where a click on attribution icon will land (optional). -->
<meta name="amp4ads-vars-attribution-url" content="https://example.com">

<!-- Optional format for creatives to pass data to AMP runtime. -->
<meta name="amp4ads-vars-foo" content="bar">


<style amp4ads-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
amp-img {height: 100vh}
Expand Down
12 changes: 11 additions & 1 deletion validator/testdata/amp4ads_feature_tests/amp_story_ad.out
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ PASS
| <!-- Specifies what type of landing page the user is direct to -->
| <meta name="amp-cta-landing-page-type" content="NONAMP">
|
| <!-- Specifies where the attribution icon will be loaded from (optional). -->
| <meta name="amp4ads-vars-attribution-icon" content="https://placekitten.com/30/30">
|
| <!-- Specifies where a click on attribution icon will land (optional). -->
| <meta name="amp4ads-vars-attribution-url" content="https://example.com">
|
| <!-- Optional format for creatives to pass data to AMP runtime. -->
| <meta name="amp4ads-vars-foo" content="bar">
|
|
| <style amp4ads-boilerplate>body{visibility:hidden}</style>
| <style amp-custom>
| amp-img {height: 100vh}
Expand All @@ -43,4 +53,4 @@ PASS
| <body>
| <amp-img src="cats.jpg" layout="responsive" height="1280" width="720"></amp-img>
| </body>
| </html>
| </html>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
<!-- Should fail due to invalid content choice. -->
<meta name="amp-cta-landing-page-type" content="GAME">

<!-- Should fail due to no `content=`. -->
<meta name="amp4ads-vars-foo">

<!-- Should fail due unrecognized `name` -->
<meta name="amp4ads-vars" content="bar">
<meta name="amp4ads-vars-" content="bar">


<style amp4ads-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
amp-img {height: 100vh}
Expand Down
16 changes: 15 additions & 1 deletion validator/testdata/amp4ads_feature_tests/amp_story_ad_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ amp4ads_feature_tests/amp_story_ad_errors.html:31:4 The mandatory attribute 'con
>> ^~~~~~~~~
amp4ads_feature_tests/amp_story_ad_errors.html:34:4 The attribute 'content' in tag 'meta name=amp-cta-landing-page-type' is set to the invalid value 'GAME'. [DISALLOWED_HTML]
|
| <!-- Should fail due to no `content=`. -->
| <meta name="amp4ads-vars-foo">
>> ^~~~~~~~~
amp4ads_feature_tests/amp_story_ad_errors.html:37:4 The mandatory attribute 'content' is missing in tag 'meta name=amp4ads-vars-*'. [DISALLOWED_HTML]
|
| <!-- Should fail due unrecognized `name` -->
| <meta name="amp4ads-vars" content="bar">
>> ^~~~~~~~~
amp4ads_feature_tests/amp_story_ad_errors.html:40:4 The attribute 'name' in tag 'meta name= and content=' is set to the invalid value 'amp4ads-vars'. [DISALLOWED_HTML]
| <meta name="amp4ads-vars-" content="bar">
>> ^~~~~~~~~
amp4ads_feature_tests/amp_story_ad_errors.html:41:4 The attribute 'name' in tag 'meta name= and content=' is set to the invalid value 'amp4ads-vars-'. [DISALLOWED_HTML]
|
|
| <style amp4ads-boilerplate>body{visibility:hidden}</style>
| <style amp-custom>
| amp-img {height: 100vh}
Expand All @@ -49,4 +63,4 @@ amp4ads_feature_tests/amp_story_ad_errors.html:34:4 The attribute 'content' in t
| <body>
| <amp-img src="cats.jpg" layout="responsive" height="1280" width="720"></amp-img>
| </body>
| </html>
| </html>
18 changes: 18 additions & 0 deletions validator/validator-main.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,24 @@ tags: {
dispatch_key: NAME_VALUE_DISPATCH
}
}
# AMP metadata, name=amp4ads-vars-*
# Allows advertisers to pass information from creatives
# to be included in amp-ad-metadata.
tags: {
html_format: AMP4ADS
tag_name: "META"
spec_name: "meta name=amp4ads-vars-*"
mandatory_parent: "HEAD"
attrs: {
name: "content"
mandatory: true
}
attrs: {
name: "name"
mandatory: true
value_regex: "amp4ads-vars-.+"
}
}
# 4.2.6 The style
# Text contents of the style tag will be validated seperately.
tags: { # Special custom 'author' spreadsheet for AMP
Expand Down

0 comments on commit b66f2fa

Please sign in to comment.