Skip to content

Commit

Permalink
Validator rollup (#39427)
Browse files Browse the repository at this point in the history
* cl/552881955 Two-way sync for PR #39237. No-op, or fixes merge conflicts, if any.

* cl/555542556 n/a

* Updates ads.out to make validator-tests.js pass

* Update some files that fail lint.
  • Loading branch information
banaag authored Sep 1, 2023
1 parent 87288cd commit 49ee0db
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 15 deletions.
10 changes: 10 additions & 0 deletions validator/testdata/feature_tests/img.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
hspace=10 vspace=20 importance="high" crossorigin="use-credentials" ismap="true"
referrerpolicy="same-origin" usemap="#blah" name="name">

<!-- Valid with fetchpriority -->
<img src="http://www.example.com/blah.jpg" width=92 height=10
alt="blah" decoding=async loading=lazy border="5px solid black" align="top"
hspace=10 vspace=20 fetchpriority="low" importance="high" crossorigin="use-credentials" ismap="true"
referrerpolicy="same-origin" usemap="#blah" name="name">

<!-- Valid with https -->
<img src="https://www.example.com/blah.jpg" width=92 height=10
alt="blah" decoding=async loading=lazy border="5px solid black" align="bottom"
Expand Down Expand Up @@ -51,6 +57,10 @@
<img src=data:image/png:base64,foo width=100 height=10
alt="blah" importance=none>

<!-- Invalid with wrong fetchpriority -->
<img src=data:image/png:base64,foo width=100 height=10
alt="blah" fetchpriority="wrongpriority">

<!-- Invalid with wrong crossorigin -->
<img src=data:image/png:base64,foo width=100 height=10
alt="blah" crossorigin="wrongcrossorigin">
Expand Down
30 changes: 21 additions & 9 deletions validator/testdata/feature_tests/img.out
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ FAIL
| hspace=10 vspace=20 importance="high" crossorigin="use-credentials" ismap="true"
| referrerpolicy="same-origin" usemap="#blah" name="name">
|
| <!-- Valid with fetchpriority -->
| <img src="http://www.example.com/blah.jpg" width=92 height=10
| alt="blah" decoding=async loading=lazy border="5px solid black" align="top"
| hspace=10 vspace=20 fetchpriority="low" importance="high" crossorigin="use-credentials" ismap="true"
| referrerpolicy="same-origin" usemap="#blah" name="name">
|
| <!-- Valid with https -->
| <img src="https://www.example.com/blah.jpg" width=92 height=10
| alt="blah" decoding=async loading=lazy border="5px solid black" align="bottom"
Expand Down Expand Up @@ -51,31 +57,37 @@ FAIL
| <!-- Invalid with wrong importance -->
| <img src=data:image/png:base64,foo width=100 height=10
>> ^~~~~~~~~
feature_tests/img.html:51:2 The attribute 'importance' in tag 'img' is set to the invalid value 'none'.
feature_tests/img.html:57:2 The attribute 'importance' in tag 'img' is set to the invalid value 'none'.
| alt="blah" importance=none>
|
| <!-- Invalid with wrong fetchpriority -->
| <img src=data:image/png:base64,foo width=100 height=10
>> ^~~~~~~~~
feature_tests/img.html:61:2 The attribute 'fetchpriority' in tag 'img' is set to the invalid value 'wrongpriority'.
| alt="blah" fetchpriority="wrongpriority">
|
| <!-- Invalid with wrong crossorigin -->
| <img src=data:image/png:base64,foo width=100 height=10
>> ^~~~~~~~~
feature_tests/img.html:55:2 The attribute 'crossorigin' in tag 'img' is set to the invalid value 'wrongcrossorigin'.
feature_tests/img.html:65:2 The attribute 'crossorigin' in tag 'img' is set to the invalid value 'wrongcrossorigin'.
| alt="blah" crossorigin="wrongcrossorigin">
|
| <!-- Invalid with wrong referrerpolicy -->
| <img src=data:image/png:base64,foo width=100 height=10
>> ^~~~~~~~~
feature_tests/img.html:59:2 The attribute 'referrerpolicy' in tag 'img' is set to the invalid value 'wrongreferrerpolicy'.
feature_tests/img.html:69:2 The attribute 'referrerpolicy' in tag 'img' is set to the invalid value 'wrongreferrerpolicy'.
| alt="blah" referrerpolicy="wrongreferrerpolicy">
|
| <!-- Invalid with wrong decoding -->
| <img src=data:image/png:base64,foo width=100 height=10
>> ^~~~~~~~~
feature_tests/img.html:63:2 The attribute 'decoding' in tag 'img' is set to the invalid value 'sync'.
feature_tests/img.html:73:2 The attribute 'decoding' in tag 'img' is set to the invalid value 'sync'.
| alt="blah" decoding=sync loading=lazy>
|
| <!-- Invalid with wrong loading -->
| <img src="https://www.example.com/blah.jpg" width=92 height=10
>> ^~~~~~~~~
feature_tests/img.html:67:2 The attribute 'loading' in tag 'img' is set to the invalid value 'smart'.
feature_tests/img.html:77:2 The attribute 'loading' in tag 'img' is set to the invalid value 'smart'.
| alt="blah" decoding=async loading=smart>
|
| <!-- Invalid with data-hero loading -->
Expand Down Expand Up @@ -129,20 +141,20 @@ feature_tests/img.html:67:2 The attribute 'loading' in tag 'img' is set to the i
| <!-- Invalid inside amp-story -->
| <amp-story standalone
>> ^~~~~~~~~
feature_tests/img.html:119:2 Tag 'amp-story' is not allowed to have any sibling tags ('body' should only have 1 child). (see https://amp.dev/documentation/components/amp-story)
feature_tests/img.html:129:2 Tag 'amp-story' is not allowed to have any sibling tags ('body' should only have 1 child). (see https://amp.dev/documentation/components/amp-story)
>> ^~~~~~~~~
feature_tests/img.html:119:2 The tag 'amp-story' requires including the 'amp-story' extension JavaScript. (see https://amp.dev/documentation/components/amp-story)
feature_tests/img.html:129:2 The tag 'amp-story' requires including the 'amp-story' extension JavaScript. (see https://amp.dev/documentation/components/amp-story)
| title=""
| publisher=""
| publisher-logo-src="logo"
| poster-portrait-src="portrait">
| <amp-story-page id=page1>
>> ^~~~~~~~~
feature_tests/img.html:124:4 The tag 'amp-story-page' requires including the 'amp-story' extension JavaScript. (see https://amp.dev/documentation/components/amp-story)
feature_tests/img.html:134:4 The tag 'amp-story-page' requires including the 'amp-story' extension JavaScript. (see https://amp.dev/documentation/components/amp-story)
| <amp-story-grid-layer template="vertical">
| <img src="http://www.example.com/blah.jpg#fragment" width=92 height=10>"
>> ^~~~~~~~~
feature_tests/img.html:126:8 The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? (see https://amp.dev/documentation/components/amp-img/)
feature_tests/img.html:136:8 The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? (see https://amp.dev/documentation/components/amp-img/)
| </amp-story-grid-layer>
| </amp-story-page>
| </amp-story>
Expand Down
2 changes: 1 addition & 1 deletion validator/testdata/feature_tests/link_meta_values.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<link rel="manifest foo" href="foo">
<link rel="preload" as="script" href="https://cdn.ampproject.org/v0.js">
<link rel="shortcut icon" type="a" href="b" sizes="c">
<link rel="author" href="me">
<link rel="author" href="me" fetchpriority="blah">
<link rel="DCTERMS.any" href="foo">

<meta name="content-disposition" content="any">
Expand Down
4 changes: 3 additions & 1 deletion validator/testdata/feature_tests/link_meta_values.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ FAIL
feature_tests/link_meta_values.html:15:2 The attribute 'rel' in tag 'link' is set to the invalid value 'manifest foo'. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/#html-tags)
| <link rel="preload" as="script" href="https://cdn.ampproject.org/v0.js">
| <link rel="shortcut icon" type="a" href="b" sizes="c">
| <link rel="author" href="me">
| <link rel="author" href="me" fetchpriority="blah">
>> ^~~~~~~~~
feature_tests/link_meta_values.html:18:2 The attribute 'fetchpriority' in tag 'link' is set to the invalid value 'blah'. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/#html-tags)
| <link rel="DCTERMS.any" href="foo">
|
| <meta name="content-disposition" content="any">
Expand Down
12 changes: 12 additions & 0 deletions validator/testdata/transformed_feature_tests/amp-img.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
</amp-img>

<!-- Valid: amp-img[layout=responsive] > i-amphtml-sizer[slot="i-amphtml-svc"] fetchpriority="high" -->
<amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" i-amphtml-ssr>
<i-amphtml-sizer slot="i-amphtml-svc" style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
<img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" fetchpriority="high">
</amp-img>

<!-- Invalid: amp-img[layout=intrinsic] > i-amphtml-sizer[slot!="i-amphtml-svc"] -->
<amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="intrinsic" width="900" height="600" i-amphtml-layout="intrinsic" i-amphtml-ssr>
<i-amphtml-sizer slot="asd" class="i-amphtml-sizer">
Expand Down Expand Up @@ -92,5 +98,11 @@
<i-amphtml-sizer slot style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
<img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
</amp-img>

<!-- Invalid: amp-img[layout=responsive] > i-amphtml-sizer[slot="i-amphtml-svc"] fetchpriority="bad" -->
<amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" fetchpriority="bad" i-amphtml-ssr>
<i-amphtml-sizer slot="i-amphtml-svc" style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
<img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
</amp-img>
</body>
</html>
22 changes: 18 additions & 4 deletions validator/testdata/transformed_feature_tests/amp-img.out
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ transformed_feature_tests/amp-img.html:45:4 The mandatory attribute 'class' is m
| <img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
| </amp-img>
|
| <!-- Valid: amp-img[layout=responsive] > i-amphtml-sizer[slot="i-amphtml-svc"] fetchpriority="high" -->
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" i-amphtml-ssr>
| <i-amphtml-sizer slot="i-amphtml-svc" style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
| <img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" fetchpriority="high">
| </amp-img>
|
| <!-- Invalid: amp-img[layout=intrinsic] > i-amphtml-sizer[slot!="i-amphtml-svc"] -->
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="intrinsic" width="900" height="600" i-amphtml-layout="intrinsic" i-amphtml-ssr>
| <i-amphtml-sizer slot="asd" class="i-amphtml-sizer">
>> ^~~~~~~~~
transformed_feature_tests/amp-img.html:70:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value 'asd'.
transformed_feature_tests/amp-img.html:76:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value 'asd'.
| <img alt aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;charset=utf-8,<svg height=&quot;600&quot; width=&quot;900&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot;/>">
| </i-amphtml-sizer>
| <img src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
Expand All @@ -86,15 +92,15 @@ transformed_feature_tests/amp-img.html:70:4 The attribute 'slot' in tag 'i-ampht
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" i-amphtml-ssr>
| <i-amphtml-sizer slot="asd" style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
>> ^~~~~~~~~
transformed_feature_tests/amp-img.html:78:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value 'asd'.
transformed_feature_tests/amp-img.html:84:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value 'asd'.
| <img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
| </amp-img>
|
| <!-- Invalid: amp-img[layout=intrinsic] > i-amphtml-sizer[slot] -->
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="intrinsic" width="900" height="600" i-amphtml-layout="intrinsic" i-amphtml-ssr>
| <i-amphtml-sizer slot class="i-amphtml-sizer">
>> ^~~~~~~~~
transformed_feature_tests/amp-img.html:84:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value ''.
transformed_feature_tests/amp-img.html:90:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value ''.
| <img alt aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;charset=utf-8,<svg height=&quot;600&quot; width=&quot;900&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot;/>">
| </i-amphtml-sizer>
| <img src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
Expand All @@ -104,7 +110,15 @@ transformed_feature_tests/amp-img.html:84:4 The attribute 'slot' in tag 'i-ampht
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" i-amphtml-ssr>
| <i-amphtml-sizer slot style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
>> ^~~~~~~~~
transformed_feature_tests/amp-img.html:92:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value ''.
transformed_feature_tests/amp-img.html:98:4 The attribute 'slot' in tag 'i-amphtml-sizer' is set to the invalid value ''.
| <img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
| </amp-img>
|
| <!-- Invalid: amp-img[layout=responsive] > i-amphtml-sizer[slot="i-amphtml-svc"] fetchpriority="bad" -->
| <amp-img src="/img/canoe_900x600.jpg" alt="An image about canoeing" layout="responsive" width="900" height="600" fetchpriority="bad" i-amphtml-ssr>
>> ^~~~~~~~~
transformed_feature_tests/amp-img.html:103:2 The attribute 'fetchpriority' in tag 'amp-img' is set to the invalid value 'bad'. (see https://amp.dev/documentation/components/amp-img/)
| <i-amphtml-sizer slot="i-amphtml-svc" style=display:block;padding-top:58.6667%;></i-amphtml-sizer>
| <img loading="lazy" src="/img/canoe_900x600.jpg" alt="An image about canoeing" class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async">
| </amp-img>
| </body>
Expand Down
24 changes: 24 additions & 0 deletions validator/validator-main.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ attr_lists: {
attrs: { name: "charset" value_casei: "utf-8" }
attrs: { name: "color" }
attrs: { name: "crossorigin" }
attrs: {
name: "fetchpriority"
value_casei: "high"
value_casei: "low"
value_casei: "auto"
}
attrs: { name: "hreflang" }
attrs: { name: "media" }
attrs: { name: "sizes" }
Expand Down Expand Up @@ -1801,6 +1807,12 @@ attr_lists: {
value_casei: "anonymous"
value_casei: "use-credentials"
}
attrs: {
name: "fetchpriority"
value_casei: "high"
value_casei: "low"
value_casei: "auto"
}
attrs: { name: "height" }
attrs: { name: "hspace" }
# https://developers.google.com/web/updates/2019/02/priority-hints
Expand Down Expand Up @@ -3982,6 +3994,12 @@ tags: { # <amp-img i-amphtml-ssr>
value_casei: "low"
value_casei: "auto"
}
attrs: {
name: "fetchpriority",
value_casei: "high"
value_casei: "low"
value_casei: "auto"
}
attrs: { name: "object-fit" }
attrs: { name: "object-position" }
attrs: { name: "placeholder" }
Expand Down Expand Up @@ -4190,6 +4208,12 @@ tags: {
attrs: { name: "attribution" }
attrs: { name: "height" }
# https://developers.google.com/web/updates/2019/02/priority-hints
attrs: {
name: "fetchpriority"
value_casei: "high"
value_casei: "low"
value_casei: "auto"
}
attrs: {
name: "importance"
value_casei: "high"
Expand Down

0 comments on commit 49ee0db

Please sign in to comment.