Skip to content

armgit / moli

Public Imported from GitHub
0

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

1.7 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 src="/wpt/resources/WebIDLParser.js"></script>
<script src="/wpt/resources/idlharness.js"></script>
<script>
idl_test([`
interface Storage {
  readonly attribute unsigned long length;
  DOMString? key(unsigned long index);
  DOMString? getItem(DOMString key);
  undefined setItem(DOMString key, DOMString value);
  undefined removeItem(DOMString key);
  undefined clear();
};
`], [], 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({
    Storage: ["localStorage", "sessionStorage"]
  });
});

test(function () {
  localStorage.clear();
  sessionStorage.clear();

  localStorage.setItem("moli-storage-idl", "local");
  sessionStorage.setItem("moli-storage-idl", "session");

  assert_equals(localStorage.getItem("moli-storage-idl"), "local");
  assert_equals(sessionStorage.getItem("moli-storage-idl"), "session");
  assert_true(localStorage.key(0) === "moli-storage-idl" || localStorage.key(0) === null);
  assert_false(Object.prototype.hasOwnProperty.call(localStorage, "length"));
  assert_equals(Object.prototype.toString.call(localStorage), "[object Storage]");

  localStorage.removeItem("moli-storage-idl");
  sessionStorage.clear();
}, "Storage idlharness sample operations preserve local/session separation");
</script>