From dfc064d4e4b4ef810b0d1044225658400f76f4a7 Mon Sep 17 00:00:00 2001 From: Kent Tamura Date: Tue, 12 Mar 2019 03:23:08 -0700 Subject: [PATCH] XMLSerializer: Keep redundant but harmless default namespace declarations Since crrev.com/632142, XMLSerializer has dropped redundant xmlns="..." declarations. It matches to IE, Edge, and DOM P&S standard. This CL reverts the behavior to unbreak existing applications. The restored behavior matches to Firefox and Safari. * MarkupAccumulator::AppendElement(): Even if ignore_namespace_definition_attribute_ is set, we drop a xmlns="..." only if its value is inconsistent with element's namespace. * MarkupAccumulator::AppendStartTagOpen(): if local_default_namespace is "" and ns is null, do not emit xmlns="". This avoids to serialize xmlns="" twice. Bug: https://github.com/w3c/DOM-Parsing/issues/47 Bug: 940204 Change-Id: I2978ddc9a3f9511d227a9a1b902f1811ac1c3c07 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1516124 Reviewed-by: Yoshifumi Inoue Commit-Queue: Kent Tamura Auto-Submit: Kent Tamura Cr-Commit-Position: refs/heads/master@{#639873} --- domparsing/XMLSerializer-serializeToString.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/domparsing/XMLSerializer-serializeToString.html b/domparsing/XMLSerializer-serializeToString.html index 81df61f5bc4288..cb8ed9372df5e0 100644 --- a/domparsing/XMLSerializer-serializeToString.html +++ b/domparsing/XMLSerializer-serializeToString.html @@ -45,6 +45,15 @@

domparsing_XMLSerializer_serializeToString

assert_equals(serialize(root), 'value1'); }, 'Check if there is no redundant empty namespace declaration.'); +test(function() { + assert_equals(serialize(parse('')), + ''); + assert_equals(serialize(parse('')), + ''); + assert_equals(serialize(parse('')), + ''); +}, 'Check if redundant xmlns="..." is dropped.'); + test(function() { const root = parse(''); const child = root.ownerDocument.createElement('child'); @@ -145,8 +154,6 @@

domparsing_XMLSerializer_serializeToString

test(function() { assert_equals(serialize(parse('')), ''); - assert_equals(serialize(parse('')), ''); - assert_equals(serialize(parse('')), ''); assert_equals(serialize(parse('')), ''); }, 'Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace.');