зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1527283 [wpt PR 15340] - XMLSerializer: Fix prefixed attribute serialization, a=testonly
Automatic update from web-platform-tests XMLSerializer: Fix prefixed attribute serialization ... in a case where its owner element has xmlns:prefix of which prefix is same as the attribute and namespace is not same as the attribute. e.g. el.setAttributeNS("uri1", "p:n", "v"); el.setAttributeNS(XMLNS_URI, "xmlns:p", "uri2"); ShouldAddNamespaceAttribute() checked only existence of xmlns:prefix in the element, but we should check existence of (prefix, namespace URI) pair in the scope according to the specification. So, this CL adds 'recording the namespace information' step [1] defined by the specification, and ShouldAddNamespaceAttribute() checks all available prefixes in the scope. [1] https://w3c.github.io/DOM-Parsing/#recording-the-namespace Bug: 929035 Change-Id: I575e8f652ae45f7583202443cc72d5afe5faf59d Reviewed-on: https://chromium-review.googlesource.com/c/1460643 Reviewed-by: Yoshifumi Inoue <yosin@chromium.org> Commit-Queue: Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/master@{#631058} -- wpt-commits: 265330b7d26194cb60157a18ac399127d21f6b99 wpt-pr: 15340
This commit is contained in:
Родитель
27a492ca22
Коммит
456e3e6451
|
@ -55,6 +55,22 @@ test(function() {
|
|||
'<root attr="
"/>', '<root attr=" "/>']);
|
||||
}, '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, '<root xmlns:ns1="uri1" ns1:foobar="value1" xmlns:p="uri2"/>');
|
||||
}, 'Check if attribute serialization takes into account of following xmlns:* attributes');
|
||||
|
||||
test(function() {
|
||||
const input = '<root xmlns:p="uri1"><child/></root>';
|
||||
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, '<root xmlns:p="uri1"><child xmlns:ns1="uri2" ns1:foobar="v"/></root>');
|
||||
}, 'Check if attribute serialization takes into account of the same prefix declared in an ancestor element');
|
||||
|
||||
test(function() {
|
||||
const input = '<root><child1/><child2/></root>';
|
||||
const root = (new DOMParser()).parseFromString(input, 'text/xml').documentElement;
|
||||
|
|
Загрузка…
Ссылка в новой задаче