diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php
index 44f4507..60b6eb6 100644
--- a/core/modules/system/src/Tests/Theme/FunctionsTest.php
+++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php
@@ -13,6 +13,7 @@
 use Drupal\Core\Session\UserSession;
 use Drupal\Core\Url;
 use Drupal\simpletest\WebTestBase;
+use Masterminds\HTML5;
 
 /**
  * Tests for common theme functions.
@@ -344,13 +345,14 @@ function testDrupalPreRenderLinks() {
       ),
     );
 
+    $html5 = new HTML5();
+
     // Start with a fresh copy of the base array, and try rendering the entire
     // thing. We expect a single <ul> with appropriate links contained within
     // it.
     $render_array = $base_array;
     $html = \Drupal::service('renderer')->renderRoot($render_array);
-    $dom = new \DOMDocument();
-    $dom->loadHTML($html);
+    $dom = $html5->loadHTML($html);
     $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered HTML.');
     $list_elements = $dom->getElementsByTagName('li');
     $this->assertEqual($list_elements->length, 3, 'Three "li" tags found in the rendered HTML.');
@@ -367,16 +369,14 @@ function testDrupalPreRenderLinks() {
     $child_html = \Drupal::service('renderer')->renderRoot($render_array['first_child']);
     $parent_html = \Drupal::service('renderer')->renderRoot($render_array);
     // First check the child HTML.
-    $dom = new \DOMDocument();
-    $dom->loadHTML($child_html);
+    $dom = $html5->loadHTML($child_html);
     $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered child HTML.');
     $list_elements = $dom->getElementsByTagName('li');
     $this->assertEqual($list_elements->length, 2, 'Two "li" tags found in the rendered child HTML.');
     $this->assertEqual($list_elements->item(0)->nodeValue, 'Parent link copy', 'First expected link found.');
     $this->assertEqual($list_elements->item(1)->nodeValue, 'First child link', 'Second expected link found.');
     // Then check the parent HTML.
-    $dom = new \DOMDocument();
-    $dom->loadHTML($parent_html);
+    $dom = $html5->loadHTML($parent_html);
     $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered parent HTML.');
     $list_elements = $dom->getElementsByTagName('li');
     $this->assertEqual($list_elements->length, 2, 'Two "li" tags found in the rendered parent HTML.');
