summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Tests/DOM/Node.js
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Tests/DOM/Node.js')
-rw-r--r--Userland/Libraries/LibWeb/Tests/DOM/Node.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Tests/DOM/Node.js b/Userland/Libraries/LibWeb/Tests/DOM/Node.js
index 47c3e1c668..38618c0dd9 100644
--- a/Userland/Libraries/LibWeb/Tests/DOM/Node.js
+++ b/Userland/Libraries/LibWeb/Tests/DOM/Node.js
@@ -36,4 +36,27 @@ afterInitialPageLoad(() => {
document.body.removeChild(element);
expect(element.isConnected).toBeFalse();
});
+
+ test("Node.compareDocumentPosition()", () => {
+ const head = document.head;
+ const body = document.body;
+
+ expect(head.compareDocumentPosition(head)).toBe(0);
+
+ // FIXME: Can be uncommented once the IDL parser correctly implements nullable paramaters.
+ // expect(head.compareDocumentPosition(null) & Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC).
+ // toBe(Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
+
+ expect(head.compareDocumentPosition(body)).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
+ expect(body.compareDocumentPosition(head)).toBe(Node.DOCUMENT_POSITION_PRECEDING);
+
+ const source = document.getElementById("source");
+ expect(source.compareDocumentPosition(body)).toBe(
+ Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING
+ );
+ expect(body.compareDocumentPosition(source)).toBe(
+ Node.DOCUMENT_POSITION_CONTAINED_BY | Node.DOCUMENT_POSITION_FOLLOWING
+ );
+ expect(source.compareDocumentPosition(head)).toBe(Node.DOCUMENT_POSITION_PRECEDING);
+ });
});