Skip to content

Truly independent web browser

Tests/LibWeb: Import WPT test for the order of named properties

Andreas Kling6d6178907e2b
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.txt
new file mode 100644
index 00000000000..2f745be3082
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail Values from id attributes precede values from name attributes when the same element contributes both
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.html
new file mode 100644
index 00000000000..5908f8624b8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/documents/dom-tree-accessors/nameditem-supported-property-names-order.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Named items: id values precede name values from the same element</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/dom.html#dom-document-nameditem">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+
+<img id="id-value" name="name-value">
+
+<script>
+"use strict";
+
+test(() => {
+ const names = Object.getOwnPropertyNames(document);
+
+ assert_array_equals(
+ names.filter(name => name === "id-value" || name === "name-value"),
+ ["id-value", "name-value"]
+ );
+}, "Values from id attributes precede values from name attributes when the same element contributes both");
+</script>