Skip to content

armgit / moli

Public Imported from GitHub
0

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

4.9 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>
  // Real project-generated font: moli-layout/tests/fixtures/moli-ahem.woff2.
  const FONT_FIXTURE_SOURCE = "url(data:font/woff2;base64,d09GMgABAAAAAAKMAAoAAAAAEewAAAI9AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAARAqSGIlCATYCJAOBRguBRgAEIAWDDweHZhsaDBEVjE2QrxO4OaB11Uo4KkNFQmQIgNrHOq+V6mgnvY2fvSQ/uF+9N7PdNFuXpclV2mkpdFaAC3aRoEdFB3L8iVa3NRGchB7CA+kvmysBs3ExDyF+2La9iSrRM8x/YMEH4+YNnI6ADDhw44HnsPGNf2vg8Vh2oEcLbcza3qYp3gsXSOBToI2cQC+UhHthpAFIuk0EVfwGmbm3vt4jtOf5c3NBuwr0P4kB5kvBCdDgYzQftZAtCfcwRbHKu3S8ycdHAOfu8OUAmLjP+bEQEov+i78AFoAP+AEAxAAAAbQvPfKjw6g3kr+bmM88bAz4CAIItbXF3xu9/n2qfwCnW7usCnIKG0p4i7hd9+SA9QzCt8+eB2LUsMiFeojjkCtwessPXvTy47FKi+3KLnHVsltY375HzLDkOf6NhCkpi4iVsmpyVHYpuS67Fdw/4GE+R/a2N2xwfWXnu79JZ8nsauts62iP3v/+6UJH9FXrZ8WIPds2mEHrVuyYtGLNiW0L8jSL6zWd2nTMNs9acejIxsou80QHe+KtWi8h8LdYBGgJlS666aGXPvoZYJAhhhlhlDHGmbAhTCjjQiptrAMfhFGcpFlelFXdtF0/jNO8rNt+nNf9vB8AQjCCYjhBUjTDcrwgSrKiarphWrbjcb2+/jc6gLBCmFDGhVTaWBf+NANEmFDGhVTaWBf+tABEmFDGhVTaWBf+tAJEmFDGhVTaWBf+tAFEmFDGhVTaWBf+tANEmFDGhVTa2PClCtb3AQAAAA==)";
idl_test([`
enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };
enum FontFaceSetLoadStatus { "loading", "loaded" };

interface FontFace {
  constructor(CSSOMString family, FontFaceSource source, optional FontFaceDescriptors descriptors = {});
  attribute CSSOMString family;
  readonly attribute FontFaceSource source;
  attribute CSSOMString style;
  attribute CSSOMString weight;
  attribute CSSOMString stretch;
  attribute CSSOMString variant;
  attribute CSSOMString featureSettings;
  attribute CSSOMString display;
  readonly attribute FontFaceLoadStatus status;
  Promise<FontFace> load();
  readonly attribute Promise<FontFace> loaded;
};

interface FontFaceSet {
  readonly attribute FontFaceSetLoadStatus status;
  readonly attribute Promise<FontFaceSet> ready;
  readonly attribute unsigned long size;
  FontFaceSet add(FontFace font);
  boolean has(FontFace font);
  boolean delete(FontFace font);
  undefined clear();
  boolean check(CSSOMString font, optional CSSOMString text = " ");
  Promise<sequence<FontFace>> load(CSSOMString font, optional CSSOMString text = " ");
  object keys();
  object values();
  object entries();
  undefined forEach(any callback, optional any thisArg);
};

typedef DOMString CSSOMString;
typedef DOMString FontFaceSource;
dictionary FontFaceDescriptors {
  CSSOMString style = "normal";
  CSSOMString weight = "normal";
  CSSOMString stretch = "normal";
  CSSOMString variant = "normal";
  CSSOMString featureSettings = "normal";
  CSSOMString display = "auto";
};
`], [], 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({
    FontFace: ["new FontFace('FixtureFace', FONT_FIXTURE_SOURCE)"],
    FontFaceSet: ["document.fonts"]
  });
});

promise_test(async function () {
  const face = new FontFace("FixtureFace", FONT_FIXTURE_SOURCE, {
    style: "italic",
    weight: "700",
    stretch: "condensed",
    variant: "small-caps",
    featureSettings: '"kern"',
    display: "swap"
  });
  const fonts = document.fonts;

  assert_equals(Object.prototype.toString.call(face), "[object FontFace]");
  assert_equals(Object.prototype.toString.call(fonts), "[object FontFaceSet]");
  assert_false(Object.prototype.hasOwnProperty.call(face, "family"));
  assert_false(Object.prototype.hasOwnProperty.call(face, "source"));
  assert_false(Object.prototype.hasOwnProperty.call(face, "status"));
  assert_false(Object.prototype.hasOwnProperty.call(face, "loaded"));
  assert_false(Object.prototype.hasOwnProperty.call(fonts, "status"));
  assert_false(Object.prototype.hasOwnProperty.call(fonts, "ready"));
  assert_false(Object.prototype.hasOwnProperty.call(fonts, "size"));
  assert_equals(face.loaded, face.loaded);
  assert_equals(fonts.ready, fonts.ready);
  assert_equals(face.family, "FixtureFace");
  assert_equals(face.source, FONT_FIXTURE_SOURCE);
  assert_equals(face.status, "unloaded");
  assert_equals(await face.load(), face);
  assert_equals(face.status, "loaded");
  assert_equals(await face.loaded, face);

  fonts.clear();
  assert_equals(fonts.add(face), fonts);
  assert_true(fonts.has(face));
  assert_array_equals(await fonts.load("16px FixtureFace"), [face]);
  assert_equals(await fonts.ready, fonts);
  assert_true(fonts.check("16px FixtureFace"));
  assert_array_equals(Array.from(fonts.values()), [face]);
}, "FontFace idlharness sample covers FontFaceSet setlike and load surfaces");
</script>