<script>
function doSyncXHR()
{
    try {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", "xmlhttprequest-responsetype-json.json", false);
        xhr.send(null);
    } catch(e) {
        return false;
    }
    return true;
}

onunload = () => {
    while (!doSyncXHR()) { };
    top.frameDidUnload();
}
</script>
