Skip to content

armgit / moli

Public Imported from GitHub
0

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

1.2 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>
function assert_throws_name(expectedName, callback) {
  let thrown = null;
  try {
    callback();
  } catch (error) {
    thrown = error;
  }
  assert_true(!!thrown, "expected exception");
  assert_equals(thrown.name, expectedName);
}

function create(type) {
  if (type === "Text") {
    return document.createTextNode("test");
  }
  if (type === "Comment") {
    return document.createComment("test");
  }
  return document.createProcessingInstruction("target", "test");
}

["Text", "Comment", "ProcessingInstruction"].forEach(function(parentType) {
  ["Text", "Comment", "ProcessingInstruction"].forEach(function(childType) {
    test(function() {
      const parent = create(parentType);
      const child = create(childType);
      assert_throws_name("HierarchyRequestError", function() {
        parent.appendChild(child);
      });
      assert_equals(parent.childNodes.length, 0);
      assert_equals(child.parentNode, null);
    }, parentType + ".appendChild(" + childType + ") rejects children");
  });
});
</script>