Skip to content

armgit / moli

Public Imported from GitHub
0

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

1.8 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_type_error(callback) {
  let thrown = null;
  try {
    callback();
  } catch (error) {
    thrown = error;
  }
  assert_true(thrown instanceof TypeError, "expected TypeError");
}

function assert_append(create, type, value, expected, expectedLength) {
  test(function() {
    const node = create();
    assert_equals(node.data, "test", "initial data");
    node.appendData(value);
    assert_equals(node.data, expected, "data");
    assert_equals(node.nodeValue, expected, "nodeValue");
    assert_equals(node.textContent, expected, "textContent");
    assert_equals(node.length, expectedLength, "length");
  }, type + ".appendData(" + JSON.stringify(value) + ")");
}

function test_append_data(create, type) {
  assert_append(create, type, "bar", "testbar", 7);
  assert_append(create, type, "", "test", 4);
  assert_append(create, type, ", append more \u8cc7\u6599\uff0c\u6e2c\u8a66\u8cc7\u6599", "test, append more \u8cc7\u6599\uff0c\u6e2c\u8a66\u8cc7\u6599", 25);
  assert_append(create, type, null, "testnull", 8);
  assert_append(create, type, undefined, "testundefined", 13);

  test(function() {
    const node = create();
    node.appendData("", "bar");
    assert_equals(node.data, "test");
  }, type + ".appendData() ignores extra arguments");

  test(function() {
    const node = create();
    assert_throws_type_error(function() {
      node.appendData();
    });
    assert_equals(node.data, "test");
  }, type + ".appendData() requires an argument");
}

test_append_data(function() { return document.createTextNode("test"); }, "Text");
test_append_data(function() { return document.createComment("test"); }, "Comment");
</script>