<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script src="form-validation.js"></script>
<form>
  Required text input: <input type="text" id="required_text_input" required><input id="required_text_input_submit" type="submit">
</form>
<div id="description"></div>
<div id="console"></div>
<script>
description("Tests that the HTML form validation bubble disappears when its associated element is no longer visible.");
jsTestIsAsync = true;

onload = function() {
    input = document.getElementById("required_text_input");
    submit = document.getElementById("required_text_input_submit");
    submit.click();

    getValidationMessage().then((_message) => {
        if (_message !== "Fill out this field")
            testFailed("Unexpected validation message: " + _message);

        // Hide input element.
        input.setAttribute("style", "display: none");
        // Force layout.
        input.offsetTop;

        getValidationMessage().then((_message) => {
            message = _message;
            shouldBeEqualToString("message", ""); // No longer visible.
            finishJSTest();
        });
    });
}
</script>
</body>
<html>
