Skip to content

armgit / moli

Public Imported from GitHub
0

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

1.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>
function assert_data(create, type, value, expected, expectedLength) {
  test(function() {
    const node = create();
    assert_equals(node.data, "test", "initial data");
    assert_equals(node.length, 4, "initial length");

    node.data = 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 + ".data = " + JSON.stringify(value));
}

function test_data(create, type) {
  assert_data(create, type, null, "", 0);
  assert_data(create, type, undefined, "undefined", 9);
  assert_data(create, type, 0, "0", 1);
  assert_data(create, type, "", "", 0);
  assert_data(create, type, "--", "--", 2);
  assert_data(create, type, "data", "data", 4);
  assert_data(create, type, "\u8cc7\u6599", "\u8cc7\u6599", 2);
  assert_data(create, type, "\ud83c\udf20 test \ud83c\udf20 TEST", "\ud83c\udf20 test \ud83c\udf20 TEST", 15);
}

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