diff --git a/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html b/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html
index d71da494fe7d..ab373481204e 100644
--- a/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html
+++ b/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html
@@ -55,6 +55,22 @@ test(function() {
'', '']);
}, 'check XMLSerializer.serializeToString escapes attribute values for roundtripping');
+test(function() {
+ const root = (new Document()).createElement('root');
+ root.setAttributeNS('uri1', 'p:foobar', 'value1');
+ root.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:p', 'uri2');
+ const xmlString = (new XMLSerializer()).serializeToString(root);
+ assert_equals(xmlString, '');
+}, 'Check if attribute serialization takes into account of following xmlns:* attributes');
+
+test(function() {
+ const input = '';
+ const root = (new DOMParser()).parseFromString(input, 'text/xml').documentElement;
+ root.firstChild.setAttributeNS('uri2', 'p:foobar', 'v');
+ const xmlString = (new XMLSerializer()).serializeToString(root);
+ assert_equals(xmlString, '');
+}, 'Check if attribute serialization takes into account of the same prefix declared in an ancestor element');
+
test(function() {
const input = '';
const root = (new DOMParser()).parseFromString(input, 'text/xml').documentElement;