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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/domListEnumeration.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 months 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/fast/dom/domListEnumeration.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/domListEnumeration.html b/third_party/WebKit/LayoutTests/fast/dom/domListEnumeration.html
index 41a28910d5c9cd7ed66d5c32de307addc51d2522..0d44bc0a75937202d2cb2b743daa12ed8a68903e 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/domListEnumeration.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/domListEnumeration.html
@@ -5,6 +5,203 @@
<script src="../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/domListEnumeration.js"></script>
+<script>
+description(
+'This tests enumerating the elements of DOM lists.'
+);
+
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+// Create a testing environment that can be cleanup up easily.
+var testingGround = document.createElement('div');
+document.body.appendChild(testingGround);
+
+function createFromMarkup(markup)
+{
+ var range = document.createRange();
+ var fragmentContainer = document.createElement("div");
+ range.selectNodeContents(fragmentContainer);
+ testingGround.appendChild(fragmentContainer);
+ var fragment = range.createContextualFragment(markup);
+ fragmentContainer.appendChild(fragment);
+ return fragmentContainer.firstChild;
+}
+
+function setup()
+{
+ var head = document.getElementsByTagName('head')[0];
+
+ // 2 additional <style>s needed for StyleSheetList test (one is included in the template).
+ // 3 rules needed in the first additional <style> for the CSSRuleList test.
+ // 3 declarations needed in the first rule needed for the CSSStyleDeclaration test.
+ // @media rule in the second additional <style> for the MediaList test.
+ head.appendChild(createFromMarkup("<style> ol { width: 100px; height: 100px; color: green; } ol { } ol { } </style>"));
+ head.appendChild(createFromMarkup("<style> @media screen, projector, printer { ol { } } </style>"));
+
+ // 3 <ol>s for NodeList test.
+ // 3 attributes in the first <ol> for the NamedNodeMap test.
+ testingGround.appendChild(createFromMarkup("<ol class='foo' id='bar' name='baz'></ol>"));
+ testingGround.appendChild(document.createElement('ol'));
+ testingGround.appendChild(document.createElement('ol'));
+
+ // 3 <form>s for forms for HTMLCollection test.
+ var form = document.createElement('form');
+ testingGround.appendChild(form);
+ testingGround.appendChild(document.createElement('form'));
+ testingGround.appendChild(document.createElement('form'));
+
+ // 3 <select>s for HTMLFormElement test.
+ var select = document.createElement('select');
+ form.appendChild(select);
+ form.appendChild(document.createElement('select'));
+ form.appendChild(document.createElement('select'));
+
+ // 3 <option>s for HTMLSelectElement test.
+ select.appendChild(document.createElement('option'));
+ select.appendChild(document.createElement('option'));
+ select.appendChild(document.createElement('option'));
+
+ document.body.appendChild(testingGround);
+}
+
+function iterateList(list)
+{
+ debug("");
+ debug(Object.prototype.toString.call(list));
+ var temp = new Array();
+ for (var i in list) {
+ temp.push(i);
+ }
+ temp.sort();
+
+ var a = new Array();
+ for (var i = 0; i < temp.length; ++i) {
+ a.push({"i" : temp[i], "item" : list[temp[i]]});
+ }
+ return a;
+}
+
+// ** Firefox DOES include the indexGetter results in enumeration **
+// NodeList
+// HTMLCollection
+// CSSRuleList
+// CSSStyleDeclaration
+// CSSValueList
+// StyleSheetList
+// MediaList
+// NamedNodeMap
+// HTMLFormElement
+// HTMLSelectElement
+
+// ** Firefox DOESN'T include the indexGetter results in enumeration **
+// Window
+
+setup();
+
+var resultArray = new Array();
+
+// NodeList
+var nodeList = document.querySelectorAll('ol');
+resultArray = iterateList(nodeList);
+
+shouldBe("resultArray.length", "9");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "nodeList.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "nodeList.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "nodeList.item(2)");
+
+// HTMLCollection
+var htmlCollection = document.forms;
+resultArray = iterateList(htmlCollection);
+shouldBe("resultArray.length", "6");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "htmlCollection.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "htmlCollection.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "htmlCollection.item(2)");
+
+// NamedNodeMap
+var namedNodeMap = document.getElementsByTagName('ol')[0].attributes;
+resultArray = iterateList(namedNodeMap);
+shouldBe("resultArray.length", "11");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "namedNodeMap.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "namedNodeMap.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "namedNodeMap.item(2)");
+
+// HTMLFormElement
+var htmlFormElement = document.getElementsByTagName('form')[0];
+resultArray = iterateList(htmlFormElement);
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "document.getElementsByTagName('select')[0]");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "document.getElementsByTagName('select')[1]");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "document.getElementsByTagName('select')[2]");
+
+// HTMLSelectElement
+var htmlSelectElement = document.getElementsByTagName('select')[0];
+resultArray = iterateList(htmlSelectElement);
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "document.getElementsByTagName('option')[0]");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "document.getElementsByTagName('option')[1]");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "document.getElementsByTagName('option')[2]");
+
+// StyleSheetList
+var styleSheetList = document.styleSheets;
+resultArray = iterateList(styleSheetList);
+shouldBe("resultArray.length", "6");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "styleSheetList.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "styleSheetList.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "styleSheetList.item(2)");
+
+// CSSRuleList
+var cssRuleList = document.styleSheets[1].cssRules;
+resultArray = iterateList(cssRuleList);
+shouldBe("resultArray.length", "5");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "cssRuleList.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "cssRuleList.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "cssRuleList.item(2)");
+
+// CSSStyleDeclaration
+//debug(escapeHTML(document.getElementsByTagName('style')));
+var cssStyleDeclaration = document.styleSheets[2].cssRules[0].style;
+resultArray = iterateList(cssStyleDeclaration);
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "cssStyleDeclaration.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "cssStyleDeclaration.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "cssStyleDeclaration.item(2)");
+
+// MediaList
+var mediaList = document.styleSheets[3].cssRules[0].media;
+resultArray = iterateList(mediaList);
+shouldBe("resultArray.length", "8");
+shouldBe("resultArray[0].i", "'0'");
+shouldBe("resultArray[0].item", "mediaList.item(0)");
+shouldBe("resultArray[1].i", "'1'");
+shouldBe("resultArray[1].item", "mediaList.item(1)");
+shouldBe("resultArray[2].i", "'2'");
+shouldBe("resultArray[2].item", "mediaList.item(2)");
+
+debug("");
+
+document.body.removeChild(testingGround);
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698