forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validator rules/test for amp-action-macro (ampproject#20928)
- Loading branch information
1 parent
12c14b1
commit 9898e57
Showing
3 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
extensions/amp-action-macro/validator-amp-action-macro.protoascii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright 2019 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. | ||
# | ||
tags: { # amp-action-macro | ||
html_format: AMP | ||
html_format: ACTIONS | ||
tag_name: "SCRIPT" | ||
extension_spec: { | ||
name: "amp-action-macro" | ||
version: "0.1" | ||
version: "latest" | ||
} | ||
attr_lists: "common-extension-attrs" | ||
} | ||
tags: { # <amp-action-macro> | ||
html_format: AMP | ||
html_format: ACTIONS | ||
tag_name: "AMP-ACTION-MACRO" | ||
requires_extension: "amp-action-macro" | ||
attrs: { | ||
name: "arguments" | ||
} | ||
attrs: { | ||
name: "execute" | ||
mandatory: true | ||
} | ||
attr_lists: "mandatory-id-attr" | ||
spec_url: "https://www.ampproject.org/docs/reference/components/amp-action-macro" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!-- | ||
Copyright 2019 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. | ||
--> | ||
<!doctype html> | ||
<html ⚡> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link rel="canonical" href="./regular-html-version.html" /> | ||
<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 custom-element="amp-action-macro" src="https://cdn.ampproject.org/v0/amp-action-macro-0.1.js"></script> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<style amp-custom> | ||
.red { | ||
color: red; | ||
} | ||
.green { | ||
color: green; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<!-- Valid --> | ||
<amp-action-macro id="action-macro-id" execute="amp-component.doSomething()"> | ||
</amp-action-macro> | ||
|
||
<!-- Valid, optional arguments --> | ||
<amp-action-macro id="action-macro-id" execute="amp-component.doSomething(foo=x,bar=y)" | ||
arguments="x,y"> | ||
</amp-action-macro> | ||
|
||
<!-- Invalid, requires ID --> | ||
<amp-action-macro execute="amp-component.doSomething()"> | ||
</amp-action-macro> | ||
|
||
<!-- Invalid, requires execute --> | ||
<amp-action-macro id="action-macro-id"> | ||
</amp-action-macro> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
FAIL | ||
| <!-- | ||
| Copyright 2019 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. | ||
| --> | ||
| <!doctype html> | ||
| <html ⚡> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <link rel="canonical" href="./regular-html-version.html" /> | ||
| <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 custom-element="amp-action-macro" src="https://cdn.ampproject.org/v0/amp-action-macro-0.1.js"></script> | ||
| <script async src="https://cdn.ampproject.org/v0.js"></script> | ||
| <style amp-custom> | ||
| .red { | ||
| color: red; | ||
| } | ||
| .green { | ||
| color: green; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| | ||
| <!-- Valid --> | ||
| <amp-action-macro id="action-macro-id" execute="amp-component.doSomething()"> | ||
| </amp-action-macro> | ||
| | ||
| <!-- Valid, optional arguments --> | ||
| <amp-action-macro id="action-macro-id" execute="amp-component.doSomething(foo=x,bar=y)" | ||
| arguments="x,y"> | ||
| </amp-action-macro> | ||
| | ||
| <!-- Invalid, requires ID --> | ||
| <amp-action-macro execute="amp-component.doSomething()"> | ||
>> ^~~~~~~~~ | ||
feature_tests/amp-action-macro.html:46:2 The mandatory attribute 'id' is missing in tag 'amp-action-macro'. (see https://www.ampproject.org/docs/reference/components/amp-action-macro) [AMP_TAG_PROBLEM] | ||
| </amp-action-macro> | ||
| | ||
| <!-- Invalid, requires execute --> | ||
| <amp-action-macro id="action-macro-id"> | ||
>> ^~~~~~~~~ | ||
feature_tests/amp-action-macro.html:50:2 The mandatory attribute 'execute' is missing in tag 'amp-action-macro'. (see https://www.ampproject.org/docs/reference/components/amp-action-macro) [AMP_TAG_PROBLEM] | ||
| </amp-action-macro> | ||
| | ||
| </body> | ||
| </html> | ||
|