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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupNamespaceURI.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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 <html>
3 <head>
4 <title>LookupNamespaceURI and IsDefaultNamespace tests</title>
5 <script src=../../../../resources/testharness.js></script>
6 <script src=../../../../resources/testharnessreport.js></script>
7 </head>
8 <body>
9 <h1>LookupNamespaceURI and IsDefaultNamespace</h1>
10 <div id="log"/>
11 <script>
12 function lookupNamespaceURI(node, prefix, expected, name) {
13 test(function() {
14 assert_equals(node.lookupNamespaceURI(prefix), expected);
15 }, name);
16 }
17
18 function isDefaultNamespace(node, namespace, expected, name) {
19 test(function() {
20 assert_equals(node.isDefaultNamespace(namespace), expected);
21 }, name);
22 }
23
24
25 var frag = document.createDocumentFragment();
26 lookupNamespaceURI(frag, null, null, 'DocumentFragment should have null namespac e, prefix null');
27 lookupNamespaceURI(frag, '', null, 'DocumentFragment should have null namespace, prefix ""');
28 lookupNamespaceURI(frag, 'foo', null, 'DocumentFragment should have null namespa ce, prefix "foo"');
29 lookupNamespaceURI(frag, 'xmlns', null, 'DocumentFragment should have null names pace, prefix "xmlns"');
30 isDefaultNamespace(frag, null, true, 'DocumentFragment is in default namespace, prefix null');
31 isDefaultNamespace(frag, '', true, 'DocumentFragment is in default namespace, pr efix ""');
32 isDefaultNamespace(frag, 'foo', false, 'DocumentFragment is in default namespace , prefix "foo"');
33 isDefaultNamespace(frag, 'xmlns', false, 'DocumentFragment is in default namespa ce, prefix "xmlns"');
34
35
36
37 var fooElem = document.createElementNS('fooNamespace', 'prefix:elem');
38 fooElem.setAttribute('bar', 'value');
39
40 lookupNamespaceURI(fooElem, null, null, 'Element should have null namespace, pre fix null');
41 lookupNamespaceURI(fooElem, '', null, 'Element should have null namespace, prefi x ""');
42 lookupNamespaceURI(fooElem, 'fooNamespace', null, 'Element should not have names pace matching prefix with namespaceURI value');
43 lookupNamespaceURI(fooElem, 'xmlns', null, 'Element should not have XMLNS namesp ace');
44 lookupNamespaceURI(fooElem, 'prefix', 'fooNamespace', 'Element has namespace URI matching prefix');
45 isDefaultNamespace(fooElem, null, true, 'Empty namespace is not default, prefix null');
46 isDefaultNamespace(fooElem, '', true, 'Empty namespace is not default, prefix "" ');
47 isDefaultNamespace(fooElem, 'fooNamespace', false, 'fooNamespace is not default' );
48 isDefaultNamespace(fooElem, 'http://www.w3.org/2000/xmlns/', false, 'xmlns names pace is not default');
49
50 fooElem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:bar', 'barURI');
51 fooElem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'bazURI');
52
53 lookupNamespaceURI(fooElem, null, 'bazURI', 'Element should have baz namespace, prefix null');
54 lookupNamespaceURI(fooElem, '', 'bazURI', 'Element should have baz namespace, pr efix ""');
55 lookupNamespaceURI(fooElem, 'xmlns', null, 'Element does not has namespace with xlmns prefix');
56 lookupNamespaceURI(fooElem, 'bar', 'barURI', 'Element has bar namespace');
57
58 isDefaultNamespace(fooElem, null, false, 'Empty namespace is not default on fooE lem, prefix null');
59 isDefaultNamespace(fooElem, '', false, 'Empty namespace is not default on fooEle m, prefix ""');
60 isDefaultNamespace(fooElem, 'barURI', false, 'bar namespace is not default');
61 isDefaultNamespace(fooElem, 'bazURI', true, 'baz namespace is default');
62
63 var comment = document.createComment('comment');
64 fooElem.appendChild(comment);
65
66 lookupNamespaceURI(comment, null, 'bazURI', 'Comment should inherit baz namespac e');
67 lookupNamespaceURI(comment, '', 'bazURI', 'Comment should inherit baz namespace ');
68 lookupNamespaceURI(comment, 'prefix', 'fooNamespace', 'Comment should inherit na mespace URI matching prefix');
69 lookupNamespaceURI(comment, 'bar', 'barURI', 'Comment should inherit bar namespa ce');
70
71 isDefaultNamespace(comment, null, false, 'For comment, empty namespace is not de fault, prefix null');
72 isDefaultNamespace(comment, '', false, 'For comment, empty namespace is not defa ult, prefix ""');
73 isDefaultNamespace(comment, 'fooNamespace', false, 'For comment, fooNamespace is not default');
74 isDefaultNamespace(comment, 'http://www.w3.org/2000/xmlns/', false, 'For comment , xmlns namespace is not default');
75 isDefaultNamespace(comment, 'barURI', false, 'For comment, inherited bar namespa ce is not default');
76 isDefaultNamespace(comment, 'bazURI', true, 'For comment, inherited baz namespac e is default');
77
78 var fooChild = document.createElementNS('childNamespace', 'childElem');
79 fooElem.appendChild(fooChild);
80
81 lookupNamespaceURI(fooChild, null, 'childNamespace', 'Child element should inher it baz namespace');
82 lookupNamespaceURI(fooChild, '', 'childNamespace', 'Child element should have nu ll namespace');
83 lookupNamespaceURI(fooChild, 'xmlns', null, 'Child element should not have XMLNS namespace');
84 lookupNamespaceURI(fooChild, 'prefix', 'fooNamespace', 'Child element has namesp ace URI matching prefix');
85
86 isDefaultNamespace(fooChild, null, false, 'Empty namespace is not default for ch ild, prefix null');
87 isDefaultNamespace(fooChild, '', false, 'Empty namespace is not default for chil d, prefix ""');
88 isDefaultNamespace(fooChild, 'fooNamespace', false, 'fooNamespace is not default for child');
89 isDefaultNamespace(fooChild, 'http://www.w3.org/2000/xmlns/', false, 'xmlns name space is not default for child');
90 isDefaultNamespace(fooChild, 'barURI', false, 'bar namespace is not default for child');
91 isDefaultNamespace(fooChild, 'bazURI', false, 'baz namespace is default for chil d');
92 isDefaultNamespace(fooChild, 'childNamespace', true, 'childNamespace is default for child');
93
94 document.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns: bar', 'barURI');
95 document.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns' , 'bazURI');
96
97 lookupNamespaceURI(document, null, 'http://www.w3.org/1999/xhtml', 'Document sho uld have xhtml namespace, prefix null');
98 lookupNamespaceURI(document, '', 'http://www.w3.org/1999/xhtml', 'Document shoul d have xhtml namespace, prefix ""');
99 lookupNamespaceURI(document, 'prefix', null, 'Document has no namespace URI matc hing prefix');
100 lookupNamespaceURI(document, 'bar', 'barURI', 'Document has bar namespace');
101
102 isDefaultNamespace(document, null, false, 'For document, empty namespace is not default, prefix null');
103 isDefaultNamespace(document, '', false, 'For document, empty namespace is not de fault, prefix ""');
104 isDefaultNamespace(document, 'fooNamespace', false, 'For document, fooNamespace is not default');
105 isDefaultNamespace(document, 'http://www.w3.org/2000/xmlns/', false, 'For docume nt, xmlns namespace is not default');
106 isDefaultNamespace(document, 'barURI', false, 'For document, bar namespace is no t default');
107 isDefaultNamespace(document, 'bazURI', false, 'For document, baz namespace is no t default');
108 isDefaultNamespace(document, 'http://www.w3.org/1999/xhtml', true, 'For document , xhtml namespace is default');
109
110 var comment = document.createComment('comment');
111 document.appendChild(comment);
112 lookupNamespaceURI(comment, 'bar', null, 'Comment does not have bar namespace');
113
114 </script>
115 </body>
116 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698