Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

2.4 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script src="/wpt/resources/WebIDLParser.js"></script>
<script src="/wpt/resources/idlharness.js"></script>
<script>
const traversalRoot = document.createElement("section");
traversalRoot.appendChild(document.createElement("article"));

idl_test([`
interface NodeIterator {
  readonly attribute Node root;
  readonly attribute unsigned long whatToShow;
  readonly attribute object? filter;
  readonly attribute Node referenceNode;
  readonly attribute boolean pointerBeforeReferenceNode;
  Node? nextNode();
  Node? previousNode();
  undefined detach();
};

interface TreeWalker {
  readonly attribute Node root;
  readonly attribute unsigned long whatToShow;
  readonly attribute object? filter;
  attribute Node currentNode;
  Node? parentNode();
  Node? firstChild();
  Node? lastChild();
  Node? previousSibling();
  Node? nextSibling();
  Node? previousNode();
  Node? nextNode();
};
`], [], function (idlArray) {
  idlArray.enable_function_length_assertions();
  idlArray.enable_interface_descriptor_assertions();
  idlArray.enable_operation_descriptor_assertions();
  idlArray.enable_attribute_descriptor_assertions();
  idlArray.enable_object_brand_assertions();
  idlArray.add_objects({
    NodeIterator: ["document.createNodeIterator(traversalRoot)"],
    TreeWalker: ["document.createTreeWalker(traversalRoot)"]
  });
});

test(function () {
  const iterator = document.createNodeIterator(traversalRoot);
  const walker = document.createTreeWalker(traversalRoot);

  assert_equals(iterator.root, traversalRoot);
  assert_false(Object.hasOwn(iterator, "root"));
  assert_false(Object.hasOwn(iterator, "whatToShow"));
  assert_false(Object.hasOwn(iterator, "filter"));
  assert_false(Object.hasOwn(iterator, "referenceNode"));
  assert_false(Object.hasOwn(iterator, "pointerBeforeReferenceNode"));

  assert_equals(walker.root, traversalRoot);
  assert_equals(walker.currentNode, traversalRoot);
  assert_false(Object.hasOwn(walker, "root"));
  assert_false(Object.hasOwn(walker, "whatToShow"));
  assert_false(Object.hasOwn(walker, "filter"));
  assert_false(Object.hasOwn(walker, "currentNode"));
}, "Traversal idlharness sample checks inherited-not-own traversal attributes");
</script>