Skip to content

Commit

Permalink
Bug 1535765 [wpt PR 15779] - XMLSerializer: Keep redundant but harmle…
Browse files Browse the repository at this point in the history
…ss default namespace declarations, a=testonly

Automatic update from web-platform-tests
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: w3c/DOM-Parsing#47
Bug: 940204
Change-Id: I2978ddc9a3f9511d227a9a1b902f1811ac1c3c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1516124
Reviewed-by: Yoshifumi Inoue <yosinchromium.org>
Commit-Queue: Kent Tamura <tkentchromium.org>
Auto-Submit: Kent Tamura <tkentchromium.org>
Cr-Commit-Position: refs/heads/master{#639873}

--

wpt-commits: 4dc79803ad127fb635a03ec8b248c8671b4c3b67
wpt-pr: 15779

UltraBlame original commit: 41a76d86404be10336a61e3a8fbd86ac0aca467f
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 897d8a3 commit 175881e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ <h1>domparsing_XMLSerializer_serializeToString</h1>
assert_equals(serialize(root), '<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>');
}, 'Check if there is no redundant empty namespace declaration.');

test(function() {
assert_equals(serialize(parse('<root><child xmlns=""/></root>')),
'<root><child/></root>');
assert_equals(serialize(parse('<root xmlns=""><child xmlns=""/></root>')),
'<root><child/></root>');
assert_equals(serialize(parse('<root xmlns="u1"><child xmlns="u1"/></root>')),
'<root xmlns="u1"><child/></root>');
}, 'Check if redundant xmlns="..." is dropped.');

test(function() {
const root = parse('<root xmlns="uri1"/>');
const child = root.ownerDocument.createElement('child');
Expand Down Expand Up @@ -145,8 +154,6 @@ <h1>domparsing_XMLSerializer_serializeToString</h1>

test(function() {
assert_equals(serialize(parse('<root><child/></root>')), '<root><child/></root>');
assert_equals(serialize(parse('<root><child xmlns=""/></root>')), '<root><child/></root>');
assert_equals(serialize(parse('<root xmlns="u1"><child xmlns="u1"/></root>')), '<root xmlns="u1"><child/></root>');
assert_equals(serialize(parse('<root xmlns="u1"><p:child xmlns:p="u1"/></root>')), '<root xmlns="u1"><child xmlns:p="u1"/></root>');
}, 'Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace.');

Expand Down

0 comments on commit 175881e

Please sign in to comment.