| <!DOCTYPE html> |
| <title>This tests that XMLSerializer emits a correct namespace declaration for the <image> element. The first line is serialized as part of a DocumentFragment. The second line is serialized as part of the Document</title> |
| <body> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| setup({single_test: true}); |
| |
| function escapeHTML(text) |
| { |
| return text.replace(/&/g, "&").replace(/</g, "<").replace(/\0/g, "\\0"); |
| } |
| |
| var svgDoc = new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>', 'text/xml'); |
| var svgEl = svgDoc.firstChild; |
| var imageEl = document.createElementNS('http://www.w3.org/2000/svg', 'image'); |
| imageEl.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'blah'); |
| svgEl.appendChild(imageEl); |
| |
| var serializer = new XMLSerializer(); |
| |
| var span = document.createElement("div"); |
| span.innerHTML = escapeHTML(serializer.serializeToString(svgEl)); |
| assert_equals(span.textContent, "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><image xlink:href=\"blah\"/></svg>"); |
| document.body.appendChild(svgDoc.removeChild(svgEl)); |
| span.innerHTML = escapeHTML(serializer.serializeToString(svgEl)); |
| assert_equals(span.textContent, "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><image xlink:href=\"blah\"/></svg>"); |
| |
| document.body.removeChild(svgEl); |
| done(); |
| </script> |