Skip to content
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

Add 'data-amp-auto-lightbox-disable' attribute to HTML tag instead of body tag to disable auto-lightbox #7097

Merged
merged 4 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class AMP_Auto_Lightbox_Disable_Sanitizer extends AMP_Base_Sanitizer {
* @return void
*/
public function sanitize() {
$this->dom->body->setAttributeNode( $this->dom->createAttribute( 'data-amp-auto-lightbox-disable' ) );
$this->dom->html->setAttributeNode( $this->dom->createAttribute( 'data-amp-auto-lightbox-disable' ) );
}
}
2 changes: 2 additions & 0 deletions tests/e2e/specs/block-editor/featured-image-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ describe( 'Featured Image Notice', () => {

// This should not suggest cropping.
await expect( page ).not.toMatch( cropImageText );

await clickButton( 'Featured image' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the E2E test failure a fluke? It doesn't seem that adding this click here should do anything since it is done in beforeEach anyway and there are no expectations in this test.

} );

it( 'should display a notice when the image is too small, but not suggest cropping', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function test_sanitize() {
$sanitizer = new AMP_Auto_Lightbox_Disable_Sanitizer( $dom );
$sanitizer->sanitize();

$this->assertTrue( $dom->body->hasAttribute( 'data-amp-auto-lightbox-disable' ) );
$this->assertTrue( $dom->html->hasAttribute( 'data-amp-auto-lightbox-disable' ) );
}
}
2 changes: 1 addition & 1 deletion tests/php/test-class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ public function test_prepare_response_standard_mode_non_amp( $with_amp_live_list

$sanitized_html = AMP_Theme_Support::prepare_response( $original_html, [ ConfigurationArgument::ENABLE_OPTIMIZER => false ] );

$this->assertStringContainsString( '<html>', $sanitized_html, 'The AMP attribute is removed from the HTML element' );
$this->assertDoesNotMatchRegularExpression( '/<html[^>]*[\s]amp[^>]*>/', $sanitized_html, 'The AMP attribute is removed from the HTML element' );
$this->assertStringContainsString( '<button onclick="alert', $sanitized_html, 'Invalid AMP is present in the response.' );
if ( $with_amp_live_list ) {
$this->assertStringContainsString( 'document.write = function', $sanitized_html, 'Override of document.write() is present.' );
Expand Down