Skip to content

armgit / moli

Public Imported from GitHub
0

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

3.0 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 Location {
  [CallWith=Isolate, RaisesException, LegacyUnforgeable] void assign(USVString url);
  [CallWith=Isolate, CrossOrigin, RaisesException, LegacyUnforgeable] void replace(USVString url);
  [LegacyUnforgeable] void reload();
  [LegacyUnforgeable] readonly attribute DOMStringList ancestorOrigins;
  [SetterCallWith=Isolate, CrossOrigin=Setter, RaisesException=Setter, LegacyUnforgeable] attribute USVString href;
  [LegacyUnforgeable] DOMString toString();
  [MeasureAs=LocationOrigin, LegacyUnforgeable] readonly attribute USVString origin;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString protocol;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString host;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString hostname;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString port;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString pathname;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString search;
  [SetterCallWith=Isolate, RaisesException=Setter, LegacyUnforgeable] attribute USVString hash;
};
`], [], function (idlArray) {
  idlArray.enable_interface_descriptor_assertions();
  idlArray.enable_operation_descriptor_assertions();
  idlArray.enable_attribute_descriptor_assertions();
  idlArray.enable_object_brand_assertions();
  idlArray.add_objects({
    Location: ["location"]
  });
});

function assert_throws_name(expectedName, callback, description) {
  try {
    callback();
  } catch (error) {
    assert_equals(error.name, expectedName, description);
    return;
  }
  throw new Error(description || "expected exception");
}

test(function () {
  assert_throws_name("TypeError", () => location.assign(), "assign() should require a URL");
  assert_throws_name("TypeError", () => location.replace(), "replace() should require a URL");
  assert_throws_name("TypeError", () => location.assign(Symbol("url")), "assign() should reject Symbol URL conversion");
  assert_throws_name("TypeError", () => location.replace(Symbol("url")), "replace() should reject Symbol URL conversion");
  assert_throws_name("Error", () => {
    location.assign({ toString() { throw new Error("assign conversion failed"); } });
  }, "assign() should propagate URL stringification errors");
  assert_throws_name("Error", () => {
    location.replace({ toString() { throw new Error("replace conversion failed"); } });
  }, "replace() should propagate URL stringification errors");
}, "Location.assign() and Location.replace() use WebIDL USVString conversion");
</script>