Repository navigation
VideoPress: fix the age gate in the block editor - #51069
Merged
Merged
Conversation
The editor renders the player inside Gutenberg's SandBox, and an iframe's sandbox flags are inherited by every nested browsing context — including the videopress.com player frame that hosts the age gate. Without `allow-forms` the birth date submission was blocked, so "Continue" did nothing. Opt into the `allowForms` prop added in WordPress/gutenberg#76471. It is not in the @wordpress/components version this package builds against yet, so the component is widened locally to accept it; versions without the prop ignore it and the age gate stays as blocked as it is today. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`rating` was synced to the VideoPress API on save but was missing from `invalidateEmbedResolutionFields`, so `getEmbedPreview` kept serving the cached HTML with the old age gate. The gate only disappeared once another attribute that is on that list changed, or the page was reloaded. The rating is not part of the embed URL either, so — unlike `loop`, `autoplay` and friends — it had no implicit cache miss to fall back on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 2 files.
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #28375
Proposed changes
This issue was two independent bugs that presented as one. Both are fixed here.
1. The age gate's "Continue" button did nothing.
The editor renders the player inside Gutenberg's
SandBox, and an iframe'ssandboxflags are inherited by every nested browsing context — including thevideopress.complayer frame that hosts the age gate. Withoutallow-forms, the browser blocked the birth date submission outright:This was unfixable from Jetpack until WordPress/gutenberg#76471 added an
allowFormsprop toSandBox. That PR is merged but not yet released, soSandBoxWithFormswidens the component type locally to accept the prop. Module augmentation is not an option here —SandBoxPropsis not re-exported from@wordpress/components' root and./sandboxis not in the packageexportsmap. Older versions ignore the unknown prop, so the age gate simply stays as blocked as it is today until the bundled version catches up. The comment on that cast says to delete it and passallowFormsdirectly once it does.2. Lowering a video's rating left the age gate on screen.
use-sync-mediakeeps two parallel field lists:videoFieldsToUpdate(pushed to the VideoPress API on save) andinvalidateEmbedResolutionFields(triggersinvalidateResolution( 'getEmbedPreview', … )).ratingwas in the first and missing from the second, so the API took the new rating — a page reload showed the correct state — while the cached oEmbed preview kept serving HTML with the gate baked in. That also explains the original report that changing any other video attribute cleared it:title,privacy_setting,allow_downloadanddisplay_embedare all on the invalidation list.Worth noting for reviewers: the comment above that list mentions some fields are "handled indirectly by the VideoPress video URL". That is true for
loop,autoplay,colorand friends, whichgetVideoPressUrlputs in the query string so a change produces a different URL and misses the cache naturally.ratingis not one of its args, so it had no implicit invalidation to fall back on — hence the explicit list entry rather than a URL change.Related product discussion/links
allowFormsprop this depends on.Does this pull request change what data or activity we track or use?
No.
Testing instructions
Fix 1 requires the Gutenberg plugin on
trunk(or any build including gutenberg#76471). Without it the prop is silently ignored and the age gate stays blocked — that is the intended graceful degradation, not a regression.Set up a video whose rating requires an age check:
Verify the form submits:
trunktoday it does nothing.iframe.components-sandboxin the editor canvas. Itssandboxattribute should now readallow-scripts allow-same-origin allow-presentation allow-forms.Verify the gate goes away when the rating is lowered:
Automated coverage:
jp test js packages/videopress— 642 tests pass. The new cases are "allows form submission so the age gate birth date can be sent" and, inuse-sync-media, "refreshes the player when the rating changes" plus a negative control asserting fields the embed does not depend on do not trigger a refresh.