+
diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php
new file mode 100644
index 0000000000..1cd9bb40fb
--- /dev/null
+++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php
@@ -0,0 +1,59 @@
+ static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
+ $rect = array(
+ 'width' => 500.1,
+ 'height' => 500.2,
+ 'x' => 100.3,
+ 'y' => 100.4,
+ 'top' => 0.1,
+ 'right' => 0.2,
+ 'bottom' => 0.3,
+ 'left' => 0.4,
+ );
+ $test_case->populate_url_metrics(
+ array(
+ array(
+ 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
+ 'isLCP' => true,
+ 'intersectionRatio' => 1,
+ // Intentionally omitting resizedBoundingClientRect here to test behavior when data isn't supplied.
+ ),
+ )
+ );
+ },
+ 'buffer' => '
+
+
+
+
...
+
+
+
+
+
+ ',
+ 'expected' => '
+
+
+
+
...
+
+
+
+
+
+
+
+ ',
+);
diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php
index 1336dcfcbd..63968e9758 100644
--- a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php
+++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php
@@ -1,12 +1,23 @@
static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
+ $rect = array(
+ 'width' => 500.1,
+ 'height' => 500.2,
+ 'x' => 100.3,
+ 'y' => 100.4,
+ 'top' => 0.1,
+ 'right' => 0.2,
+ 'bottom' => 0.3,
+ 'left' => 0.4,
+ );
$test_case->populate_url_metrics(
array(
array(
- 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]',
- 'isLCP' => true,
- 'intersectionRatio' => 1,
+ 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
+ 'isLCP' => true,
+ 'intersectionRatio' => 1,
+ 'resizedBoundingClientRect' => array_merge( $rect, array( 'height' => 500 ) ),
),
)
);
@@ -32,11 +43,17 @@
...
+
-