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

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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/web-platform-tests/dom/nodes/Element-children.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html
new file mode 100644
index 0000000000000000000000000000000000000000..88d6a5da4a1a03a536f5def5b5be209fa4fae0e6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<title>HTMLCollection edge cases</title>
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<div id="test"><img><img id=foo><img id=foo><img name="bar"></div>
+<script>
+setup(function() {
+ // Add some non-HTML elements in there to test what happens with those.
+ var container = document.getElementById("test");
+ var child = document.createElementNS("", "img");
+ child.setAttribute("id", "baz");
+ container.appendChild(child);
+
+ child = document.createElementNS("", "img");
+ child.setAttribute("name", "qux");
+ container.appendChild(child);
+});
+
+test(function() {
+ var container = document.getElementById("test");
+ var result = container.children.item("foo");
+ assert_true(result instanceof Element, "Expected an Element.");
+ assert_false(result.hasAttribute("id"), "Expected the IDless Element.")
+})
+
+test(function() {
+ var container = document.getElementById("test");
+ var list = container.children;
+ var result = [];
+ for (var p in list) {
+ if (list.hasOwnProperty(p)) {
+ result.push(p);
+ }
+ }
+ assert_array_equals(result, ['0', '1', '2', '3', '4', '5']);
+ result = Object.getOwnPropertyNames(list);
+ assert_array_equals(result, ['0', '1', '2', '3', '4', '5', 'foo', 'bar', 'baz']);
+
+ // Mapping of exposed names to their indices in the list.
+ var exposedNames = { 'foo': 1, 'bar': 3, 'baz': 4 };
+ for (var exposedName in exposedNames) {
+ assert_true(exposedName in list);
+ assert_true(list.hasOwnProperty(exposedName));
+ assert_equals(list[exposedName], list.namedItem(exposedName));
+ assert_equals(list[exposedName], list.item(exposedNames[exposedName]));
+ assert_true(list[exposedName] instanceof Element);
+ }
+
+ var unexposedNames = ['qux'];
+ for (var unexposedName of unexposedNames) {
+ assert_false(unexposedName in list);
+ assert_false(list.hasOwnProperty(unexposedName));
+ assert_equals(list[unexposedName], undefined);
+ assert_equals(list.namedItem(unexposedName), null);
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698