<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script src="form-validation.js"></script>
<iframe id="testFrame1" srcdoc="<iframe id='testFrame2' src='resources/form-validation-iframe.html'></iframe>"></iframe>
<div id="description"></div>
<div id="console"></div>
<script>
description("Tests that the form validation message goes away when its element's iframe gets detached.");
jsTestIsAsync = true;

onload = function() {
    var testFrame1 = document.getElementById("testFrame1");
    testFrame1.contentDocument.getElementById("testFrame2").contentDocument.getElementById("required_text_input_submit").click();

    testFrame1.remove();
    testFrame1 = null;
    gc();

    getValidationMessage().then((_message) => {
        message = _message;

        gc();
        shouldBeEqualToString("message", "");
        finishJSTest();
    });
}
</script>
</body>
<html>
