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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html

Issue 2477133002: Import wpt@306326cfe973b6c7019c50879ad03b02825c7539 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html
index 59fa02d83f56bdb08c1b5e5b95a2c82de1fb0df0..bacaff0f6a00273f611cf3eb7e8d3a686e5b8599 100644
--- a/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html
+++ b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html
@@ -9,6 +9,8 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
+<iframe src="/common/dummy.xml"></iframe>
+<iframe src="/common/dummy.xhtml"></iframe>
<script>
function toASCIIUppercase(str) {
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
@@ -22,64 +24,134 @@ function toASCIIUppercase(str) {
}
return res;
}
-test(function() {
- var HTMLNS = "http://www.w3.org/1999/xhtml",
- valid = [
- //[input, localName],
- [undefined, "undefined"],
- [null, "null"],
- ["foo", "foo"],
- ["f1oo", "f1oo"],
- ["foo1", "foo1"],
- ["f\u0300oo", "f\u0300oo"],
- ["foo\u0300", "foo\u0300"],
- [":foo", ":foo"],
- ["f:oo", "f:oo"],
- ["foo:", "foo:"],
- ["xml", "xml"],
- ["xmlns", "xmlns"],
- ["xmlfoo", "xmlfoo"],
- ["xml:foo", "xml:foo"],
- ["xmlns:foo", "xmlns:foo"],
- ["xmlfoo:bar", "xmlfoo:bar"],
- ["svg", "svg"],
- ["math", "math"],
- ["FOO", "foo"],
- ["mar\u212a", "mar\u212a"],
- ["\u0130nput", "\u0130nput"],
- ["\u0131nput", "\u0131nput"]
- ],
- invalid = [
- "",
- "1foo",
- "\u0300foo",
- "}foo",
- "f}oo",
- "foo}",
- "\ufffffoo",
- "f\uffffoo",
- "foo\uffff",
- "<foo",
- "foo>",
- "<foo>",
- "f<oo"
- ]
+function toASCIILowercase(str) {
+ var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
+ var res = "";
+ for (var i = 0; i < str.length; ++i) {
+ if ("A" <= str[i] && str[i] <= "Z") {
+ res += String.fromCharCode(str.charCodeAt(i) + diff);
+ } else {
+ res += str[i];
+ }
+ }
+ return res;
+}
+var HTMLNS = "http://www.w3.org/1999/xhtml",
+ valid = [
+ undefined,
+ null,
+ "foo",
+ "f1oo",
+ "foo1",
+ "f\u0BC6",
+ "foo\u0BC6",
+ ":",
+ ":foo",
+ "f:oo",
+ "foo:",
+ "f:o:o",
+ "f::oo",
+ "f::oo:",
+ "foo:0",
+ "foo:_",
+ // combining char after :, invalid QName but valid Name
+ "foo:\u0BC6",
+ "foo:foo\u0BC6",
+ "foo\u0BC6:foo",
+ "xml",
+ "xmlns",
+ "xmlfoo",
+ "xml:foo",
+ "xmlns:foo",
+ "xmlfoo:bar",
+ "svg",
+ "math",
+ "FOO",
+ // Test that non-ASCII chars don't get uppercased/lowercased
+ "mar\u212a",
+ "\u0130nput",
+ "\u0131nput",
+ ],
+ invalid = [
+ "",
+ "1foo",
+ "1:foo",
+ "fo o",
+ "\u0BC6foo",
+ "}foo",
+ "f}oo",
+ "foo}",
+ "\ufffffoo",
+ "f\uffffoo",
+ "foo\uffff",
+ "<foo",
+ "foo>",
+ "<foo>",
+ "f<oo",
+ "-foo",
+ ".foo",
+ "\u0BC6",
+ ]
+
+var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');
+var xhtmlIframe = document.querySelector('[src="/common/dummy.xhtml"]');
+
+function getWin(desc) {
+ if (desc == "HTML document") {
+ return window;
+ }
+ if (desc == "XML document") {
+ assert_equals(xmlIframe.contentDocument.documentElement.textContent,
+ "Dummy XML document", "XML document didn't load");
+ return xmlIframe.contentWindow;
+ }
+ if (desc == "XHTML document") {
+ assert_equals(xhtmlIframe.contentDocument.documentElement.textContent,
+ "Dummy XHTML document", "XHTML document didn't load");
+ return xhtmlIframe.contentWindow;
+ }
+}
+
- valid.forEach(function(t) {
- test(function() {
- var elt = document.createElement(t[0])
- assert_true(elt instanceof Element)
- assert_true(elt instanceof Node)
- assert_equals(elt.localName, t[1])
- assert_equals(elt.tagName, toASCIIUppercase(t[1]))
- assert_equals(elt.prefix, null)
- assert_equals(elt.namespaceURI, HTMLNS)
- }, "createElement(" + format_value(t[0]) + ")");
+valid.forEach(function(t) {
+ ["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
+ async_test(function(testObj) {
+ window.addEventListener("load", function() {
+ testObj.step(function() {
+ var win = getWin(desc);
+ var doc = win.document;
+ var elt = doc.createElement(t)
+ assert_true(elt instanceof win.Element, "instanceof Element")
+ assert_true(elt instanceof win.Node, "instanceof Node")
+ assert_equals(elt.localName,
+ desc == "HTML document" ? toASCIILowercase(String(t))
+ : String(t),
+ "localName")
+ assert_equals(elt.tagName,
+ desc == "HTML document" ? toASCIIUppercase(String(t))
+ : String(t),
+ "tagName")
+ assert_equals(elt.prefix, null, "prefix")
+ assert_equals(elt.namespaceURI,
+ desc == "XML document" ? null : HTMLNS, "namespaceURI")
+ });
+ testObj.done();
+ });
+ }, "createElement(" + format_value(t) + ") in " + desc);
});
- invalid.forEach(function(arg) {
- test(function() {
- assert_throws("INVALID_CHARACTER_ERR", function() { document.createElement(arg) })
- }, "createElement(" + format_value(arg) + ")");
+});
+invalid.forEach(function(arg) {
+ ["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
+ async_test(function(testObj) {
+ window.addEventListener("load", function() {
+ testObj.step(function() {
+ var doc = getWin(desc).document;
+ assert_throws("InvalidCharacterError",
+ function() { doc.createElement(arg) })
+ });
+ testObj.done();
+ });
+ }, "createElement(" + format_value(arg) + ") in " + desc);
});
-})
+});
</script>

Powered by Google App Engine
This is Rietveld 408576698