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>
<html>
  <head>
    <script>
      const absolute = new URL("/path/to/resource?x=1#frag", document.baseURI);
      const relative = new URL("child.js", document.baseURI);
      window.urlHref = absolute.href;
      window.urlOrigin = absolute.origin;
      window.urlHost = absolute.host;
      window.urlHostname = absolute.hostname;
      window.urlPort = absolute.port;
      window.urlPathname = absolute.pathname;
      window.urlSearch = absolute.search;
      window.urlHash = absolute.hash;
      window.urlRelativeHref = relative.href;
      window.urlStringifyWorks =
        String(relative) === relative.href && relative.toJSON() === relative.href;
      const urlLike = {
        toString() {
          return "https://example.test/from-object?value=1";
        },
      };
      window.urlObjectToStringValue = urlLike.toString();
      window.urlObjectStringValue = String(urlLike);
      window.urlObjectHref = captureUrlResult(() => new URL(urlLike).href);
      const anchor = document.createElement("a");
      anchor.href = "/anchor-target?q=1#ok";
      window.urlAnchorPropertyHref = anchor.href;
      window.urlAnchorStringValue = String(anchor);
      window.urlAnchorStringifyWorks = String(anchor) === anchor.href;
      window.urlAnchorHref = captureUrlResult(() => new URL(anchor).href);
      window.urlBaseAnchorHref = captureUrlResult(() => new URL("child", anchor).href);
      window.urlCanParseAbsolute = URL.canParse(serverUrl("/can-parse"));
      window.urlCanParseRelativeWithBase = URL.canParse("child", anchor);
      window.urlCanParseRejectsInvalidBaseForAbsolute = URL.canParse(
        "https://example.test/absolute",
        "not-a-url"
      );
      window.documentUrlValue = document.URL;
      window.documentDocumentUriValue = document.documentURI;
      window.documentBaseUriValue = document.baseURI;
      window.documentReadyStateDuringScript = document.readyState;
      window.documentCookieValue = document.cookie;

      document.addEventListener("DOMContentLoaded", () => {
        window.documentReadyStateAtDomContentLoaded = document.readyState;
      }, { once: true });
      window.addEventListener("load", () => {
        window.documentReadyStateAtLoad = document.readyState;
      }, { once: true });

      try {
        new URL("http://[invalid");
        window.urlInvalidThrows = false;
      } catch (_) {
        window.urlInvalidThrows = true;
      }

      function serverUrl(pathname) {
        return new URL(pathname, document.baseURI).href;
      }

      function captureUrlResult(fn) {
        try {
          return fn();
        } catch (error) {
          return String(error);
        }
      }
    </script>
    <script type="module">
      const asset = new URL("./assets/page-mod1.js?mode=test#frag", import.meta.url);
      window.moduleUrlHref = asset.href;
      window.moduleUrlPathname = asset.pathname;
      window.moduleUrlSearch = asset.search;
      window.moduleUrlHash = asset.hash;
    </script>
  </head>
  <body>
    <main>url binding fixture</main>
  </body>
</html>