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

✅ Validator rules for amp-vimeo 1.0 #34199

Merged
merged 1 commit into from
May 5, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions extensions/amp-vimeo/1.0/test/validator-amp-vimeo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--
Copyright 2021 The AMP HTML Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the license.
-->
<!--
Test Description:
This tests validation for the amp-vimeo tag version 1.0.
-->
<!DOCTYPE html>
<html ⚡>
<!-- prettier-ignore -->
<head>
<meta charset="utf-8">
<title>amp-vimeo 1.0</title>
<link rel="canonical" href="./">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Questrial" rel="stylesheet" type="text/css">
<script async custom-element="amp-vimeo" src="https://cdn.ampproject.org/v0/amp-vimeo-1.0.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
<!-- valid -->
<amp-vimeo data-videoid="27246366" width="500" height="281"></amp-vimeo>

<!-- valid -->
<amp-vimeo
data-videoid="27246366"
width="500"
height="281"
layout="responsive"
noloading
autoplay
></amp-vimeo>

<!-- valid -->
<amp-vimeo
data-videoid="27246366"
width="500"
height="281"
layout="responsive"
noloading="noloading"
></amp-vimeo>

<!-- invalid: bad videoid -->
<amp-vimeo
data-videoid="i don't think so"
width="500"
height="281"
layout="responsive"
></amp-vimeo>

<!-- invalid: videoid missing -->
<amp-vimeo width="500" height="281" layout="responsive"></amp-vimeo>

<!-- invalid: noloading must not have a value other than "" or noloading -->
<amp-vimeo
width="500"
height="281"
layout="responsive"
noloading="foo"
></amp-vimeo>
</body>
</html>
82 changes: 82 additions & 0 deletions extensions/amp-vimeo/1.0/test/validator-amp-vimeo.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
FAIL
| <!--
| Copyright 2021 The AMP HTML Authors. All Rights Reserved.
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS-IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the license.
| -->
| <!--
| Test Description:
| This tests validation for the amp-vimeo tag version 1.0.
| -->
| <!DOCTYPE html>
| <html ⚡>
| <!-- prettier-ignore -->
| <head>
| <meta charset="utf-8">
| <title>amp-vimeo 1.0</title>
| <link rel="canonical" href="./">
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
| <link href="https://fonts.googleapis.com/css?family=Questrial" rel="stylesheet" type="text/css">
| <script async custom-element="amp-vimeo" src="https://cdn.ampproject.org/v0/amp-vimeo-1.0.js"></script>
| <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| </head>
| <body>
| <!-- valid -->
| <amp-vimeo data-videoid="27246366" width="500" height="281"></amp-vimeo>
|
| <!-- valid -->
| <amp-vimeo
| data-videoid="27246366"
| width="500"
| height="281"
| layout="responsive"
| noloading
| autoplay
| ></amp-vimeo>
|
| <!-- valid -->
| <amp-vimeo
| data-videoid="27246366"
| width="500"
| height="281"
| layout="responsive"
| noloading="noloading"
| ></amp-vimeo>
|
| <!-- invalid: bad videoid -->
| <amp-vimeo
>> ^~~~~~~~~
amp-vimeo/1.0/test/validator-amp-vimeo.html:57:4 The attribute 'data-videoid' in tag 'amp-vimeo' is set to the invalid value 'i don't think so'. (see https://amp.dev/documentation/components/amp-vimeo)
| data-videoid="i don't think so"
| width="500"
| height="281"
| layout="responsive"
| ></amp-vimeo>
|
| <!-- invalid: videoid missing -->
| <amp-vimeo width="500" height="281" layout="responsive"></amp-vimeo>
>> ^~~~~~~~~
amp-vimeo/1.0/test/validator-amp-vimeo.html:65:4 The mandatory attribute 'data-videoid' is missing in tag 'amp-vimeo'. (see https://amp.dev/documentation/components/amp-vimeo)
|
| <!-- invalid: noloading must not have a value other than "" or noloading -->
| <amp-vimeo
>> ^~~~~~~~~
amp-vimeo/1.0/test/validator-amp-vimeo.html:68:4 The attribute 'noloading' in tag 'amp-vimeo' is set to the invalid value 'foo'. (see https://amp.dev/documentation/components/amp-vimeo)
| width="500"
| height="281"
| layout="responsive"
| noloading="foo"
| ></amp-vimeo>
| </body>
| </html>
15 changes: 15 additions & 0 deletions extensions/amp-vimeo/validator-amp-vimeo.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@
# limitations under the license.
#

tags: { # amp-vimeo 1.0
html_format: AMP
tag_name: "SCRIPT"
satisfies: "amp-vimeo 1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a test for the satisfies/excludes?

Copy link
Member Author

Choose a reason for hiding this comment

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

How would that work?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd imagine it would be one with both script tags, though it may issue a different error. What is being achieved by having satisifes/excludes here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Two script tags should throw the error for this satisfies/excludes. For context the satisfies/excludes was added from a somewhat recent change to validator here: https://critique-ng.corp.google.com/cl/366894452

This allows us to specify different extension_spec rules between different versions of the script. So in this case 1.0 does not have the following:

requires_usage: EXEMPTED
deprecated_allow_duplicates: true

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't get the following to fail, in either order:

<script async custom-element="amp-vimeo" src="https://cdn.ampproject.org/v0/amp-vimeo-1.0.js"></script>
<script async custom-element="amp-vimeo" src="https://cdn.ampproject.org/v0/amp-vimeo-0.1.js"></script>

Could there be a problem with the definition that prevents this from erroring out?

Copy link
Contributor

Choose a reason for hiding this comment

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

The definition looks right, I also tried producing locally and also not able to get it to fail. I will check with the Validator team.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Kevin. As discussed offline, the error is not being triggered in any case. Since that's being handled separately, I'll merge as-is.

excludes: "amp-vimeo 0.1"
extension_spec: {
name: "amp-vimeo"
version_name: "v1.0"
version: "1.0"
}
attr_lists: "common-extension-attrs"
}
tags: { # amp-vimeo
html_format: AMP
tag_name: "SCRIPT"
satisfies: "amp-vimeo 0.1"
excludes: "amp-vimeo 1.0"
extension_spec: {
name: "amp-vimeo"
version_name: "v0.1"
version: "0.1"
version: "latest"
requires_usage: EXEMPTED
Expand Down