Skip to content

armgit / moli

Public Imported from GitHub
0

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

2.1 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<body></body>
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script>
test(function () {
  const parent = document.createElement("div");
  const child = document.createElement("test");
  parent.appendChild(child);

  child.after();
  assert_equals(parent.innerHTML, "<test></test>");

  child.after(null, undefined, "", "text");
  assert_equals(parent.innerHTML, "<test></test>nullundefinedtext");
  assert_equals(parent.childNodes[3].data, "");
}, "ChildNode.after converts non-node arguments to Text after the child");

test(function () {
  const parent = document.createElement("div");
  const child = document.createElement("test");
  const x = document.createElement("x");
  parent.appendChild(child);

  child.after(x, "text");
  assert_equals(parent.innerHTML, "<test></test><x></x>text");
}, "ChildNode.after inserts element and text arguments after the child");

test(function () {
  const parent = document.createElement("div");
  const child = document.createElement("test");
  parent.appendChild(child);

  child.after("text", child);
  assert_equals(parent.innerHTML, "text<test></test>");
}, "ChildNode.after handles the context object as an argument");

test(function () {
  const parent = document.createElement("div");
  const child = document.createElement("test");
  const x = document.createElement("x");
  const y = document.createElement("y");
  const z = document.createElement("z");

  parent.appendChild(y);
  parent.appendChild(child);
  parent.appendChild(x);

  child.after(x, y, z);
  assert_equals(parent.innerHTML, "<test></test><x></x><y></y><z></z>");
}, "ChildNode.after moves existing siblings after the child in argument order");

test(function () {
  const orphan = document.createElement("x");
  const y = document.createElement("y");

  orphan.after(y);
  assert_equals(orphan.nextSibling, null);
  assert_equals(y.parentNode, null);
}, "ChildNode.after on a child without any parent is a no-op");
</script>