Skip to content

Commit

Permalink
XMLSerializer: Fix prefix generation algorithm
Browse files Browse the repository at this point in the history
Fix it in order to match to DOM Parsing and Serialization specification.
We should not expose hash values of strings.

Bug: 928639
Change-Id: I589572d87715805961f2931c6808c1bd38acade6
Reviewed-on: https://chromium-review.googlesource.com/c/1454070
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629490}
  • Loading branch information
tkent-google authored and chromium-wpt-export-bot committed Feb 6, 2019
1 parent 71d0b28 commit d2c49d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions domparsing/XMLSerializer-serializeToString.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ <h1>domparsing_XMLSerializer_serializeToString</h1>
'<root attr="&#xD;"/>', '<root attr="&#13;"/>']);
}, 'check XMLSerializer.serializeToString escapes attribute values for roundtripping');

test(function() {
const input = '<root><child1/><child2/></root>';
const root = (new DOMParser()).parseFromString(input, 'text/xml').documentElement;
root.firstChild.setAttributeNS('uri1', 'attr1', 'value1');
root.firstChild.setAttributeNS('uri2', 'attr2', 'value2');
root.lastChild.setAttributeNS('uri3', 'attr3', 'value3');
const xmlString = (new XMLSerializer()).serializeToString(root);
assert_equals(xmlString, '<root><child1 xmlns:ns1="uri1" ns1:attr1="value1" xmlns:ns2="uri2" ns2:attr2="value2"/><child2 xmlns:ns3="uri3" ns3:attr3="value3"/></root>');
}, 'Check if generated prefixes match to "ns${index}".');

</script>
</body>
</html>

0 comments on commit d2c49d8

Please sign in to comment.