<!DOCTYPE html>
<title>Element ready check for sibling of fullscreen element</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>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<div id="a"></div>
<div id="b"></div>
<script>
    promise_test(async (t) => {
        document.onfullscreenerror = t.unreached_func(
            "second fullscreenchange event"
        );
        const a = document.getElementById("a");
        const b = document.getElementById("b");
        await Promise.all([trusted_request(a), fullScreenChange()]);

        assert_equals(document.fullscreenElement, a, "fullscreen element is a");

        await Promise.all([trusted_request(b, a), fullScreenChange()]);
        assert_equals(document.fullscreenElement, b, "fullscreen element is b");
    });
</script>
