Skip to content

Commit f53feac

Browse files
Update tests for relaxed DOM name/attribute parsing
Spec PR: whatwg/dom#1079 Bug: 40122442, 40228234 Change-Id: I42c40c3f3acdfcfc4647c6d87ffcbfadc6de13be Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6570951 Reviewed-by: David Baron <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1475652}
1 parent 69019b2 commit f53feac

10 files changed

+116
-151
lines changed

acid/acid3/test.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@
928928
test('<div>');
929929
test('0div');
930930
test('di v');
931-
test('di<v');
932931
test('-div');
933932
test('.div');
934933
return 2;
@@ -948,12 +947,10 @@
948947
test('<div>', null, 5);
949948
test('0div', null, 5);
950949
test('di v', null, 5);
951-
test('di<v', null, 5);
952950
test('-div', null, 5);
953951
test('.div', null, 5);
954952
test('<div>', "http://example.com/", 5);
955953
test('0div', "http://example.com/", 5);
956-
test('di<v', "http://example.com/", 5);
957954
test('-div', "http://example.com/", 5);
958955
test('.div', "http://example.com/", 5);
959956
//test(':div', null, 14);
@@ -975,7 +972,7 @@
975972
// check that exceptions that are thrown are DOMException objects
976973
var message = "";
977974
try {
978-
document.implementation.createDocumentType('a:', '', ''); /* doesn't contain an illegal character; is malformed */
975+
document.implementation.createDocumentType('a>', '', ''); /* doesn't contain an illegal character; is malformed */
979976
message = "failed to raise exception";
980977
} catch (e) {
981978
/*if (e.code != e.NAMESPACE_ERR)

dom/nodes/DOMImplementation-createDocument.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,16 @@
113113
assert_equals(element.nodeType, Node.ELEMENT_NODE)
114114
assert_equals(element.ownerDocument, doc)
115115
var qualified = String(qualifiedName), names = []
116-
if (qualified.indexOf(":") >= 0) {
117-
names = qualified.split(":", 2)
116+
var firstColonIndex = qualified.indexOf(":")
117+
if (firstColonIndex >= 0) {
118+
names.push(qualified.substring(0, firstColonIndex));
119+
names.push(qualified.substring(firstColonIndex + 1));
118120
} else {
119121
names = [null, qualified]
120122
}
121-
assert_equals(element.prefix, names[0])
122-
assert_equals(element.localName, names[1])
123-
assert_equals(element.namespaceURI, namespace === undefined ? null : namespace)
123+
assert_equals(element.prefix, names[0], 'element.prefix')
124+
assert_equals(element.localName, names[1], 'element.localName')
125+
assert_equals(element.namespaceURI, namespace === undefined || namespace === "" ? null : namespace, 'element.namespaceURI')
124126
}
125127
if (!doctype) {
126128
assert_equals(doc.doctype, null)

dom/nodes/DOMImplementation-createDocumentType.html

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<script>
1313
test(function() {
1414
var tests = [
15-
["", "", "", "INVALID_CHARACTER_ERR"],
15+
["", "", "", null],
1616
["test:root", "1234", "", null],
1717
["test:root", "1234", "test", null],
1818
["test:root", "test", "", null],
@@ -32,57 +32,57 @@
3232
["a-b:c.j", "", "", null],
3333
["a-b:c", "", "", null],
3434
["foo", "", "", null],
35-
["1foo", "", "", "INVALID_CHARACTER_ERR"],
35+
["1foo", "", "", null],
3636
["foo1", "", "", null],
3737
["f1oo", "", "", null],
38-
["@foo", "", "", "INVALID_CHARACTER_ERR"],
39-
["foo@", "", "", "INVALID_CHARACTER_ERR"],
40-
["f@oo", "", "", "INVALID_CHARACTER_ERR"],
41-
["edi:{", "", "", "INVALID_CHARACTER_ERR"],
42-
["edi:}", "", "", "INVALID_CHARACTER_ERR"],
43-
["edi:~", "", "", "INVALID_CHARACTER_ERR"],
44-
["edi:'", "", "", "INVALID_CHARACTER_ERR"],
45-
["edi:!", "", "", "INVALID_CHARACTER_ERR"],
46-
["edi:@", "", "", "INVALID_CHARACTER_ERR"],
47-
["edi:#", "", "", "INVALID_CHARACTER_ERR"],
48-
["edi:$", "", "", "INVALID_CHARACTER_ERR"],
49-
["edi:%", "", "", "INVALID_CHARACTER_ERR"],
50-
["edi:^", "", "", "INVALID_CHARACTER_ERR"],
51-
["edi:&", "", "", "INVALID_CHARACTER_ERR"],
52-
["edi:*", "", "", "INVALID_CHARACTER_ERR"],
53-
["edi:(", "", "", "INVALID_CHARACTER_ERR"],
54-
["edi:)", "", "", "INVALID_CHARACTER_ERR"],
55-
["edi:+", "", "", "INVALID_CHARACTER_ERR"],
56-
["edi:=", "", "", "INVALID_CHARACTER_ERR"],
57-
["edi:[", "", "", "INVALID_CHARACTER_ERR"],
58-
["edi:]", "", "", "INVALID_CHARACTER_ERR"],
59-
["edi:\\", "", "", "INVALID_CHARACTER_ERR"],
60-
["edi:/", "", "", "INVALID_CHARACTER_ERR"],
61-
["edi:;", "", "", "INVALID_CHARACTER_ERR"],
62-
["edi:`", "", "", "INVALID_CHARACTER_ERR"],
63-
["edi:<", "", "", "INVALID_CHARACTER_ERR"],
38+
["@foo", "", "", null],
39+
["foo@", "", "", null],
40+
["f@oo", "", "", null],
41+
["edi:{", "", "", null],
42+
["edi:}", "", "", null],
43+
["edi:~", "", "", null],
44+
["edi:'", "", "", null],
45+
["edi:!", "", "", null],
46+
["edi:@", "", "", null],
47+
["edi:#", "", "", null],
48+
["edi:$", "", "", null],
49+
["edi:%", "", "", null],
50+
["edi:^", "", "", null],
51+
["edi:&", "", "", null],
52+
["edi:*", "", "", null],
53+
["edi:(", "", "", null],
54+
["edi:)", "", "", null],
55+
["edi:+", "", "", null],
56+
["edi:=", "", "", null],
57+
["edi:[", "", "", null],
58+
["edi:]", "", "", null],
59+
["edi:\\", "", "", null],
60+
["edi:/", "", "", null],
61+
["edi:;", "", "", null],
62+
["edi:`", "", "", null],
63+
["edi:<", "", "", null],
6464
["edi:>", "", "", "INVALID_CHARACTER_ERR"],
65-
["edi:,", "", "", "INVALID_CHARACTER_ERR"],
65+
["edi:,", "", "", null],
6666
["edi:a ", "", "", "INVALID_CHARACTER_ERR"],
67-
["edi:\"", "", "", "INVALID_CHARACTER_ERR"],
68-
["{", "", "", "INVALID_CHARACTER_ERR"],
69-
["}", "", "", "INVALID_CHARACTER_ERR"],
70-
["'", "", "", "INVALID_CHARACTER_ERR"],
71-
["~", "", "", "INVALID_CHARACTER_ERR"],
72-
["`", "", "", "INVALID_CHARACTER_ERR"],
73-
["@", "", "", "INVALID_CHARACTER_ERR"],
74-
["#", "", "", "INVALID_CHARACTER_ERR"],
75-
["$", "", "", "INVALID_CHARACTER_ERR"],
76-
["%", "", "", "INVALID_CHARACTER_ERR"],
77-
["^", "", "", "INVALID_CHARACTER_ERR"],
78-
["&", "", "", "INVALID_CHARACTER_ERR"],
79-
["*", "", "", "INVALID_CHARACTER_ERR"],
80-
["(", "", "", "INVALID_CHARACTER_ERR"],
81-
[")", "", "", "INVALID_CHARACTER_ERR"],
67+
["edi:\"", "", "", null],
68+
["{", "", "", null],
69+
["}", "", "", null],
70+
["'", "", "", null],
71+
["~", "", "", null],
72+
["`", "", "", null],
73+
["@", "", "", null],
74+
["#", "", "", null],
75+
["$", "", "", null],
76+
["%", "", "", null],
77+
["^", "", "", null],
78+
["&", "", "", null],
79+
["*", "", "", null],
80+
["(", "", "", null],
81+
[")", "", "", null],
8282
["f:oo", "", "", null],
83-
[":foo", "", "", "INVALID_CHARACTER_ERR"],
84-
["foo:", "", "", "INVALID_CHARACTER_ERR"],
85-
["prefix::local", "", "", "INVALID_CHARACTER_ERR"],
83+
[":foo", "", "", null],
84+
["foo:", "", "", null],
85+
["prefix::local", "", "", null],
8686
["foo", "foo", "", null],
8787
["foo", "", "foo", null],
8888
["foo", "f'oo", "", null],

dom/nodes/Document-createElement.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,26 @@
7171
"mar\u212a",
7272
"\u0130nput",
7373
"\u0131nput",
74+
"\u0300foo",
75+
"f}oo",
76+
"foo}",
77+
"\ufffffoo",
78+
"f\uffffoo",
79+
"foo\uffff",
80+
"f<oo",
81+
"\u0300",
7482
],
7583
invalid = [
7684
"",
7785
"1foo",
7886
"1:foo",
7987
"fo o",
80-
"\u0300foo",
8188
"}foo",
82-
"f}oo",
83-
"foo}",
84-
"\ufffffoo",
85-
"f\uffffoo",
86-
"foo\uffff",
8789
"<foo",
8890
"foo>",
8991
"<foo>",
90-
"f<oo",
9192
"-foo",
9293
".foo",
93-
"\u0300",
9494
]
9595

9696
var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');

dom/nodes/Document-createElementNS.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,21 @@
5959
assert_equals(element.nodeValue, null)
6060
assert_equals(element.ownerDocument, doc)
6161
var qualified = String(qualifiedName), names = []
62-
if (qualified.indexOf(":") >= 0) {
63-
names = qualified.split(":", 2)
62+
var firstColonIndex = qualified.indexOf(":")
63+
if (firstColonIndex >= 0) {
64+
names.push(qualified.substring(0, firstColonIndex));
65+
names.push(qualified.substring(firstColonIndex + 1));
6466
} else {
6567
names = [null, qualified]
6668
}
67-
assert_equals(element.prefix, names[0])
68-
assert_equals(element.localName, names[1])
69-
assert_equals(element.tagName, qualified)
70-
assert_equals(element.nodeName, qualified)
69+
assert_equals(element.prefix, names[0], 'element.prefix')
70+
assert_equals(element.localName, names[1], 'element.localName')
71+
assert_equals(element.tagName, qualified, 'element.tagName')
72+
assert_equals(element.nodeName, qualified, 'element.nodeName')
7173
assert_equals(element.namespaceURI,
7274
namespace === undefined || namespace === "" ? null
73-
: namespace)
75+
: namespace,
76+
'element.namespaceURI')
7477
}
7578
});
7679
testObj.done();

dom/nodes/Document-createElementNS.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ var createElementNS_tests = [
1111
[null, "f1oo", null],
1212
[null, "foo1", null],
1313
[null, "\u0BC6foo", null],
14-
[null, "\u037Efoo", "INVALID_CHARACTER_ERR"],
14+
[null, "\u037Efoo", null],
1515
[null, "}foo", "INVALID_CHARACTER_ERR"],
16-
[null, "f}oo", "INVALID_CHARACTER_ERR"],
17-
[null, "foo}", "INVALID_CHARACTER_ERR"],
18-
[null, "\uFFFFfoo", "INVALID_CHARACTER_ERR"],
19-
[null, "f\uFFFFoo", "INVALID_CHARACTER_ERR"],
20-
[null, "foo\uFFFF", "INVALID_CHARACTER_ERR"],
16+
[null, "f}oo", null],
17+
[null, "foo}", null],
18+
[null, "\uFFFFfoo", null],
19+
[null, "f\uFFFFoo", null],
20+
[null, "foo\uFFFF", null],
2121
[null, "<foo", "INVALID_CHARACTER_ERR"],
2222
[null, "foo>", "INVALID_CHARACTER_ERR"],
2323
[null, "<foo>", "INVALID_CHARACTER_ERR"],
24-
[null, "f<oo", "INVALID_CHARACTER_ERR"],
24+
[null, "f<oo", null],
2525
[null, "^^", "INVALID_CHARACTER_ERR"],
2626
[null, "fo o", "INVALID_CHARACTER_ERR"],
2727
[null, "-foo", "INVALID_CHARACTER_ERR"],
2828
[null, ".foo", "INVALID_CHARACTER_ERR"],
29-
[null, ":foo", "INVALID_CHARACTER_ERR"],
29+
[null, ":foo", null],
3030
[null, "f:oo", "NAMESPACE_ERR"],
3131
[null, "foo:", "INVALID_CHARACTER_ERR"],
32-
[null, "f:o:o", "INVALID_CHARACTER_ERR"],
32+
[null, "f:o:o", "NAMESPACE_ERR"],
3333
[null, ":", "INVALID_CHARACTER_ERR"],
3434
[null, "xml", null],
3535
[null, "xmlns", "NAMESPACE_ERR"],
@@ -39,7 +39,7 @@ var createElementNS_tests = [
3939
[null, "xmlfoo:bar", "NAMESPACE_ERR"],
4040
[null, "null:xml", "NAMESPACE_ERR"],
4141
["", null, null],
42-
["", ":foo", "INVALID_CHARACTER_ERR"],
42+
["", ":foo", null],
4343
["", "f:oo", "NAMESPACE_ERR"],
4444
["", "foo:", "INVALID_CHARACTER_ERR"],
4545
[undefined, null, null],
@@ -48,10 +48,10 @@ var createElementNS_tests = [
4848
[undefined, "1foo", "INVALID_CHARACTER_ERR"],
4949
[undefined, "f1oo", null],
5050
[undefined, "foo1", null],
51-
[undefined, ":foo", "INVALID_CHARACTER_ERR"],
51+
[undefined, ":foo", null],
5252
[undefined, "f:oo", "NAMESPACE_ERR"],
5353
[undefined, "foo:", "INVALID_CHARACTER_ERR"],
54-
[undefined, "f::oo", "INVALID_CHARACTER_ERR"],
54+
[undefined, "f::oo", "NAMESPACE_ERR"],
5555
[undefined, "xml", null],
5656
[undefined, "xmlns", "NAMESPACE_ERR"],
5757
[undefined, "xmlfoo", null],
@@ -61,25 +61,25 @@ var createElementNS_tests = [
6161
["http://example.com/", "foo", null],
6262
["http://example.com/", "1foo", "INVALID_CHARACTER_ERR"],
6363
["http://example.com/", "<foo>", "INVALID_CHARACTER_ERR"],
64-
["http://example.com/", "fo<o", "INVALID_CHARACTER_ERR"],
64+
["http://example.com/", "fo<o", null],
6565
["http://example.com/", "-foo", "INVALID_CHARACTER_ERR"],
6666
["http://example.com/", ".foo", "INVALID_CHARACTER_ERR"],
6767
["http://example.com/", "f1oo", null],
6868
["http://example.com/", "foo1", null],
69-
["http://example.com/", ":foo", "INVALID_CHARACTER_ERR"],
69+
["http://example.com/", ":foo", null],
7070
["http://example.com/", "f:oo", null],
71-
["http://example.com/", "f:o:o", "INVALID_CHARACTER_ERR"],
71+
["http://example.com/", "f:o:o", null],
7272
["http://example.com/", "foo:", "INVALID_CHARACTER_ERR"],
73-
["http://example.com/", "f::oo", "INVALID_CHARACTER_ERR"],
73+
["http://example.com/", "f::oo", null],
7474
["http://example.com/", "a:0", "INVALID_CHARACTER_ERR"],
75-
["http://example.com/", "0:a", "INVALID_CHARACTER_ERR"],
75+
["http://example.com/", "0:a", null],
7676
["http://example.com/", "a:_", null],
7777
["http://example.com/", "a:\u0BC6", null],
78-
["http://example.com/", "a:\u037E", "INVALID_CHARACTER_ERR"],
79-
["http://example.com/", "a:\u0300", "INVALID_CHARACTER_ERR"],
78+
["http://example.com/", "a:\u037E", null],
79+
["http://example.com/", "a:\u0300", null],
8080
["http://example.com/", "\u0BC6:a", null],
81-
["http://example.com/", "\u0300:a", "INVALID_CHARACTER_ERR"],
82-
["http://example.com/", "\u037E:a", "INVALID_CHARACTER_ERR"],
81+
["http://example.com/", "\u0300:a", null],
82+
["http://example.com/", "\u037E:a", null],
8383
["http://example.com/", "a:a\u0BC6", null],
8484
["http://example.com/", "a\u0BC6:a", null],
8585
["http://example.com/", "xml:test", "NAMESPACE_ERR"],
@@ -103,7 +103,7 @@ var createElementNS_tests = [
103103
["http://example.com/", "xmlns:foo", "NAMESPACE_ERR"],
104104
["http://example.com/", "XMLNS:foo", null],
105105
["http://example.com/", "xmlfoo:bar", null],
106-
["http://example.com/", "prefix::local", "INVALID_CHARACTER_ERR"],
106+
["http://example.com/", "prefix::local", null],
107107
["http://example.com/", "namespaceURI:{", "INVALID_CHARACTER_ERR"],
108108
["http://example.com/", "namespaceURI:}", "INVALID_CHARACTER_ERR"],
109109
["http://example.com/", "namespaceURI:~", "INVALID_CHARACTER_ERR"],
@@ -135,7 +135,7 @@ var createElementNS_tests = [
135135
["/", "1foo", "INVALID_CHARACTER_ERR"],
136136
["/", "f1oo", null],
137137
["/", "foo1", null],
138-
["/", ":foo", "INVALID_CHARACTER_ERR"],
138+
["/", ":foo", null],
139139
["/", "f:oo", null],
140140
["/", "foo:", "INVALID_CHARACTER_ERR"],
141141
["/", "xml", null],
@@ -148,7 +148,7 @@ var createElementNS_tests = [
148148
["http://www.w3.org/XML/1998/namespace", "1foo", "INVALID_CHARACTER_ERR"],
149149
["http://www.w3.org/XML/1998/namespace", "f1oo", null],
150150
["http://www.w3.org/XML/1998/namespace", "foo1", null],
151-
["http://www.w3.org/XML/1998/namespace", ":foo", "INVALID_CHARACTER_ERR"],
151+
["http://www.w3.org/XML/1998/namespace", ":foo", null],
152152
["http://www.w3.org/XML/1998/namespace", "f:oo", null],
153153
["http://www.w3.org/XML/1998/namespace", "foo:", "INVALID_CHARACTER_ERR"],
154154
["http://www.w3.org/XML/1998/namespace", "xml", null],
@@ -163,7 +163,7 @@ var createElementNS_tests = [
163163
["http://www.w3.org/2000/xmlns/", "1foo", "INVALID_CHARACTER_ERR"],
164164
["http://www.w3.org/2000/xmlns/", "f1oo", "NAMESPACE_ERR"],
165165
["http://www.w3.org/2000/xmlns/", "foo1", "NAMESPACE_ERR"],
166-
["http://www.w3.org/2000/xmlns/", ":foo", "INVALID_CHARACTER_ERR"],
166+
["http://www.w3.org/2000/xmlns/", ":foo", "NAMESPACE_ERR"],
167167
["http://www.w3.org/2000/xmlns/", "f:oo", "NAMESPACE_ERR"],
168168
["http://www.w3.org/2000/xmlns/", "foo:", "INVALID_CHARACTER_ERR"],
169169
["http://www.w3.org/2000/xmlns/", "xml", "NAMESPACE_ERR"],
@@ -177,7 +177,7 @@ var createElementNS_tests = [
177177
["foo:", "1foo", "INVALID_CHARACTER_ERR"],
178178
["foo:", "f1oo", null],
179179
["foo:", "foo1", null],
180-
["foo:", ":foo", "INVALID_CHARACTER_ERR"],
180+
["foo:", ":foo", null],
181181
["foo:", "f:oo", null],
182182
["foo:", "foo:", "INVALID_CHARACTER_ERR"],
183183
["foo:", "xml", null],

0 commit comments

Comments
 (0)