It turns out that the bug also happens when Emacs is configured with the --without-xml2 option, so the test must be skipped in that case too. Updated patch attached.