Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/XMLSerializer-attribute-special-namespaces.html

Issue 2667303004: Move tests for DOMParser and XMLSerializer to dom/domparsing/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 description('Tests the serialization of special XML namespaces on attributes, as reported in <a href="http://crbug.com/395950">bug 395950</a>.');
5
6 var xmlDocument = (new DOMParser()).parseFromString('<outer />', 'text/xml');
7
8 var inner1 = xmlDocument.createElementNS(null, 'inner1');
9 // The xlink's namespace prefix is xlink by default, not auto-generated.
10 inner1.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'http://www.google .com');
11 // The xml namespace is automatically bound to the xml prefix, no definition nee ded.
12 inner1.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'attr', 'value');
13 xmlDocument.firstChild.appendChild(inner1);
14
15 var inner2 = xmlDocument.createElementNS(null, 'inner2');
16 // The xlink's namespace prefix should not be forced to xlink.
17 inner2.setAttributeNS('http://www.w3.org/1999/xlink', 'xl:href', 'http://www.goo gle.com');
18 // The xml namespace is automatically bound to the xml prefix, no definition nee ded.
19 inner2.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:attr', 'value ');
20 xmlDocument.firstChild.appendChild(inner2);
21
22 // Check the DOM construction.
23 shouldBeEqualToString('xmlDocument.querySelector("inner1").getAttributeNS("http: //www.w3.org/1999/xlink", "href")', 'http://www.google.com');
24 shouldBeEqualToString('xmlDocument.querySelector("inner1").getAttributeNS("http: //www.w3.org/XML/1998/namespace", "attr")', 'value');
25 shouldBeEqualToString('xmlDocument.querySelector("inner2").getAttributeNS("http: //www.w3.org/1999/xlink", "href")', 'http://www.google.com');
26 shouldBeEqualToString('xmlDocument.querySelector("inner2").getAttribute("xl:href ")', 'http://www.google.com');
27 shouldBeEqualToString('xmlDocument.querySelector("inner2").getAttributeNS("http: //www.w3.org/XML/1998/namespace", "attr")', 'value');
28 shouldBeEqualToString('xmlDocument.querySelector("inner2").getAttribute("xml:att r")', 'value');
29
30 var xmlString = (new XMLSerializer()).serializeToString(xmlDocument);
31
32 // Check the serialization result.
33 var parsedDoc = (new DOMParser()).parseFromString(xmlString, 'text/xml');
34 shouldBeEqualToString('parsedDoc.querySelector("inner1").getAttributeNS("http:// www.w3.org/1999/xlink", "href")', 'http://www.google.com');
35 shouldBeEqualToString('parsedDoc.querySelector("inner1").getAttributeNS("http:// www.w3.org/XML/1998/namespace", "attr")', 'value');
36 shouldBeEqualToString('parsedDoc.querySelector("inner2").getAttributeNS("http:// www.w3.org/1999/xlink", "href")', 'http://www.google.com');
37 shouldBeEqualToString('parsedDoc.querySelector("inner2").getAttribute("xl:href") ', 'http://www.google.com');
38 shouldBeEqualToString('parsedDoc.querySelector("inner2").getAttributeNS("http:// www.w3.org/XML/1998/namespace", "attr")', 'value');
39 shouldBeEqualToString('parsedDoc.querySelector("inner2").getAttribute("xml:attr" )', 'value');
40
41 // Check that the correct xmlns definitions were emitted.
42 shouldBeEqualToNumber('xmlString.indexOf("xmlns:xml")', -1);
43 shouldNotBe('xmlString.indexOf("xmlns:xlink")', '-1');
44 shouldNotBe('xmlString.indexOf("xmlns:xl")', '-1');
45 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698