| Differences between
and this patch
- file_not_specified_in_diff
Line 1 file_not_specified_in_diff_sec1
- a/LayoutTests/dom/xhtml/level3/core/documentsetstricterrorchecking02-expected.txt -2 / +1 lines
Lines 1-3 a/LayoutTests/dom/xhtml/level3/core/documentsetstricterrorchecking02-expected.txt_sec1
1
Test	http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetstricterrorchecking02
1
Test	http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetstricterrorchecking02
2
Status	failure
2
Status	Success
3
Message	NAMESPACE_ERR_documentsetstricterrorchecking02: assertTrue failed
- a/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err-expected.txt +52 lines
Line 0 a/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err-expected.txt_sec1
1
createAttirbuteNS tests adapted from createElementNS tests attached to webkit bug 16833
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6
PASS document.createAttributeNS().toString() is "[object Attr]"
7
PASS document.createAttributeNS("http://www.example.com").toString() is "[object Attr]"
8
PASS createAttributeNS(undefined, undefined)
9
PASS createAttributeNS(null, undefined)
10
PASS createAttributeNS(undefined, null); threw INVALID_CHARACTER_ERR
11
PASS createAttributeNS(null, null); threw INVALID_CHARACTER_ERR
12
PASS createAttributeNS(null, ""); threw INVALID_CHARACTER_ERR
13
PASS createAttributeNS("", null); threw INVALID_CHARACTER_ERR
14
PASS createAttributeNS("", ""); threw INVALID_CHARACTER_ERR
15
PASS createAttributeNS(null, "<div>"); threw INVALID_CHARACTER_ERR
16
PASS createAttributeNS(null, "0div"); threw INVALID_CHARACTER_ERR
17
PASS createAttributeNS(null, "di v"); threw INVALID_CHARACTER_ERR
18
PASS createAttributeNS(null, "di<v"); threw INVALID_CHARACTER_ERR
19
PASS createAttributeNS(null, "-div"); threw INVALID_CHARACTER_ERR
20
PASS createAttributeNS(null, ".div"); threw INVALID_CHARACTER_ERR
21
PASS createAttributeNS("http://example.com/", "<div>"); threw INVALID_CHARACTER_ERR
22
PASS createAttributeNS("http://example.com/", "0div"); threw INVALID_CHARACTER_ERR
23
PASS createAttributeNS("http://example.com/", "di<v"); threw INVALID_CHARACTER_ERR
24
PASS createAttributeNS("http://example.com/", "-div"); threw INVALID_CHARACTER_ERR
25
PASS createAttributeNS("http://example.com/", ".div"); threw INVALID_CHARACTER_ERR
26
PASS createAttributeNS(null, ":div"); threw NAMESPACE_ERR
27
PASS createAttributeNS(null, "div:"); threw NAMESPACE_ERR
28
PASS createAttributeNS("http://example.com/", ":div"); threw NAMESPACE_ERR
29
PASS createAttributeNS("http://example.com/", "div:"); threw NAMESPACE_ERR
30
PASS createAttributeNS(null, "d:iv"); threw NAMESPACE_ERR
31
FAIL createAttributeNS(null, "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
32
FAIL createAttributeNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
33
FAIL createAttributeNS(null, "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
34
FAIL createAttributeNS("http://example.com/", "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
35
PASS createAttributeNS("http://example.com/", "a:0"); valid XML name, not a valid QName; threw INVALID_CHARACTER_ERR
36
PASS createAttributeNS("http://example.com/", "0:a"); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR
37
PASS createAttributeNS("http://example.com/", "a:_")
38
FAIL createAttributeNS("http://example.com/", "a:ெ"); non-ASCII character after colon is CombiningChar, which is NCNameChar but not (Letter | "_") so invalid at start of NCName (but still a valid XML name, hence not INVALID_CHARACTER_ERR); expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
39
PASS createAttributeNS("http://example.com/", "ெ:a"); non-ASCII character after colon is CombiningChar, which is NCNameChar but not (Letter | "_") so invalid at start of NCName (Gecko chooses to throw NAMESPACE_ERR here, but either is valid as this is both an invalid XML name and an invalid QName); threw INVALID_CHARACTER_ERR
40
PASS createAttributeNS("http://example.com/", "a:aெ")
41
PASS createAttributeNS("http://example.com/", "aெ:a")
42
PASS createAttributeNS("http://example.com/", "xml:test"); binding xml prefix wrong; threw NAMESPACE_ERR
43
PASS createAttributeNS("http://example.com/", "xmlns:test"); binding xmlns prefix wrong; threw NAMESPACE_ERR
44
PASS createAttributeNS("http://www.w3.org/2000/xmlns/", "x:test"); binding namespace namespace to wrong prefix; threw NAMESPACE_ERR
45
PASS createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:test")
46
PASS createAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:test")
47
PASS createAttributeNS("http://www.w3.org/XML/1998/namespace", "x:test")
48
PASS createAttributeNS("http://example.com/", "xmlns"); threw NAMESPACE_ERR
49
PASS successfullyParsed is true
50
51
TEST COMPLETE
52
- a/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err.html +13 lines
Line 0 a/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
5
<script src="../../js/resources/js-test-pre.js"></script>
6
</head>
7
<body>
8
<p id="description"></p>
9
<div id="console"></div>
10
<script src="resources/createAttributeNS-namespace-err.js"></script>
11
<script src="../../js/resources/js-test-post.js"></script>
12
</body>
13
</html>
- a/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt +138 lines
Line 0 a/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt_sec1
1
createElementNS tests from mozilla, attached to webkit bug 16833
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6
PASS document.createElementNS().toString() is "[object Element]"
7
PASS document.createElementNS("http://www.example.com").toString() is "[object Element]"
8
HTML tests:
9
PASS createElementNS(, )
10
PASS createElementNS(null, )
11
PASS createElementNS(undefined, null); threw INVALID_CHARACTER_ERR
12
PASS createElementNS(null, null); threw INVALID_CHARACTER_ERR
13
PASS createElementNS(null, ""); threw INVALID_CHARACTER_ERR
14
PASS createElementNS("", null); threw INVALID_CHARACTER_ERR
15
PASS createElementNS("", ""); threw INVALID_CHARACTER_ERR
16
PASS createElementNS(null, "<div>"); threw INVALID_CHARACTER_ERR
17
PASS createElementNS(null, "0div"); threw INVALID_CHARACTER_ERR
18
PASS createElementNS(null, "di v"); threw INVALID_CHARACTER_ERR
19
PASS createElementNS(null, "di<v"); threw INVALID_CHARACTER_ERR
20
PASS createElementNS(null, "-div"); threw INVALID_CHARACTER_ERR
21
PASS createElementNS(null, ".div"); threw INVALID_CHARACTER_ERR
22
PASS createElementNS("http://example.com/", "<div>"); threw INVALID_CHARACTER_ERR
23
PASS createElementNS("http://example.com/", "0div"); threw INVALID_CHARACTER_ERR
24
PASS createElementNS("http://example.com/", "di<v"); threw INVALID_CHARACTER_ERR
25
PASS createElementNS("http://example.com/", "-div"); threw INVALID_CHARACTER_ERR
26
PASS createElementNS("http://example.com/", ".div"); threw INVALID_CHARACTER_ERR
27
PASS createElementNS(null, ":div"); threw NAMESPACE_ERR
28
PASS createElementNS(null, "div:"); threw NAMESPACE_ERR
29
PASS createElementNS("http://example.com/", ":div"); threw NAMESPACE_ERR
30
PASS createElementNS("http://example.com/", "div:"); threw NAMESPACE_ERR
31
PASS createElementNS(null, "d:iv"); threw NAMESPACE_ERR
32
FAIL createElementNS(null, "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
33
FAIL createElementNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
34
FAIL createElementNS(null, "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
35
FAIL createElementNS("http://example.com/", "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
36
PASS createElementNS("http://example.com/", "a:0"); valid XML name, not a valid QName; threw INVALID_CHARACTER_ERR
37
PASS createElementNS("http://example.com/", "0:a"); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR
38
PASS createElementNS("http://example.com/", "a:_")
39
FAIL createElementNS("http://example.com/", "a:ெ"); non-ASCII character after colon is CombiningChar, which is NCNameChar but not (Letter | "_") so invalid at start of NCName (but still a valid XML name, hence not INVALID_CHARACTER_ERR); expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR
40
PASS createElementNS("http://example.com/", "ெ:a"); non-ASCII character after colon is CombiningChar, which is NCNameChar but not (Letter | "_") so invalid at start of NCName (Gecko chooses to throw NAMESPACE_ERR here, but either is valid as this is both an invalid XML name and an invalid QName); threw INVALID_CHARACTER_ERR
41
PASS createElementNS("http://example.com/", "a:aெ")
42
PASS createElementNS("http://example.com/", "aெ:a")
43
PASS createElementNS("http://example.com/", "xml:test"); binding xml prefix wrong; threw NAMESPACE_ERR
44
PASS createElementNS("http://example.com/", "xmlns:test"); binding xmlns prefix wrong; threw NAMESPACE_ERR
45
PASS createElementNS("http://www.w3.org/2000/xmlns/", "x:test"); binding namespace namespace to wrong prefix; threw NAMESPACE_ERR
46
PASS createElementNS("http://www.w3.org/2000/xmlns/", "xmlns:test")
47
PASS createElementNS("http://www.w3.org/XML/1998/namespace", "xml:test")
48
PASS createElementNS("http://www.w3.org/XML/1998/namespace", "x:test")
49
PASS createElement()
50
PASS createElement(null, undefined); threw INVALID_CHARACTER_ERR
51
PASS createElement("", undefined); threw INVALID_CHARACTER_ERR
52
PASS createElement("<div>", undefined); threw INVALID_CHARACTER_ERR
53
PASS createElement("0div", undefined); threw INVALID_CHARACTER_ERR
54
PASS createElement("di v", undefined); threw INVALID_CHARACTER_ERR
55
PASS createElement("di<v", undefined); threw INVALID_CHARACTER_ERR
56
PASS createElement("-div", undefined); threw INVALID_CHARACTER_ERR
57
PASS createElement(".div", undefined); threw INVALID_CHARACTER_ERR
58
PASS createElement(":"); valid XML name, invalid QName
59
PASS createElement(":div"); valid XML name, invalid QName
60
PASS createElement("div:"); valid XML name, invalid QName
61
PASS createElement("d:iv")
62
PASS createElement("a:b:c"); valid XML name, invalid QName
63
PASS createElement("a::c"); valid XML name, invalid QName
64
PASS createElement("a::c:"); valid XML name, invalid QName
65
PASS createElement("a:0"); valid XML name, not a valid QName
66
PASS createElement("0:a", undefined); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR
67
PASS createElement("a:_")
68
PASS createElement("a:ெ"); non-ASCII character after colon is CombiningChar, which is valid in pre-namespace XML
69
PASS createElement("ெ:a", undefined); not a valid start character; threw INVALID_CHARACTER_ERR
70
PASS createElement("a:aெ")
71
PASS createElement("aெ:a")
72
PASS createElement("xml:test")
73
PASS createElement("xmlns:test")
74
PASS createElement("x:test")
75
PASS createElement("xmlns:test")
76
PASS createElement("SOAP-ENV:Body")
77
XHTML createElement tests:
78
PASS createElement()
79
PASS createElement(null, undefined); threw INVALID_CHARACTER_ERR
80
PASS createElement("", undefined); threw INVALID_CHARACTER_ERR
81
PASS createElement("<div>", undefined); threw INVALID_CHARACTER_ERR
82
PASS createElement("0div", undefined); threw INVALID_CHARACTER_ERR
83
PASS createElement("di v", undefined); threw INVALID_CHARACTER_ERR
84
PASS createElement("di<v", undefined); threw INVALID_CHARACTER_ERR
85
PASS createElement("-div", undefined); threw INVALID_CHARACTER_ERR
86
PASS createElement(".div", undefined); threw INVALID_CHARACTER_ERR
87
PASS createElement(":"); valid XML name, invalid QName
88
PASS createElement(":div"); valid XML name, invalid QName
89
PASS createElement("div:"); valid XML name, invalid QName
90
PASS createElement("d:iv")
91
PASS createElement("a:b:c"); valid XML name, invalid QName
92
PASS createElement("a::c"); valid XML name, invalid QName
93
PASS createElement("a::c:"); valid XML name, invalid QName
94
PASS createElement("a:0"); valid XML name, not a valid QName
95
PASS createElement("0:a", undefined); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR
96
PASS createElement("a:_")
97
PASS createElement("a:ெ"); non-ASCII character after colon is CombiningChar, which is valid in pre-namespace XML
98
PASS createElement("ெ:a", undefined); not a valid start character; threw INVALID_CHARACTER_ERR
99
PASS createElement("a:aெ")
100
PASS createElement("aெ:a")
101
PASS createElement("xml:test")
102
PASS createElement("xmlns:test")
103
PASS createElement("x:test")
104
PASS createElement("xmlns:test")
105
PASS createElement("SOAP-ENV:Body")
106
XML createElement tests:
107
PASS createElement()
108
PASS createElement(null, undefined); threw INVALID_CHARACTER_ERR
109
PASS createElement("", undefined); threw INVALID_CHARACTER_ERR
110
PASS createElement("<div>", undefined); threw INVALID_CHARACTER_ERR
111
PASS createElement("0div", undefined); threw INVALID_CHARACTER_ERR
112
PASS createElement("di v", undefined); threw INVALID_CHARACTER_ERR
113
PASS createElement("di<v", undefined); threw INVALID_CHARACTER_ERR
114
PASS createElement("-div", undefined); threw INVALID_CHARACTER_ERR
115
PASS createElement(".div", undefined); threw INVALID_CHARACTER_ERR
116
PASS createElement(":"); valid XML name, invalid QName
117
PASS createElement(":div"); valid XML name, invalid QName
118
PASS createElement("div:"); valid XML name, invalid QName
119
PASS createElement("d:iv")
120
PASS createElement("a:b:c"); valid XML name, invalid QName
121
PASS createElement("a::c"); valid XML name, invalid QName
122
PASS createElement("a::c:"); valid XML name, invalid QName
123
PASS createElement("a:0"); valid XML name, not a valid QName
124
PASS createElement("0:a", undefined); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR
125
PASS createElement("a:_")
126
PASS createElement("a:ெ"); non-ASCII character after colon is CombiningChar, which is valid in pre-namespace XML
127
PASS createElement("ெ:a", undefined); not a valid start character; threw INVALID_CHARACTER_ERR
128
PASS createElement("a:aெ")
129
PASS createElement("aெ:a")
130
PASS createElement("xml:test")
131
PASS createElement("xmlns:test")
132
PASS createElement("x:test")
133
PASS createElement("xmlns:test")
134
PASS createElement("SOAP-ENV:Body")
135
PASS successfullyParsed is true
136
137
TEST COMPLETE
138
- a/LayoutTests/fast/dom/Document/createElementNS-namespace-err.html +13 lines
Line 0 a/LayoutTests/fast/dom/Document/createElementNS-namespace-err.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
5
<script src="../../js/resources/js-test-pre.js"></script>
6
</head>
7
<body>
8
<p id="description"></p>
9
<div id="console"></div>
10
<script src="resources/createElementNS-namespace-err.js"></script>
11
<script src="../../js/resources/js-test-post.js"></script>
12
</body>
13
</html>
- a/LayoutTests/fast/dom/Document/resources/TEMPLATE.html +13 lines
Line 0 a/LayoutTests/fast/dom/Document/resources/TEMPLATE.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
5
<script src="../../js/resources/js-test-pre.js"></script>
6
</head>
7
<body>
8
<p id="description"></p>
9
<div id="console"></div>
10
<script src="YOUR_JS_FILE_HERE"></script>
11
<script src="../../js/resources/js-test-post.js"></script>
12
</body>
13
</html>
- a/LayoutTests/fast/dom/Document/resources/createAttributeNS-namespace-err.js +135 lines
Line 0 a/LayoutTests/fast/dom/Document/resources/createAttributeNS-namespace-err.js_sec1
1
description("createAttirbuteNS tests adapted from createElementNS tests attached to webkit bug 16833");
2
3
function assert(c, m)
4
{
5
    if (!c)
6
        testFailed(m);
7
    else
8
        testPassed(m);
9
}
10
11
function stringForExceptionCode(c)
12
{
13
    var exceptionName;
14
    switch(c) {
15
        case DOMException.INVALID_CHARACTER_ERR:
16
            exceptionName = "INVALID_CHARACTER_ERR";
17
            break;
18
        case DOMException.NAMESPACE_ERR:
19
            exceptionName = "NAMESPACE_ERR";
20
    }
21
    if (exceptionName)
22
        return exceptionName; // + "(" + c + ")";
23
    return c;
24
}
25
26
function assertEquals(actual, expect, m)
27
{
28
    if (actual !== expect) {
29
        m += "; expected " + stringForExceptionCode(expect) + ", threw " + stringForExceptionCode(actual);
30
        testFailed(m);
31
    } else {
32
        m += "; threw " + stringForExceptionCode(actual);;
33
        testPassed(m);
34
    }
35
}
36
37
var allNSTests = [
38
   { args: [undefined, undefined] },
39
   { args: [null, undefined] },
40
   { args: [undefined, null], code: 5 },
41
   { args: [null, null], code: 5 },
42
   { args: [null, ""], code: 5 },
43
   { args: ["", null], code: 5 },
44
   { args: ["", ""], code: 5 },
45
   { args: [null, "<div>"], code: 5 },
46
   { args: [null, "0div"], code: 5 },
47
   { args: [null, "di v"], code: 5 },
48
   { args: [null, "di<v"], code: 5 },
49
   { args: [null, "-div"], code: 5 },
50
   { args: [null, ".div"], code: 5 },
51
   { args: ["http://example.com/", "<div>"], code: 5 },
52
   { args: ["http://example.com/", "0div"], code: 5 },
53
   { args: ["http://example.com/", "di<v"], code: 5 },
54
   { args: ["http://example.com/", "-div"], code: 5 },
55
   { args: ["http://example.com/", ".div"], code: 5 },
56
   { args: [null, ":div"], code: 14 },
57
   { args: [null, "div:"], code: 14 },
58
   { args: ["http://example.com/", ":div"], code: 14 },
59
   { args: ["http://example.com/", "div:"], code: 14 },
60
   { args: [null, "d:iv"], code: 14 },
61
   { args: [null, "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
62
   { args: ["http://example.com/", "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
63
   { args: [null, "a::c"], code: 14, message: "valid XML name, invalid QName" },
64
   { args: ["http://example.com/", "a::c"], code: 14, message: "valid XML name, invalid QName" },
65
   { args: ["http://example.com/", "a:0"], code: 5, message: "valid XML name, not a valid QName" },
66
   { args: ["http://example.com/", "0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
67
   { args: ["http://example.com/", "a:_"] },
68
   { args: ["http://example.com/", "a:\u0BC6"], code: 14,
69
     message: "non-ASCII character after colon is CombiningChar, which is " +
70
              "NCNameChar but not (Letter | \"_\") so invalid at start of " +
71
              "NCName (but still a valid XML name, hence not INVALID_CHARACTER_ERR)" },
72
   { args: ["http://example.com/", "\u0BC6:a"], code: 5,
73
     message: "non-ASCII character after colon is CombiningChar, which is " +
74
              "NCNameChar but not (Letter | \"_\") so invalid at start of " +
75
              "NCName (Gecko chooses to throw NAMESPACE_ERR here, but either is valid " +
76
              "as this is both an invalid XML name and an invalid QName)" },
77
   { args: ["http://example.com/", "a:a\u0BC6"] },
78
   { args: ["http://example.com/", "a\u0BC6:a"] },
79
   { args: ["http://example.com/", "xml:test"], code: 14, message: "binding xml prefix wrong" },
80
   { args: ["http://example.com/", "xmlns:test"], code: 14, message: "binding xmlns prefix wrong" },
81
   { args: ["http://www.w3.org/2000/xmlns/", "x:test"], code: 14, message: "binding namespace namespace to wrong prefix" },
82
   { args: ["http://www.w3.org/2000/xmlns/", "xmlns:test"] },
83
   { args: ["http://www.w3.org/XML/1998/namespace", "xml:test"] },
84
   { args: ["http://www.w3.org/XML/1998/namespace", "x:test"] },
85
   { args: ["http://example.com/", "xmlns"], code: 14 }, // from the createAttributeNS section
86
];
87
88
function sourceify(v)
89
{
90
    switch (typeof v) {
91
    case "undefined":
92
        return v;
93
94
    case "string":
95
        return '"' + v.replace('"', '\\"') + '"';
96
97
    default:
98
        return String(v);
99
    }
100
}
101
102
function runNSTests()
103
{
104
    var createFunction = document.createAttributeNS;
105
    var createFunctionName = "createAttributeNS";
106
    var doc = document;
107
108
    for (var i = 0, sz = allNSTests.length; i < sz; i++) {
109
        var test = allNSTests[i];
110
111
        var code = -1;
112
        var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]);
113
        try {
114
            createFunction.apply(doc, test.args);
115
            var msg = createFunctionName + "(" + argStr + ")";
116
            if ("message" in test)
117
                msg += "; " + test.message;
118
            assert(!("code" in test), msg);
119
        } catch (e) {
120
            var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]);
121
            msg = createFunctionName + "(" + argStr + ")";
122
            if ("message" in test)
123
                msg += "; " + test.message;
124
            assertEquals(e.code, test.code || "expected no exception", msg);
125
        }
126
    }
127
}
128
129
// Moz throws a "Not enough arguments" exception in these, we don't:
130
shouldBeEqualToString("document.createAttributeNS().toString()", "[object Attr]");
131
shouldBeEqualToString("document.createAttributeNS(\"http://www.example.com\").toString()", "[object Attr]");
132
133
runNSTests();
134
135
var successfullyParsed = true;
- a/LayoutTests/fast/dom/Document/resources/createElementNS-namespace-err.js +180 lines
Line 0 a/LayoutTests/fast/dom/Document/resources/createElementNS-namespace-err.js_sec1
1
description("createElementNS tests from mozilla, attached to webkit bug 16833");
2
3
function assert(c, m)
4
{
5
    if (!c)
6
        testFailed(m);
7
    else
8
        testPassed(m);
9
}
10
11
function stringForExceptionCode(c)
12
{
13
    var exceptionName;
14
    switch(c) {
15
        case DOMException.INVALID_CHARACTER_ERR:
16
            exceptionName = "INVALID_CHARACTER_ERR";
17
            break;
18
        case DOMException.NAMESPACE_ERR:
19
            exceptionName = "NAMESPACE_ERR";
20
    }
21
    if (exceptionName)
22
        return exceptionName; // + "(" + c + ")";
23
    return c;
24
}
25
26
function assertEquals(actual, expect, m)
27
{
28
    if (actual !== expect) {
29
        m += "; expected " + stringForExceptionCode(expect) + ", threw " + stringForExceptionCode(actual);
30
        testFailed(m);
31
    } else {
32
        m += "; threw " + stringForExceptionCode(actual);;
33
        testPassed(m);
34
    }
35
}
36
37
var allNSTests = [
38
   { args: [undefined, undefined] },
39
   { args: [null, undefined] },
40
   { args: [undefined, null], code: 5 },
41
   { args: [null, null], code: 5 },
42
   { args: [null, ""], code: 5 },
43
   { args: ["", null], code: 5 },
44
   { args: ["", ""], code: 5 },
45
   { args: [null, "<div>"], code: 5 },
46
   { args: [null, "0div"], code: 5 },
47
   { args: [null, "di v"], code: 5 },
48
   { args: [null, "di<v"], code: 5 },
49
   { args: [null, "-div"], code: 5 },
50
   { args: [null, ".div"], code: 5 },
51
   { args: ["http://example.com/", "<div>"], code: 5 },
52
   { args: ["http://example.com/", "0div"], code: 5 },
53
   { args: ["http://example.com/", "di<v"], code: 5 },
54
   { args: ["http://example.com/", "-div"], code: 5 },
55
   { args: ["http://example.com/", ".div"], code: 5 },
56
   { args: [null, ":div"], code: 14 },
57
   { args: [null, "div:"], code: 14 },
58
   { args: ["http://example.com/", ":div"], code: 14 },
59
   { args: ["http://example.com/", "div:"], code: 14 },
60
   { args: [null, "d:iv"], code: 14 },
61
   { args: [null, "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
62
   { args: ["http://example.com/", "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
63
   { args: [null, "a::c"], code: 14, message: "valid XML name, invalid QName" },
64
   { args: ["http://example.com/", "a::c"], code: 14, message: "valid XML name, invalid QName" },
65
   { args: ["http://example.com/", "a:0"], code: 5, message: "valid XML name, not a valid QName" },
66
   { args: ["http://example.com/", "0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
67
   { args: ["http://example.com/", "a:_"] },
68
   { args: ["http://example.com/", "a:\u0BC6"], code: 14,
69
     message: "non-ASCII character after colon is CombiningChar, which is " +
70
              "NCNameChar but not (Letter | \"_\") so invalid at start of " +
71
              "NCName (but still a valid XML name, hence not INVALID_CHARACTER_ERR)" },
72
   { args: ["http://example.com/", "\u0BC6:a"], code: 5,
73
     message: "non-ASCII character after colon is CombiningChar, which is " +
74
              "NCNameChar but not (Letter | \"_\") so invalid at start of " +
75
              "NCName (Gecko chooses to throw NAMESPACE_ERR here, but either is valid " +
76
              "as this is both an invalid XML name and an invalid QName)" },
77
   { args: ["http://example.com/", "a:a\u0BC6"] },
78
   { args: ["http://example.com/", "a\u0BC6:a"] },
79
   { args: ["http://example.com/", "xml:test"], code: 14, message: "binding xml prefix wrong" },
80
   { args: ["http://example.com/", "xmlns:test"], code: 14, message: "binding xmlns prefix wrong" },
81
   { args: ["http://www.w3.org/2000/xmlns/", "x:test"], code: 14, message: "binding namespace namespace to wrong prefix" },
82
   { args: ["http://www.w3.org/2000/xmlns/", "xmlns:test"] },
83
   { args: ["http://www.w3.org/XML/1998/namespace", "xml:test"] },
84
   { args: ["http://www.w3.org/XML/1998/namespace", "x:test"] },
85
];
86
87
var allNoNSTests = [
88
   { args: [undefined] },
89
   { args: [null], code: 5 },
90
   { args: [""], code: 5 },
91
   { args: ["<div>"], code: 5 },
92
   { args: ["0div"], code: 5 },
93
   { args: ["di v"], code: 5 },
94
   { args: ["di<v"], code: 5 },
95
   { args: ["-div"], code: 5 },
96
   { args: [".div"], code: 5 },
97
   { args: [":"], message: "valid XML name, invalid QName" },
98
   { args: [":div"], message: "valid XML name, invalid QName" },
99
   { args: ["div:"], message: "valid XML name, invalid QName" },
100
   { args: ["d:iv"] },
101
   { args: ["a:b:c"], message: "valid XML name, invalid QName" },
102
   { args: ["a::c"], message: "valid XML name, invalid QName" },
103
   { args: ["a::c:"], message: "valid XML name, invalid QName" },
104
   { args: ["a:0"], message: "valid XML name, not a valid QName" },
105
   { args: ["0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
106
   { args: ["a:_"] },
107
   { args: ["a:\u0BC6"],
108
     message: "non-ASCII character after colon is CombiningChar, which is " +
109
              "valid in pre-namespace XML" },
110
   { args: ["\u0BC6:a"], code: 5, message: "not a valid start character" },
111
   { args: ["a:a\u0BC6"] },
112
   { args: ["a\u0BC6:a"] },
113
   { args: ["xml:test"] },
114
   { args: ["xmlns:test"] },
115
   { args: ["x:test"] },
116
   { args: ["xmlns:test"] },
117
   { args: ["SOAP-ENV:Body"] }, // From Yahoo Mail Beta
118
];
119
120
function sourceify(v)
121
{
122
    switch (typeof v) {
123
        case "undefined":
124
            return v;
125
        case "string":
126
            return '"' + v.replace('"', '\\"') + '"';
127
        default:
128
            return String(v);
129
    }
130
}
131
132
function sourceifyArgs(args)
133
{
134
    var copy = new Array(args.length);
135
    for (var i = 0, sz = args.length; i < sz; i++)
136
        copy[i] = sourceify(args[i]);
137
138
    return copy.join(", ");
139
}
140
141
function runNSTests(tests, doc, createFunctionName)
142
{
143
    for (var i = 0, sz = tests.length; i < sz; i++) {
144
        var test = tests[i];
145
146
        var code = -1;
147
        var argStr = sourceifyArgs(test.args);
148
        try {
149
            doc[createFunctionName].apply(doc, test.args);
150
            var msg = createFunctionName + "(" + argStr + ")";
151
            if ("message" in test)
152
                msg += "; " + test.message;
153
            assert(!("code" in test), msg);
154
        } catch (e) {
155
            var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]);
156
            msg = createFunctionName + "(" + argStr + ")";
157
            if ("message" in test)
158
                msg += "; " + test.message;
159
            assertEquals(e.code, test.code || "expected no exception", msg);
160
        }
161
    }
162
}
163
164
// Moz throws a "Not enough arguments" exception in these, we don't:
165
shouldBeEqualToString("document.createElementNS().toString()", "[object Element]");
166
shouldBeEqualToString("document.createElementNS(\"http://www.example.com\").toString()", "[object Element]");
167
168
debug("HTML tests:")
169
runNSTests(allNSTests, document, "createElementNS");
170
runNSTests(allNoNSTests, document, "createElement");
171
172
debug("XHTML createElement tests:")
173
var xhtmlDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
174
runNSTests(allNoNSTests, xhtmlDoc, "createElement");
175
176
debug("XML createElement tests:")
177
var xmlDoc = document.implementation.createDocument("http://www.example.com/foo", "example", null);
178
runNSTests(allNoNSTests, xmlDoc, "createElement");
179
180
var successfullyParsed = true;
- a/WebCore/dom/Document.cpp -27 / +62 lines
Lines 107-112 a/WebCore/dom/Document.cpp_sec1
107
#include "UIEvent.h"
107
#include "UIEvent.h"
108
#include "WheelEvent.h"
108
#include "WheelEvent.h"
109
#include "XMLHttpRequest.h"
109
#include "XMLHttpRequest.h"
110
#include "XMLNames.h"
110
#include "XMLTokenizer.h"
111
#include "XMLTokenizer.h"
111
#include "kjs_binding.h"
112
#include "kjs_binding.h"
112
#include "kjs_proxy.h"
113
#include "kjs_proxy.h"
Lines 514-528 Element* Document::documentElement() const a/WebCore/dom/Document.cpp_sec2
514
515
515
PassRefPtr<Element> Document::createElement(const String &name, ExceptionCode& ec)
516
PassRefPtr<Element> Document::createElement(const String &name, ExceptionCode& ec)
516
{
517
{
517
    if (m_isXHTML) {
518
    if (!isValidName(name)) {
518
        if (!isValidName(name)) {
519
        ec = INVALID_CHARACTER_ERR;
519
            ec = INVALID_CHARACTER_ERR;
520
        return 0;
520
            return 0;
521
    }
521
        }
522
523
    if (m_isXHTML)
524
        return HTMLElementFactory::createHTMLElement(name, this, 0, false);
522
525
523
        return HTMLElementFactory::createHTMLElement(AtomicString(name), this, 0, false);
526
    return createElement(QualifiedName(nullAtom, name, nullAtom), false, ec);
524
    } else
525
        return createElementNS(nullAtom, name, ec);
526
}
527
}
527
528
528
PassRefPtr<DocumentFragment> Document::createDocumentFragment()
529
PassRefPtr<DocumentFragment> Document::createDocumentFragment()
Lines 716-721 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec) a/WebCore/dom/Document.cpp_sec3
716
    return source;
717
    return source;
717
}
718
}
718
719
720
static bool hasNamespaceError(const QualifiedName& qName)
721
{
722
    static const AtomicString xmlnsNamespaceURI = "http://www.w3.org/2000/xmlns/";
723
    static const AtomicString xmlns = "xmlns";
724
    static const AtomicString xml = "xml";
725
726
    // These checks are from DOM Core Level 2, createElementNS
727
    // http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrElNS
728
    if (qName.prefix() == emptyAtom) // createElementNS(null, ":div")
729
        return true;
730
    if (qName.localName().isEmpty()) // createElementNS(null, ""), createElementNS(null, null), createElementNS()
731
        return true;
732
    if (!qName.prefix().isEmpty() && qName.namespaceURI().isNull()) // createElementNS(null, "html:div")
733
        return true;
734
    if (qName.prefix() == xml && qName.namespaceURI() != XMLNames::xmlNamespaceURI) // createElementNS("http://www.example.com", "xml:lang")
735
        return true;
736
737
    // Required by DOM Level 3 Core and unspecified by DOM Level 2 Core:
738
    // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS
739
    // createElementNS("http://www.w3.org/2000/xmlns/", "foo:bar"), createElementNS(null, "xmlns:bar")
740
    if ((qName.prefix() == xmlns && qName.namespaceURI() != xmlnsNamespaceURI) || (qName.prefix() != xmlns && qName.namespaceURI() == xmlnsNamespaceURI))
741
        return true;
742
743
    return false;
744
}
745
719
// FIXME: This should really be in a possible ElementFactory class
746
// FIXME: This should really be in a possible ElementFactory class
720
PassRefPtr<Element> Document::createElement(const QualifiedName& qName, bool createdByParser, ExceptionCode& ec)
747
PassRefPtr<Element> Document::createElement(const QualifiedName& qName, bool createdByParser, ExceptionCode& ec)
721
{
748
{
Lines 732-748 PassRefPtr<Element> Document::createElement(const QualifiedName& qName, bool cre a/WebCore/dom/Document.cpp_sec4
732
    if (!e)
759
    if (!e)
733
        e = new Element(qName, document());
760
        e = new Element(qName, document());
734
    
761
    
762
    // FIXME: The element factories should be fixed to not ignore qName.prefix()
763
    // Instead they should pass the entire qName into element creation so we don't
764
    // need to manually set the prefix after creation.
765
    // Then this code can become ASSERT(qName == e.qname());
766
    // and Document::createElement can stop taking ExceptionCode& as well.
735
    if (e && !qName.prefix().isNull()) {
767
    if (e && !qName.prefix().isNull()) {
736
        ec = 0;
768
        ec = 0;
737
        e->setPrefix(qName.prefix(), ec);
769
        e->setPrefix(qName.prefix(), ec);
738
        if (ec)
770
        if (ec)
739
            return 0;
771
            return 0;
740
    }    
772
    }
741
    
773
    
742
    return e.release();
774
    return e.release();
743
}
775
}
744
776
745
PassRefPtr<Element> Document::createElementNS(const String &_namespaceURI, const String &qualifiedName, ExceptionCode& ec)
777
PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec)
746
{
778
{
747
    String prefix, localName;
779
    String prefix, localName;
748
    if (!parseQualifiedName(qualifiedName, prefix, localName)) {
780
    if (!parseQualifiedName(qualifiedName, prefix, localName)) {
Lines 750-758 PassRefPtr<Element> Document::createElementNS(const String &_namespaceURI, const a/WebCore/dom/Document.cpp_sec5
750
        return 0;
782
        return 0;
751
    }
783
    }
752
784
753
    RefPtr<Element> e;
785
    QualifiedName qName(prefix, localName, namespaceURI);
754
    QualifiedName qName = QualifiedName(AtomicString(prefix), AtomicString(localName), AtomicString(_namespaceURI));
786
    if (hasNamespaceError(qName)) {
755
    
787
        ec = NAMESPACE_ERR;
788
        return 0;
789
    }
790
756
    return createElement(qName, false, ec);
791
    return createElement(qName, false, ec);
757
}
792
}
758
793
Lines 2784-2790 bool Document::isValidName(const String &name) a/WebCore/dom/Document.cpp_sec6
2784
    return true;
2819
    return true;
2785
}
2820
}
2786
2821
2787
bool Document::parseQualifiedName(const String &qualifiedName, String &prefix, String &localName)
2822
bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName)
2788
{
2823
{
2789
    unsigned length = qualifiedName.length();
2824
    unsigned length = qualifiedName.length();
2790
2825
Lines 3489-3517 Document *Document::topDocument() const a/WebCore/dom/Document.cpp_sec7
3489
    return doc;
3524
    return doc;
3490
}
3525
}
3491
3526
3492
PassRefPtr<Attr> Document::createAttributeNS(const String &namespaceURI, const String &qualifiedName, ExceptionCode& ec)
3527
PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec)
3493
{
3528
{
3494
    if (qualifiedName.isNull()) {
3529
    String prefix, localName;
3495
        ec = NAMESPACE_ERR;
3530
    if (!parseQualifiedName(qualifiedName, prefix, localName)) {
3531
        ec = INVALID_CHARACTER_ERR;
3496
        return 0;
3532
        return 0;
3497
    }
3533
    }
3498
3534
3499
    String localName = qualifiedName;
3535
    QualifiedName qName(prefix, localName, namespaceURI);
3500
    String prefix;
3536
    if (hasNamespaceError(qName)) {
3501
    int colonpos;
3537
        ec = NAMESPACE_ERR;
3502
    if ((colonpos = qualifiedName.find(':')) >= 0) {
3538
        return 0;
3503
        prefix = qualifiedName.substring(0, colonpos);
3504
        localName = qualifiedName.substring(colonpos + 1);
3505
    }
3539
    }
3506
3540
3507
    if (!isValidName(localName)) {
3541
    // Spec: DOM Level 2 Core: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrAttrNS
3508
        ec = INVALID_CHARACTER_ERR;
3542
    if (qName.localName() == "xmlns" && qName.namespaceURI() != "http://www.w3.org/2000/xmlns/") {
3543
        ec = NAMESPACE_ERR;
3509
        return 0;
3544
        return 0;
3510
    }
3545
    }
3511
    
3546
3512
    // FIXME: Assume this is a mapped attribute, since createAttribute isn't namespace-aware.  There's no harm to XML
3547
    // FIXME: Assume this is a mapped attribute, since createAttribute isn't namespace-aware.  There's no harm to XML
3513
    // documents if we're wrong.
3548
    // documents if we're wrong.
3514
    return new Attr(0, this, new MappedAttribute(QualifiedName(prefix, localName, namespaceURI), StringImpl::empty()));
3549
    return new Attr(0, this, new MappedAttribute(qName, StringImpl::empty()));
3515
}
3550
}
3516
3551
3517
#if ENABLE(SVG)
3552
#if ENABLE(SVG)
- a/WebCore/dom/Document.idl -3 / +3 lines
Lines 33-39 module core { a/WebCore/dom/Document.idl_sec1
33
        readonly attribute DOMImplementation implementation;
33
        readonly attribute DOMImplementation implementation;
34
        readonly attribute Element documentElement;
34
        readonly attribute Element documentElement;
35
35
36
        Element            createElement(in DOMString tagName)
36
        Element            createElement(in [ConvertNullToNullString] DOMString tagName)
37
            raises (DOMException);
37
            raises (DOMException);
38
        DocumentFragment   createDocumentFragment();
38
        DocumentFragment   createDocumentFragment();
39
        Text               createTextNode(in DOMString data);
39
        Text               createTextNode(in DOMString data);
Lines 55-64 module core { a/WebCore/dom/Document.idl_sec2
55
                                       in boolean deep)
55
                                       in boolean deep)
56
            raises (DOMException);
56
            raises (DOMException);
57
        [OldStyleObjC] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI,
57
        [OldStyleObjC] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI,
58
                                               in DOMString qualifiedName)
58
                                               in [ConvertNullToNullString] DOMString qualifiedName)
59
            raises (DOMException);
59
            raises (DOMException);
60
        [OldStyleObjC] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
60
        [OldStyleObjC] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
61
                                              in DOMString qualifiedName)
61
                                              in [ConvertNullToNullString] DOMString qualifiedName)
62
            raises (DOMException);
62
            raises (DOMException);
63
        [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
63
        [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
64
                                                       in DOMString localName);
64
                                                       in DOMString localName);

Return to Bug 16833