-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Bento: Validate Facebook components #35395
Conversation
Hey @ampproject/wg-caching! These files were changed:
|
| layout="responsive" | ||
| data-href="https://www.facebook.com/zuck/posts/10102593740125791"> | ||
| </amp-facebook> | ||
| <!-- Example of a valid amp-facebook-comments --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you intend for this to be valid? You may want to add the extension script in that case.
Same question for a few of the other tests below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example, amp-facebook-comments
, amp-facebook-like
, and amp-facebook-page
are all registered by the one amp-facebook
script included. As long as amp-facebook-1.0
is being used, all four components should have valid use. Is that possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, this is what I was having trouble expressing in this PR:
- The script inclusion is not exclusive after applying
satisfies
/excludes
, as can be seen with the passing cases that should be failing inextensions/amp-facebook/1.0/test/validator-amp-facebook-exclusive.html
- Use of the
amp-facebook-*
components is not valid with theamp-facebook-1.0.js
script alone -- it appears to be running into therequires_extension
line, i.e.:
requires_extension: "amp-facebook-page"
I assume there's not such a thing asrequires_extension_oneof
like we have with other properties? Example test file that should pass but fails:extensions/amp-facebook/1.0/test/validator-amp-facebook-page.out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see now. I'm not 100% sure this'll work without running the tests, but can you define two amp-facebook-comments
tagspecs, one requiring each extension but otherwise identical?
To reduce duplication a tiny bit, you can use a named attr_list with all of the attrs in it which you then include in both tagspecs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this recommendation! It looks like your recommendation, plus giving the 1.0
script a spec_name
and requiring by that, did the trick for the second bullet point above (allowing amp-facebook-*
to be used when importing amp-facebook:1.0
). I added more tests to verify also that importing 0.1 does not work, but it helped me to notice that the secondary tag spec obscures the validation message for amp-facebook-*
, which might normally recommend importing the script corresponding to the tag in use. Instead the invalid message shows:
The tag 'amp-facebook 1.0' is missing or incorrect, but required by 'amp-facebook-page'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to give the different tagspecs spec_name
s now that there are more than one tag_spec for each of the tag names like amp-facebook-comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this recommendation! Adding spec_name
now suffices for the other bullet point above (exclusion between tags).
As for the "obscured message", the more I think about it, the more I settle on the perspective that it is WAI. In that case things are all set for review. :) Thank you again for all your patience and wisdom here 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion for a few comments to toss in, but otherwise looks good.
mandatory: true | ||
} | ||
requires: "amp-facebook-comments 0.1" | ||
attr_lists: "amp-facebook" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest leaving a comment for the reader on where to find this list, since it's in a different file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
html_format: AMP | ||
tag_name: "SCRIPT" | ||
spec_name: "amp-facebook 1.0" | ||
satisfies: "amp-facebook 1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good place to leave a comment for the reader on what this scheme is trying to do, maybe even just linking to the discussion in this PR as sufficient. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, linked this PR and a brief explanation.Thanks for the recommendation
After looking at how the changes here relate to the AMP-WP plugin, I have a question about how this might impact extension auto-importing. Namely, if someone adds a |
This is a good question. The In terms of the qualitative difference between 0.1 and 1.0 for Another consideration too is that the |
I think the difference between these Facebook components and amphtml/extensions/amp-facebook-comments/validator-amp-facebook-comments.protoascii Lines 29 to 45 in d21ecc0
And only consider this one: amphtml/extensions/amp-facebook/validator-amp-facebook.protoascii Lines 66 to 82 in d21ecc0
The metadata to do so seems a bit fuzzy however. |
In short, we'll have to merge |
You're saying there needs to be more metadata to assist the Optimizer in doing this, right? Whether that be having another file that contains just the known metadata (e.g. when bento don't use this spec_name, use this one instead) or add a metadata identifier within the validator.proto to be used in the rules just for bento and for the optimizer (e.g. is_bento: true, defaults to false). |
Right. Basically, when there are two different tag specs that look the same except they have differences in the I was able to work out a way to do so by using the It seems it would be useful if there was an amphtml/extensions/amp-facebook/validator-amp-facebook.protoascii Lines 18 to 35 in d21ecc0
This would prevent us from having to consult |
This PR introduces validations for the 1.0 versions of
amp-facebook
,amp-facebook-comments
,amp-facebook-like
, andamp-facebook-page
, all of which are provided by theamp-facebook-1.0.js
extension script.In particular we want to guard for the following cases:
amp-facebook(-*)
tags is valid with inclusion of anamp-facebook-1.0.js
scriptamp-facebook(-*)
tags other thanamp-facebook
is invalid if onlyamp-facebook-0.1.js
script is included (they must include their corresponding 0.1 script if not that amp-facebook-1.0.js script)amp-facebook-*-0.1.js
extension scripts can be used on the same document as theamp-facebook-1.0.js
scriptContinuation from #35064 for the validator change discussions.