chromium/third_party/blink/web_tests/screen_orientation/screenorientation-detached-notify-no-crash.html

<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<iframe id=testIframe></iframe>
<script>
var notifyTest = async_test("Test that async event dispatch to detached frame is gracefully handled.");

function changeOrientationAndDetach() {
    // Dispatch an orientationchange event; this is handled asynchronously,
    // queueing a task/timer to do the actual dispatch.
    testRunner.setMockScreenOrientation('portrait-secondary');

    // Detach the iframe while the event dispatch is in-flight. If
    // the screen orientation controller is finalized during the
    // detach, the async event dispatch just after will be treated
    // like a no-op -- there's no controller to handle the dispatch.
    document.body.removeChild(testIframe);
    setTimeout(function () { notifyTest.done(); }, 0);
}
notifyTest.step(function () {
    // Force the creation of a ScreenOrientation and register it
    // with the controller, so that orientationchange events are sent.
    var currentType = window.screen.orientation.type;
    testIframe.src = "resources/iframe-listen-orientation-change-detach.html";
});
</script>
</body>
</html>