Index: tests/phpunit/tests/formatting/Autop.php
===================================================================
--- tests/phpunit/tests/formatting/Autop.php	(revision 39562)
+++ tests/phpunit/tests/formatting/Autop.php	(working copy)
@@ -534,4 +534,27 @@
 
 		$this->assertEquals( $expected, trim( wpautop( $content ) ) );
 	}
+
+	/**
+	 * wpautop() should add an extra </p>
+	 *
+	 * "<div><span></span></p>
+	 *    <div></div>
+	 *    </div>
+	 *    "
+	 * @covers ::wpautop
+	 * @uses trim
+	 *
+	 * @ticket 39377
+	 */
+	function test_that_wpautop_doses_not_extra_closing_p_in_figure() {
+		$content = '<figure><img src="/wp-content/uploads/example.jpg" alt="something" /><figcaption>Caption</figcaption></figure>';
+
+		$expected = '<figure><img src="/wp-content/uploads/example.jpg" alt="something" />
+<figcaption>Caption</figcaption>
+</figure>';
+
+		$this->assertEquals( $expected, trim( wpautop( $content ) ) );
+	}
+
 }
