blob: df7372d01145505f37978f17f6b1cd5f07e01155 [file] [log] [blame]
<!DOCTYPE html>
<title>Test picture-in-picture display mode</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body>
<script>
promise_test(async (t) => {
await test_driver.bless('request PiP window');
const pipWindow = await documentPictureInPicture.requestWindow();
if (pipWindow.document.readyState != "complete") {
// about:blank should load synchronous, but Gecko is still working on that...
// Ensure the async load doesn't blow away the iframe later on.
assert_true(true, "Waiting for pip window to load");
await new Promise(res => pipWindow.addEventListener("load", res, { once: true }));
}
await new Promise(requestAnimationFrame);
assert_true(
!!pipWindow.matchMedia('(display-mode: picture-in-picture)'.matches),
'PIP matches display mode'
);
const iframe = pipWindow.document.createElement("iframe");
iframe.src = '/common/blank.html';
pipWindow.document.body.append(iframe);
await new Promise(res => iframe.addEventListener("load", res, { once: true }));
assert_true(
!!iframe.contentWindow.matchMedia('(display-mode: picture-in-picture)'.matches),
'iframe in PIP matches display mode'
);
});
</script>
</body>