Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / XMLSerializer-element-ns-no-reemit.html
blobfd4f7f36fb1196012a0c60bdfd7ec132db4ce979
1 <!DOCTYPE html>
2 <title>XMLSerializer: Don't emit redundant NS declarations</title>
3 <script src=../../resources/testharness.js></script>
4 <script src=../../resources/testharnessreport.js></script>
5 <div id=log></div>
6 <script>
7 test(function() {
8 var s = '<foo xmlns="http://www.w3.org/1999/xhtml"></foo>';
9 var docFrag = new DOMParser().parseFromString(s, 'text/xml');
10 var root = docFrag.removeChild(docFrag.firstChild);
11 var child = document.createElementNS('http://www.w3.org/1999/xhtml', 'bar');
12 child.appendChild(document.createTextNode(''));
13 root.appendChild(child);
14 var result1 = new XMLSerializer().serializeToString(root);
15 assert_equals(result1, '<foo xmlns="http://www.w3.org/1999/xhtml"><bar></bar></foo>');
16 }, 'XMLSerializer: Don\'t emit redundant declarations of the default NS.');
18 test(function() {
19 var s = '<foo xmlns="http://www.w3.org/1999/xhtml" xmlns:baz="http://example.org/baz"></foo>';
20 var docFrag = new DOMParser().parseFromString(s, 'text/xml');
21 var root = docFrag.removeChild(docFrag.firstChild);
22 var child = document.createElementNS('http://example.org/baz', 'baz:bar');
23 child.appendChild(document.createTextNode(''));
24 root.appendChild(child);
25 var result1 = new XMLSerializer().serializeToString(root);
26 assert_equals(result1, '<foo xmlns="http://www.w3.org/1999/xhtml" xmlns:baz="http://example.org/baz"><baz:bar></baz:bar></foo>');
27 }, 'XMLSerializer: Don\'t emit redundant declarations of a prefix.');
28 </script>