Skip to content

armgit / moli

Public Imported from GitHub
0

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

2.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 Screen {
  readonly attribute long availWidth;
  readonly attribute long availHeight;
  readonly attribute long width;
  readonly attribute long height;
  readonly attribute unsigned long colorDepth;
  readonly attribute unsigned long pixelDepth;
  readonly attribute ScreenOrientation orientation;
};

interface ScreenOrientation {
  readonly attribute OrientationType type;
  readonly attribute unsigned short angle;
  attribute EventHandler onchange;
};

enum OrientationType {
  "portrait-primary",
  "portrait-secondary",
  "landscape-primary",
  "landscape-secondary"
};

typedef any EventHandler;
`], [], function (idlArray) {
  idlArray.enable_interface_descriptor_assertions();
  idlArray.enable_attribute_descriptor_assertions();
  idlArray.enable_object_brand_assertions();
  idlArray.add_objects({
    Screen: ["screen"],
    ScreenOrientation: ["screen.orientation"]
  });
});

test(function () {
  assert_false(screen.hasOwnProperty("width"));
  assert_false(screen.hasOwnProperty("height"));
  assert_false(screen.hasOwnProperty("availWidth"));
  assert_false(screen.hasOwnProperty("availHeight"));
  assert_false(screen.hasOwnProperty("colorDepth"));
  assert_false(screen.hasOwnProperty("pixelDepth"));
  assert_false(screen.hasOwnProperty("orientation"));
  assert_false(screen.orientation.hasOwnProperty("type"));
  assert_false(screen.orientation.hasOwnProperty("angle"));
  assert_false(screen.orientation.hasOwnProperty("onchange"));
  assert_equals(screen.width, 1920);
  assert_equals(screen.height, 1080);
  assert_equals(screen.orientation.type, "landscape-primary");
  assert_equals(screen.orientation.angle, 0);
  assert_equals(Object.prototype.toString.call(screen), "[object Screen]");
  assert_equals(Object.prototype.toString.call(screen.orientation), "[object ScreenOrientation]");
}, "Screen idlharness sample properties expose stable profile and brands");

test(function () {
  let screenCount = 0;
  let orientationCount = 0;

  screen.addEventListener("change", function () {
    screenCount += 1;
  });
  screen.orientation.onchange = function () {
    orientationCount += 1;
  };

  assert_true(screen.dispatchEvent(new Event("change")));
  assert_true(screen.orientation.dispatchEvent(new Event("change")));
  assert_equals(screenCount, 1);
  assert_equals(orientationCount, 1);
}, "Screen idlharness sample dispatch preserves current EventTarget-like behavior");
</script>