Skip to content

Commit f803e1d

Browse files
committed
Bug 1358104 - Only throw InvalidCharacterError for bad XML id's, not NamespaceError r=baku
Discussion at <whatwg/dom#319>. In short, the specification used to say to throw sometimes InvalidCharacterError and sometimes NamespaceError, but browsers disagreed on which to throw in corner cases, and everyone agreed it wasn't worth the effort to spec the distinction, so we just changed it to InvalidCharacterError across the board. The test changes are already upstream. MozReview-Commit-ID: AWSZBznQprG
1 parent bc2d30f commit f803e1d

11 files changed

Lines changed: 42 additions & 47 deletions

‎dom/base/nsContentUtils.cpp‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,12 +3094,7 @@ nsContentUtils::CheckQName(const nsAString& aQualifiedName,
30943094
return NS_OK;
30953095
}
30963096

3097-
// MOZ_EXPAT_EMPTY_QNAME || MOZ_EXPAT_INVALID_CHARACTER
3098-
if (result == (1 << 0) || result == (1 << 1)) {
3099-
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
3100-
}
3101-
3102-
return NS_ERROR_DOM_NAMESPACE_ERR;
3097+
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
31033098
}
31043099

31053100
//static

‎dom/tests/mochitest/dom-level2-core/test_createAttributeNS01.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@
108108
newAttr = doc.createAttributeNS(namespaceURI,malformedName);
109109
}
110110
catch(ex) {
111-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
111+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
112112
}
113-
assertTrue("throw_NAMESPACE_ERR",success);
113+
assertTrue("throw INVALID_CHARACTER_ERR",success);
114114
}
115115

116116
}

‎dom/tests/mochitest/dom-level2-core/test_createDocument01.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@
114114
aNewDoc = domImpl.createDocument(namespaceURI,malformedName,docType);
115115
}
116116
catch(ex) {
117-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
117+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
118118
}
119-
assertTrue("throw_NAMESPACE_ERR",success);
119+
assertTrue("throw INVALID_CHARACTER_ERR",success);
120120
}
121121

122122
}

‎dom/tests/mochitest/dom-level2-core/test_createDocumentType01.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@
112112
newType = domImpl.createDocumentType(malformedName,publicId,systemId);
113113
}
114114
catch(ex) {
115-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
115+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
116116
}
117-
assertTrue("throw_NAMESPACE_ERR",success);
117+
assertTrue("throw INVALID_CHARACTER_ERR", success);
118118
}
119119

120120
}

‎dom/tests/mochitest/dom-level2-core/test_createElementNS01.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@
108108
newElement = doc.createElementNS(namespaceURI,malformedName);
109109
}
110110
catch(ex) {
111-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
111+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
112112
}
113-
assertTrue("throw_NAMESPACE_ERR",success);
113+
assertTrue("throw INVALID_CHARACTER_ERR", success);
114114
}
115115

116116
}

‎dom/tests/mochitest/dom-level2-core/test_documentcreateattributeNS04.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
attribute = doc.createAttributeNS(namespaceURI,qualifiedName);
114114
}
115115
catch(ex) {
116-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
116+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
117117
}
118118
assertTrue("documentcreateattributeNS04",success);
119119
}

‎dom/tests/mochitest/dom-level2-core/test_domimplementationcreatedocument07.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
newDoc = domImpl.createDocument(namespaceURI,":",docType);
107107
}
108108
catch(ex) {
109-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
109+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
110110
}
111111
assertTrue("domimplementationcreatedocument07",success);
112112
}

‎dom/tests/mochitest/dom-level2-core/test_setAttributeNS02.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@
109109
testAddr.setAttributeNS(namespaceURI,qualifiedName,"newValue");
110110
}
111111
catch(ex) {
112-
success = (typeof(ex.code) != 'undefined' && ex.code == 14);
112+
success = ex.code === DOMException.INVALID_CHARACTER_ERR;
113113
}
114-
assertTrue("throw_NAMESPACE_ERR",success);
114+
assertTrue("throw INVALID_CHARACTER_ERR",success);
115115
}
116116

117117
}

‎testing/web-platform/tests/dom/nodes/DOMImplementation-createDocumentType.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
["(", "", "", "INVALID_CHARACTER_ERR"],
8181
[")", "", "", "INVALID_CHARACTER_ERR"],
8282
["f:oo", "", "", null],
83-
[":foo", "", "", "NAMESPACE_ERR"],
84-
["foo:", "", "", "NAMESPACE_ERR"],
85-
["prefix::local", "", "", "NAMESPACE_ERR"],
83+
[":foo", "", "", "INVALID_CHARACTER_ERR"],
84+
["foo:", "", "", "INVALID_CHARACTER_ERR"],
85+
["prefix::local", "", "", "INVALID_CHARACTER_ERR"],
8686
["foo", "foo", "", null],
8787
["foo", "", "foo", null],
8888
["foo", "f'oo", "", null],

‎testing/web-platform/tests/dom/nodes/Document-createElementNS.js‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ var createElementNS_tests = [
2525
[null, "fo o", "INVALID_CHARACTER_ERR"],
2626
[null, "-foo", "INVALID_CHARACTER_ERR"],
2727
[null, ".foo", "INVALID_CHARACTER_ERR"],
28-
[null, ":foo", "NAMESPACE_ERR"],
28+
[null, ":foo", "INVALID_CHARACTER_ERR"],
2929
[null, "f:oo", "NAMESPACE_ERR"],
30-
[null, "foo:", "NAMESPACE_ERR"],
31-
[null, "f:o:o", "NAMESPACE_ERR"],
32-
[null, ":", "NAMESPACE_ERR"],
30+
[null, "foo:", "INVALID_CHARACTER_ERR"],
31+
[null, "f:o:o", "INVALID_CHARACTER_ERR"],
32+
[null, ":", "INVALID_CHARACTER_ERR"],
3333
[null, "xml", null],
3434
[null, "xmlns", "NAMESPACE_ERR"],
3535
[null, "xmlfoo", null],
@@ -38,19 +38,19 @@ var createElementNS_tests = [
3838
[null, "xmlfoo:bar", "NAMESPACE_ERR"],
3939
[null, "null:xml", "NAMESPACE_ERR"],
4040
["", null, null],
41-
["", ":foo", "NAMESPACE_ERR"],
41+
["", ":foo", "INVALID_CHARACTER_ERR"],
4242
["", "f:oo", "NAMESPACE_ERR"],
43-
["", "foo:", "NAMESPACE_ERR"],
43+
["", "foo:", "INVALID_CHARACTER_ERR"],
4444
[undefined, null, null],
4545
[undefined, undefined, null],
4646
[undefined, "foo", null],
4747
[undefined, "1foo", "INVALID_CHARACTER_ERR"],
4848
[undefined, "f1oo", null],
4949
[undefined, "foo1", null],
50-
[undefined, ":foo", "NAMESPACE_ERR"],
50+
[undefined, ":foo", "INVALID_CHARACTER_ERR"],
5151
[undefined, "f:oo", "NAMESPACE_ERR"],
52-
[undefined, "foo:", "NAMESPACE_ERR"],
53-
[undefined, "f::oo", "NAMESPACE_ERR"],
52+
[undefined, "foo:", "INVALID_CHARACTER_ERR"],
53+
[undefined, "f::oo", "INVALID_CHARACTER_ERR"],
5454
[undefined, "xml", null],
5555
[undefined, "xmlns", "NAMESPACE_ERR"],
5656
[undefined, "xmlfoo", null],
@@ -65,15 +65,15 @@ var createElementNS_tests = [
6565
["http://example.com/", ".foo", "INVALID_CHARACTER_ERR"],
6666
["http://example.com/", "f1oo", null],
6767
["http://example.com/", "foo1", null],
68-
["http://example.com/", ":foo", "NAMESPACE_ERR"],
68+
["http://example.com/", ":foo", "INVALID_CHARACTER_ERR"],
6969
["http://example.com/", "f:oo", null],
70-
["http://example.com/", "f:o:o", "NAMESPACE_ERR"],
71-
["http://example.com/", "foo:", "NAMESPACE_ERR"],
72-
["http://example.com/", "f::oo", "NAMESPACE_ERR"],
73-
["http://example.com/", "a:0", "NAMESPACE_ERR"],
70+
["http://example.com/", "f:o:o", "INVALID_CHARACTER_ERR"],
71+
["http://example.com/", "foo:", "INVALID_CHARACTER_ERR"],
72+
["http://example.com/", "f::oo", "INVALID_CHARACTER_ERR"],
73+
["http://example.com/", "a:0", "INVALID_CHARACTER_ERR"],
7474
["http://example.com/", "0:a", "INVALID_CHARACTER_ERR"],
7575
["http://example.com/", "a:_", null],
76-
["http://example.com/", "a:\u0BC6", "NAMESPACE_ERR"],
76+
["http://example.com/", "a:\u0BC6", "INVALID_CHARACTER_ERR"],
7777
["http://example.com/", "\u0BC6:a", "INVALID_CHARACTER_ERR"],
7878
["http://example.com/", "a:a\u0BC6", null],
7979
["http://example.com/", "a\u0BC6:a", null],
@@ -98,7 +98,7 @@ var createElementNS_tests = [
9898
["http://example.com/", "xmlns:foo", "NAMESPACE_ERR"],
9999
["http://example.com/", "XMLNS:foo", null],
100100
["http://example.com/", "xmlfoo:bar", null],
101-
["http://example.com/", "prefix::local", "NAMESPACE_ERR"],
101+
["http://example.com/", "prefix::local", "INVALID_CHARACTER_ERR"],
102102
["http://example.com/", "namespaceURI:{", "INVALID_CHARACTER_ERR"],
103103
["http://example.com/", "namespaceURI:}", "INVALID_CHARACTER_ERR"],
104104
["http://example.com/", "namespaceURI:~", "INVALID_CHARACTER_ERR"],
@@ -130,9 +130,9 @@ var createElementNS_tests = [
130130
["/", "1foo", "INVALID_CHARACTER_ERR"],
131131
["/", "f1oo", null],
132132
["/", "foo1", null],
133-
["/", ":foo", "NAMESPACE_ERR"],
133+
["/", ":foo", "INVALID_CHARACTER_ERR"],
134134
["/", "f:oo", null],
135-
["/", "foo:", "NAMESPACE_ERR"],
135+
["/", "foo:", "INVALID_CHARACTER_ERR"],
136136
["/", "xml", null],
137137
["/", "xmlns", "NAMESPACE_ERR"],
138138
["/", "xmlfoo", null],
@@ -143,9 +143,9 @@ var createElementNS_tests = [
143143
["http://www.w3.org/XML/1998/namespace", "1foo", "INVALID_CHARACTER_ERR"],
144144
["http://www.w3.org/XML/1998/namespace", "f1oo", null],
145145
["http://www.w3.org/XML/1998/namespace", "foo1", null],
146-
["http://www.w3.org/XML/1998/namespace", ":foo", "NAMESPACE_ERR"],
146+
["http://www.w3.org/XML/1998/namespace", ":foo", "INVALID_CHARACTER_ERR"],
147147
["http://www.w3.org/XML/1998/namespace", "f:oo", null],
148-
["http://www.w3.org/XML/1998/namespace", "foo:", "NAMESPACE_ERR"],
148+
["http://www.w3.org/XML/1998/namespace", "foo:", "INVALID_CHARACTER_ERR"],
149149
["http://www.w3.org/XML/1998/namespace", "xml", null],
150150
["http://www.w3.org/XML/1998/namespace", "xmlns", "NAMESPACE_ERR"],
151151
["http://www.w3.org/XML/1998/namespace", "xmlfoo", null],
@@ -158,9 +158,9 @@ var createElementNS_tests = [
158158
["http://www.w3.org/2000/xmlns/", "1foo", "INVALID_CHARACTER_ERR"],
159159
["http://www.w3.org/2000/xmlns/", "f1oo", "NAMESPACE_ERR"],
160160
["http://www.w3.org/2000/xmlns/", "foo1", "NAMESPACE_ERR"],
161-
["http://www.w3.org/2000/xmlns/", ":foo", "NAMESPACE_ERR"],
161+
["http://www.w3.org/2000/xmlns/", ":foo", "INVALID_CHARACTER_ERR"],
162162
["http://www.w3.org/2000/xmlns/", "f:oo", "NAMESPACE_ERR"],
163-
["http://www.w3.org/2000/xmlns/", "foo:", "NAMESPACE_ERR"],
163+
["http://www.w3.org/2000/xmlns/", "foo:", "INVALID_CHARACTER_ERR"],
164164
["http://www.w3.org/2000/xmlns/", "xml", "NAMESPACE_ERR"],
165165
["http://www.w3.org/2000/xmlns/", "xmlns", null],
166166
["http://www.w3.org/2000/xmlns/", "xmlfoo", "NAMESPACE_ERR"],
@@ -172,9 +172,9 @@ var createElementNS_tests = [
172172
["foo:", "1foo", "INVALID_CHARACTER_ERR"],
173173
["foo:", "f1oo", null],
174174
["foo:", "foo1", null],
175-
["foo:", ":foo", "NAMESPACE_ERR"],
175+
["foo:", ":foo", "INVALID_CHARACTER_ERR"],
176176
["foo:", "f:oo", null],
177-
["foo:", "foo:", "NAMESPACE_ERR"],
177+
["foo:", "foo:", "INVALID_CHARACTER_ERR"],
178178
["foo:", "xml", null],
179179
["foo:", "xmlns", "NAMESPACE_ERR"],
180180
["foo:", "xmlfoo", null],

0 commit comments

Comments
 (0)