From 68e287b5269ed956e8e7694b1e8da5ab478458df Mon Sep 17 00:00:00 2001 From: Greg Grothaus Date: Wed, 13 Apr 2016 17:26:08 -0700 Subject: [PATCH] Validator Roll-up (#2903) * Rename AMP_MUSTACHE_TEMPLATE_PROBLEM -> AMP_HTML_TEMPLATE_PROBLEM. * Allow filtering by error category. * Relax validation of mustache template layout attributes. * Update `` to rename `direction` attr to `side` and require `nodisplay` layout. --- .../0.1/test/validator-amp-mustache.html | 9 +++ .../0.1/test/validator-amp-mustache.out | 70 +++++++++---------- .../0.1/test/validator-amp-sidebar.html | 8 +-- .../0.1/test/validator-amp-sidebar.out | 4 +- .../0.1/validator-amp-sidebar.protoascii | 10 ++- validator/validator-in-browser.js | 4 +- validator/validator-main.protoascii | 2 +- validator/validator.js | 50 +++++++++++-- validator/validator.proto | 8 ++- 9 files changed, 106 insertions(+), 59 deletions(-) diff --git a/extensions/amp-mustache/0.1/test/validator-amp-mustache.html b/extensions/amp-mustache/0.1/test/validator-amp-mustache.html index 3370ea9849c6..002ddf555adf 100644 --- a/extensions/amp-mustache/0.1/test/validator-amp-mustache.html +++ b/extensions/amp-mustache/0.1/test/validator-amp-mustache.html @@ -108,5 +108,14 @@ + + + + + + diff --git a/extensions/amp-mustache/0.1/test/validator-amp-mustache.out b/extensions/amp-mustache/0.1/test/validator-amp-mustache.out index 765f75d31b26..350871b433bf 100644 --- a/extensions/amp-mustache/0.1/test/validator-amp-mustache.out +++ b/extensions/amp-mustache/0.1/test/validator-amp-mustache.out @@ -1,38 +1,38 @@ FAIL -amp-mustache/0.1/test/validator-amp-mustache.html:34:2 Mustache template syntax in attribute name '{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:35:2 Mustache template syntax in attribute name '{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:34:2 Mustache template syntax in attribute name '{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:35:2 Mustache template syntax in attribute name '{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] amp-mustache/0.1/test/validator-amp-mustache.html:36:2 The attribute 'data-{notallowed}' may not appear in tag 'p'. [DISALLOWED_HTML] -amp-mustache/0.1/test/validator-amp-mustache.html:37:2 Mustache template syntax in attribute name 'data-{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:38:2 Mustache template syntax in attribute name 'data-{{{notallowed}}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:39:2 Mustache template syntax in attribute name 'data-{{¬allowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:40:2 Mustache template syntax in attribute name 'data-{{#notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:41:2 Mustache template syntax in attribute name 'data-{{/notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:42:2 Mustache template syntax in attribute name 'data-{{^notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:43:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:44:2 Mustache template syntax in attribute name '{{#notallowed}}class' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:45:2 Mustache template syntax in attribute name '{{#notallowed}}class{{/notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:46:2 The attribute 'title' in tag 'p' is set to '{{{notallowed}}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:47:2 The attribute 'title' in tag 'p' is set to '{{¬allowed}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:48:2 The attribute 'title' in tag 'p' is set to '{{>notallowed}}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:53:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:54:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:55:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:56:2 Mustache template syntax in attribute name 'data-{{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:57:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:58:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:59:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:60:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:61:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:62:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:63:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:64:2 The attribute 'title' in tag 'p' is set to '{{{ notallowed }}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:65:2 The attribute 'title' in tag 'p' is set to '{{ ¬allowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:66:2 The attribute 'title' in tag 'p' is set to '{{ >notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:67:2 The attribute 'title' in tag 'p' is set to '{{& notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:68:2 The attribute 'title' in tag 'p' is set to '{{> notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:69:2 The attribute 'title' in tag 'p' is set to '{{ & notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:70:2 The attribute 'title' in tag 'p' is set to '{{ > notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:95:4 The tag 'template' may not appear as a descendant of tag 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_MUSTACHE_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:37:2 Mustache template syntax in attribute name 'data-{{notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:38:2 Mustache template syntax in attribute name 'data-{{{notallowed}}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:39:2 Mustache template syntax in attribute name 'data-{{¬allowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:40:2 Mustache template syntax in attribute name 'data-{{#notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:41:2 Mustache template syntax in attribute name 'data-{{/notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:42:2 Mustache template syntax in attribute name 'data-{{^notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:43:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:44:2 Mustache template syntax in attribute name '{{#notallowed}}class' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:45:2 Mustache template syntax in attribute name '{{#notallowed}}class{{/notallowed}}' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:46:2 The attribute 'title' in tag 'p' is set to '{{{notallowed}}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:47:2 The attribute 'title' in tag 'p' is set to '{{¬allowed}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:48:2 The attribute 'title' in tag 'p' is set to '{{>notallowed}}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:53:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:54:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:55:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:56:2 Mustache template syntax in attribute name 'data-{{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:57:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:58:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:59:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:60:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:61:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:62:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:63:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:64:2 The attribute 'title' in tag 'p' is set to '{{{ notallowed }}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:65:2 The attribute 'title' in tag 'p' is set to '{{ ¬allowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:66:2 The attribute 'title' in tag 'p' is set to '{{ >notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:67:2 The attribute 'title' in tag 'p' is set to '{{& notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:68:2 The attribute 'title' in tag 'p' is set to '{{> notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:69:2 The attribute 'title' in tag 'p' is set to '{{ & notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:70:2 The attribute 'title' in tag 'p' is set to '{{ > notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:95:4 The tag 'template' may not appear as a descendant of tag 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM] amp-mustache/0.1/test/validator-amp-mustache.html:107:0 The attribute 'autoplay' in tag 'amp-audio' is set to the invalid value '{{invalid}}'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:112:7 The tag 'amp-audio extension .js script' is missing or incorrect, but required by 'amp-audio'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM] -amp-mustache/0.1/test/validator-amp-mustache.html:112:7 The tag 'amp-mustache extension .js script' is missing or incorrect, but required by 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_TAG_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:121:7 The tag 'amp-audio extension .js script' is missing or incorrect, but required by 'amp-audio'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM] +amp-mustache/0.1/test/validator-amp-mustache.html:121:7 The tag 'amp-mustache extension .js script' is missing or incorrect, but required by 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_TAG_PROBLEM] diff --git a/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.html b/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.html index 70735990b094..783a0b264e1c 100644 --- a/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.html +++ b/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.html @@ -32,7 +32,7 @@ - +

Section 1

@@ -47,10 +47,10 @@

Section 2

- + - - + + diff --git a/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.out b/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.out index a48a96c756b0..a22da294abe7 100644 --- a/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.out +++ b/extensions/amp-sidebar/0.1/test/validator-amp-sidebar.out @@ -1,4 +1,4 @@ FAIL -amp-sidebar/0.1/test/validator-amp-sidebar.html:50:2 The tag 'amp-sidebar' appears more than once in the document. [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT] +amp-sidebar/0.1/test/validator-amp-sidebar.html:50:2 The tag 'amp-sidebar' appears more than once in the document. (see https://github.com/ampproject/amphtml/blob/master/extensions/amp-sidebar/amp-sidebar.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT] amp-sidebar/0.1/test/validator-amp-sidebar.html:51:4 The tag 'amp-ad' may not appear as a descendant of tag 'amp-sidebar'. (see https://www.ampproject.org/docs/reference/amp-ad.html) [AMP_TAG_PROBLEM] -amp-sidebar/0.1/test/validator-amp-sidebar.html:54:2 The attribute 'direction' in tag 'amp-sidebar' is set to the invalid value 'center'. [AMP_TAG_PROBLEM] +amp-sidebar/0.1/test/validator-amp-sidebar.html:54:2 The attribute 'side' in tag 'amp-sidebar' is set to the invalid value 'center'. (see https://github.com/ampproject/amphtml/blob/master/extensions/amp-sidebar/amp-sidebar.md) [AMP_TAG_PROBLEM] diff --git a/extensions/amp-sidebar/0.1/validator-amp-sidebar.protoascii b/extensions/amp-sidebar/0.1/validator-amp-sidebar.protoascii index 0e06b726c086..7969ac156cdd 100644 --- a/extensions/amp-sidebar/0.1/validator-amp-sidebar.protoascii +++ b/extensions/amp-sidebar/0.1/validator-amp-sidebar.protoascii @@ -44,8 +44,7 @@ tags: { # amp-sidebar error_message: "contents" } } - # Uncomment once reference is available. - # spec_url: "https://www.ampproject.org/docs/reference/extended/amp-sidebar.html" + spec_url: "https://www.ampproject.org/docs/reference/extended/amp-sidebar.html" } tags: { # tag_name: "amp-sidebar" @@ -55,13 +54,12 @@ tags: { # disallowed_ancestor: "amp-sidebar" also_requires: "amp-sidebar extension .js script" attrs: { - name: "direction" + name: "side" value_regex: "(left|right)" } attr_lists: "extended-amp-global" - # Uncomment once reference is available. - # spec_url: "https://github.com/ampproject/amphtml/blob/master/extensions/amp-sidebar/amp-sidebar.md" + spec_url: "https://github.com/ampproject/amphtml/blob/master/extensions/amp-sidebar/amp-sidebar.md" amp_layout: { - supported_layouts: CONTAINER + supported_layouts: NODISPLAY } } diff --git a/validator/validator-in-browser.js b/validator/validator-in-browser.js index 51d65f326c95..5ebdef19a0fe 100644 --- a/validator/validator-in-browser.js +++ b/validator/validator-in-browser.js @@ -129,9 +129,11 @@ amp.validator.validateInBrowser = function(doc) { * and https://github.com/ampproject/amphtml/blob/master/src/validator-integration.js * @param {string} url * @param {!Document=} opt_doc + * @param {!string=} opt_errorCategoryFilter * @export */ -amp.validator.validateUrlAndLog = function(url, opt_doc) { +amp.validator.validateUrlAndLog = function( + url, opt_doc, opt_errorCategoryFilter) { getUrl(url).then( function(html) { // Success const validationResult = amp.validator.validateString(html); diff --git a/validator/validator-main.protoascii b/validator/validator-main.protoascii index eff4e0f213b8..b70828c18710 100644 --- a/validator/validator-main.protoascii +++ b/validator/validator-main.protoascii @@ -25,7 +25,7 @@ min_validator_revision_required: 112 # newer versions of the spec file. This is currently a Google internal # mechanism, validator.js does not use this facility. However, any # change to this file (validator-main.js) requires updating this revision id. -spec_file_revision: 207 +spec_file_revision: 208 # Validator extensions. # ===================== diff --git a/validator/validator.js b/validator/validator.js index 9c5986eef82d..96ac7238b213 100644 --- a/validator/validator.js +++ b/validator/validator.js @@ -331,21 +331,46 @@ amp.validator.Terminal = class { * errors. * @param {string} url * @param {!amp.validator.Terminal=} opt_terminal + * @param {!string=} opt_errorCategoryFilter */ amp.validator.ValidationResult.prototype.outputToTerminal = - function(url, opt_terminal) { + function(url, opt_terminal, opt_errorCategoryFilter) { const terminal = opt_terminal || new amp.validator.Terminal(); + const errorCategoryFilter = opt_errorCategoryFilter || null; + const status = this.status; if (status === amp.validator.ValidationResult.Status.PASS) { terminal.info('AMP validation successful.'); - } else if (status === amp.validator.ValidationResult.Status.FAIL) { - terminal.error('AMP validation had errors:'); - } else { + return; + } + if (status !== amp.validator.ValidationResult.Status.FAIL) { terminal.error( 'AMP validation had unknown results. This should not happen.'); + return; + } + let errors; + if (errorCategoryFilter === null) { + terminal.error('AMP validation had errors:'); + errors = this.errors; + } else { + errors = []; + for (const error of this.errors) { + if (amp.validator.categorizeError(error) === errorCategoryFilter) { + errors.push(error); + } + } + if (errors.length === 0) { + terminal.error('AMP validation - no errors matching ' + + 'error_category_filter=' + errorCategoryFilter + ' found. ' + + 'To see all errors, visit ' + url + '#development=1'); + } else { + terminal.error('AMP validation - displaying errors matching ' + + 'error_category_filter=' + errorCategoryFilter + '. ' + + 'To see all errors, visit ' + url + '#development=1'); + } } - for (const error of this.errors) { + for (const error of errors) { if (error.severity === amp.validator.ValidationError.Severity.ERROR) { terminal.error(errorLine(url, error)); @@ -2056,6 +2081,17 @@ class ParsedTagSpec { const sizesAttr = attrsByKey.get('sizes'); const heightsAttr = attrsByKey.get('heights'); + // We disable validating layout for tags where one of the layout attributes + // contains mustache syntax. + const hasTemplateAncestor = context.getTagStack().hasAncestor('template'); + if (hasTemplateAncestor && + (ParsedTagSpec.valueHasTemplateSyntax(layoutAttr) || + ParsedTagSpec.valueHasTemplateSyntax(widthAttr) || + ParsedTagSpec.valueHasTemplateSyntax(heightAttr) || + ParsedTagSpec.valueHasTemplateSyntax(sizesAttr) || + ParsedTagSpec.valueHasTemplateSyntax(heightsAttr))) + return; + // Parse the input layout attributes which we found for this tag. const inputLayout = parseLayout(layoutAttr); if (layoutAttr !== undefined && @@ -3347,7 +3383,7 @@ amp.validator.categorizeError = function(error) { TEMPLATE_PARTIAL_IN_ATTR_VALUE || error.code === amp.validator.ValidationError.Code. TEMPLATE_IN_ATTR_NAME) { - return amp.validator.ErrorCategory.Code.AMP_MUSTACHE_TEMPLATE_PROBLEM; + return amp.validator.ErrorCategory.Code.AMP_HTML_TEMPLATE_PROBLEM; } // E.g. "The tag 'amp-ad' may not appear as a descendant of tag 'amp-sidebar'. if (error.code === amp.validator.ValidationError.Code @@ -3358,7 +3394,7 @@ amp.validator.categorizeError = function(error) { if (error.code === amp.validator.ValidationError.Code .DISALLOWED_TAG_ANCESTOR && (error.params[1] === "template")) { - return amp.validator.ErrorCategory.Code.AMP_MUSTACHE_TEMPLATE_PROBLEM; + return amp.validator.ErrorCategory.Code.AMP_HTML_TEMPLATE_PROBLEM; } // E.g. "Missing URL for attribute 'href' in tag 'a'." // E.g. "Invalid URL protocol 'http:' for attribute 'src' in tag diff --git a/validator/validator.proto b/validator/validator.proto index 02966a57e156..f7fbf977a6f4 100644 --- a/validator/validator.proto +++ b/validator/validator.proto @@ -351,9 +351,11 @@ message ErrorCategory { // a given AMP element, and responsiveness. // https://github.com/ampproject/amphtml/blob/master/spec/amp-html-layout.md AMP_LAYOUT_PROBLEM = 8; - // AMP supports Mustache templates; the validator generates errors - // for misplaced template syntax. - AMP_MUSTACHE_TEMPLATE_PROBLEM = 9; + // AMP supports the HTML template tag (e.g. within amp-list) and interprets + // Mustache syntax within such templates. To help with debugging, the AMP + // Validator generates errors for misplaced Mustache template syntax. + // https://github.com/ampproject/amphtml/blob/master/spec/amp-html-templates.md + AMP_HTML_TEMPLATE_PROBLEM = 9; // This is currently still allowed but may soon be disallowed. Usually // a recommendation for a replacement is rendered as part of the error. DEPRECATION = 10;