
            doc.addEventListener("fullscreenchange", resolve, { once: true });
        });
    }

    // Both when entering and exiting, the fullscreenchange event is fired first
    // on the outer document and then on the iframe's document. This is because
    // the events are fired in animation frame tasks, which run in "frame tree"
    // order.
    promise_test(async (t) => {
        document.onfullscreenerror = t.unreached_func(
            "document fullscreenerror event"
        );
        iframeD