Skip to content

Commit

Permalink
✅ Validator rules for amp-video-iframe 1.0 (#34200)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco authored May 11, 2021
1 parent 0c63a01 commit 4847034
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!--
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.
-->
<!--
Tests for amp-video-iframe tag version 1.0
-->
<!DOCTYPE html>
<html >
<!-- prettier-ignore -->
<head>
<meta charset="utf-8">
<title>amp-video-iframe 1.0</title>
<link rel="canonical" href="./">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<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>
<script async custom-element="amp-video-iframe" src="https://cdn.ampproject.org/v0/amp-video-iframe-1.0.js"></script>
</head>
<body>
<!-- Valid -->
<amp-video-iframe
width="640"
height="360"
layout="responsive"
src="https://foo.com"
>
</amp-video-iframe>

<!-- Valid -->
<amp-video-iframe
width="640"
height="360"
layout="responsive"
src="https://foo.com"
poster="images/kitten-playing.png"
>
</amp-video-iframe>

<!-- Invalid: Incorrect attribute value for autoplay -->
<amp-video-iframe
autoplay="true"
layout="fill"
width="300"
height="500"
src="https://foo.com"
poster="images/kitten-playing.png"
>
</amp-video-iframe>

<!-- Valid: correct attribute value for autoplay -->
<amp-video-iframe
autoplay
layout="fill"
width="300"
height="500"
src="https://foo.com"
poster="images/kitten-playing.png"
>
</amp-video-iframe>

<!-- Valid: Correct attribute value for rotate-to-fullscreen -->
<amp-video-iframe
rotate-to-fullscreen
layout="fill"
width="300"
height="500"
src="https://foo.com"
poster="images/kitten-playing.png"
>
</amp-video-iframe>

<!-- Invalid: Incorrect attribute value for rotate-to-fullscreen -->
<amp-video-iframe
rotate-to-fullscreen="true"
layout="fill"
width="300"
height="500"
src="https://foo.com"
poster="images/kitten-playing.png"
>
</amp-video-iframe>
</body>
</html>
100 changes: 100 additions & 0 deletions extensions/amp-video-iframe/1.0/test/validator-amp-video-iframe.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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.
| -->
| <!--
| Tests for amp-video-iframe tag version 1.0
| -->
| <!DOCTYPE html>
| <html ⚡>
| <!-- prettier-ignore -->
| <head>
| <meta charset="utf-8">
| <title>amp-video-iframe 1.0</title>
| <link rel="canonical" href="./">
| <meta name="viewport" content="width=device-width,minimum-scale=1">
| <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>
| <script async custom-element="amp-video-iframe" src="https://cdn.ampproject.org/v0/amp-video-iframe-1.0.js"></script>
| </head>
| <body>
| <!-- Valid -->
| <amp-video-iframe
| width="640"
| height="360"
| layout="responsive"
| src="https://foo.com"
| >
| </amp-video-iframe>
|
| <!-- Valid -->
| <amp-video-iframe
| width="640"
| height="360"
| layout="responsive"
| src="https://foo.com"
| poster="images/kitten-playing.png"
| >
| </amp-video-iframe>
|
| <!-- Invalid: Incorrect attribute value for autoplay -->
| <amp-video-iframe
>> ^~~~~~~~~
amp-video-iframe/1.0/test/validator-amp-video-iframe.html:52:4 The attribute 'autoplay' in tag 'amp-video-iframe' is set to the invalid value 'true'. (see https://amp.dev/documentation/components/amp-video-iframe/)
| autoplay="true"
| layout="fill"
| width="300"
| height="500"
| src="https://foo.com"
| poster="images/kitten-playing.png"
| >
| </amp-video-iframe>
|
| <!-- Valid: correct attribute value for autoplay -->
| <amp-video-iframe
| autoplay
| layout="fill"
| width="300"
| height="500"
| src="https://foo.com"
| poster="images/kitten-playing.png"
| >
| </amp-video-iframe>
|
| <!-- Valid: Correct attribute value for rotate-to-fullscreen -->
| <amp-video-iframe
| rotate-to-fullscreen
| layout="fill"
| width="300"
| height="500"
| src="https://foo.com"
| poster="images/kitten-playing.png"
| >
| </amp-video-iframe>
|
| <!-- Invalid: Incorrect attribute value for rotate-to-fullscreen -->
| <amp-video-iframe
>> ^~~~~~~~~
amp-video-iframe/1.0/test/validator-amp-video-iframe.html:85:4 The attribute 'rotate-to-fullscreen' in tag 'amp-video-iframe' is set to the invalid value 'true'. (see https://amp.dev/documentation/components/amp-video-iframe/)
| rotate-to-fullscreen="true"
| layout="fill"
| width="300"
| height="500"
| src="https://foo.com"
| poster="images/kitten-playing.png"
| >
| </amp-video-iframe>
| </body>
| </html>
16 changes: 16 additions & 0 deletions extensions/amp-video-iframe/validator-amp-video-iframe.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,24 @@
tags: { # amp-video-iframe
html_format: AMP # Iframes not allowed in ads.
tag_name: "SCRIPT"
satisfies: "amp-video-iframe 1.0"
excludes: "amp-video-iframe 0.1"
extension_spec: {
name: "amp-video-iframe"
version_name: "v1.0"
version: "1.0"
}
attr_lists: "common-extension-attrs"
}

tags: { # amp-video-iframe
html_format: AMP # Iframes not allowed in ads.
tag_name: "SCRIPT"
satisfies: "amp-video-iframe 0.1"
excludes: "amp-video-iframe 1.0"
extension_spec: {
name: "amp-video-iframe"
version_name: "v0.1"
version: "0.1"
version: "latest"
}
Expand Down

0 comments on commit 4847034

Please sign in to comment.