Skip to content

armgit / moli

Public Imported from GitHub
0

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

2.0 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<div id="target"></div>
<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>
idl_test([`
callback IntersectionObserverCallback = undefined (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer);

interface IntersectionObserver {
  constructor(IntersectionObserverCallback callback, optional object options = {});
  readonly attribute Element? root;
  readonly attribute DOMString rootMargin;
  readonly attribute FrozenArray<double> thresholds;
  undefined observe(Element target);
  undefined unobserve(Element target);
  undefined disconnect();
  sequence<IntersectionObserverEntry> takeRecords();
};
`], [], 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({
    IntersectionObserver: ["new IntersectionObserver(function () {})"]
  });
});

test(function () {
  const target = document.getElementById("target");
  const observer = new IntersectionObserver(function () {}, { threshold: [0, 0.5] });
  assert_equals(observer.root, null);
  assert_equals(observer.rootMargin, "0px 0px 0px 0px");
  assert_array_equals(Array.from(observer.thresholds), [0, 0.5]);
  assert_false(Object.hasOwn(observer, "root"));
  assert_false(Object.hasOwn(observer, "rootMargin"));
  assert_false(Object.hasOwn(observer, "thresholds"));
  assert_equals(observer.thresholds, observer.thresholds);
  observer.observe(target);
  assert_true(Array.isArray(observer.takeRecords()));
  observer.unobserve(target);
  observer.disconnect();
}, "IntersectionObserver idlharness sample operations accept an Element target");
</script>