Add support for 8 bits strings to Document::isValidName()
https://bugs.webkit.org/show_bug.cgi?id=74784
Patch by Benjamin Poulain <bpoulain@apple.com> on 2011-12-19
Reviewed by Darin Adler.
Source/WebCore:
Avoid the conversion to 16bits when we are in the ASCII fast path,
otherwise fallback to the Unicode testing in 16bits.
* dom/Document.cpp:
(WebCore::isValidNameASCII):
(WebCore::Document::isValidName):
LayoutTests:
Add tests for valid and invalid names for nodes.
* fast/dom/Document/createElement-invalid-names-expected.txt: Added.
* fast/dom/Document/createElement-invalid-names.html: Added.
* fast/dom/Document/createElement-valid-names-expected.txt: Added.
* fast/dom/Document/createElement-valid-names.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/dom/Document/createElement-invalid-names.html b/LayoutTests/fast/dom/Document/createElement-invalid-names.html
new file mode 100644
index 0000000..0879df7
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/createElement-invalid-names.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Test various valid name for elements according to the definition of DOM Level 2.")
+
+var nameList = [
+ // Invalid first Char
+ '0ascii',
+ '.Ascii',
+ '-Ascii',
+ ' ascii',
+ ' ascii',
+ '֑sc.ii',
+ '⃣scii',
+ 'िascii',
+ 'ʳascii',
+ // Invalid other char
+ 'asc i',
+ 'asc i',
+ 'asciiⅦ'
+ ];
+
+for (var i in nameList)
+ shouldThrow("document.createElement('" + nameList[i] +"')", "'Error: INVALID_CHARACTER_ERR: DOM Exception 5'");
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>