| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ enableKeygenElement=true ] --> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| <script> |
| description("Test for validationMessage DOM property."); |
| |
| var form = document.createElement("form"); |
| document.body.appendChild(form); |
| |
| // An input element with a pattern set and a mismatched value |
| var patternInput = document.createElement("input"); |
| patternInput.name = "patternInput"; |
| patternInput.pattern = "lorem ipsum"; |
| patternInput.value = "lorem"; |
| form.appendChild(patternInput); |
| debug("input patternMismatch: " + patternInput.validationMessage); |
| |
| // A required input with an empty value |
| var requiredInput = document.createElement("input"); |
| requiredInput.name = "requiredInput"; |
| requiredInput.required = true; |
| form.appendChild(requiredInput); |
| debug("input valueMissing: " + requiredInput.validationMessage); |
| |
| // A required textarea with an empty value |
| var requiredTextArea = document.createElement("textarea"); |
| requiredTextArea.name = "requiredTextArea"; |
| requiredTextArea.required = true; |
| form.appendChild(requiredTextArea); |
| debug("textarea valueMissing: " + requiredTextArea.validationMessage); |
| |
| // A required select with an empty value |
| var requiredSelect = document.createElement("select"); |
| requiredSelect.name = "requiredSelect"; |
| requiredSelect.required = true; |
| form.appendChild(requiredSelect); |
| debug("select valueMissing: " + requiredSelect.validationMessage); |
| |
| // A type=email input for the "type mismatch" flag |
| var emailInput = document.createElement("input"); |
| emailInput.name = "emailInput"; |
| emailInput.type = "email"; |
| emailInput.value = "incorrectValue"; |
| form.appendChild(emailInput); |
| debug("input typeMismatch: " + emailInput.validationMessage); |
| |
| var numberInput = document.createElement("input"); |
| numberInput.type = "number"; |
| form.appendChild(numberInput); |
| numberInput.focus(); |
| document.execCommand("InsertText", false, "abc"); |
| debug("input badInput: " + numberInput.validationMessage); |
| var nonRequiredBadInputMessage = numberInput.validationMessage; |
| |
| debug("badInput and valueMissing:"); |
| numberInput.required = true; |
| shouldBe("numberInput.validationMessage", "nonRequiredBadInputMessage"); |
| |
| // A button can't be valited and, thus, has a blank validationMessage |
| var but = document.createElement("button"); |
| but.name = "button"; |
| form.appendChild(but); |
| shouldBe("but.validationMessage", "''"); |
| |
| // An input control with no name, so it can't be validated (willValidate = false) |
| var anoninput = document.createElement("input"); |
| form.appendChild(anoninput); |
| shouldBe("anoninput.validationMessage", "''") |
| |
| // Fieldsets can't be validated |
| var happyFieldset = document.createElement("fieldset"); |
| happyFieldset.name = "fieldset"; |
| form.appendChild(happyFieldset); |
| shouldBe("happyFieldset.validationMessage", "''"); |
| |
| // Select controls can't be validated too |
| var happySelect = document.createElement("select"); |
| happySelect.name = "select"; |
| form.appendChild(happySelect); |
| shouldBe("happySelect.validationMessage", "''"); |
| |
| // Output elements can't be validated |
| var happyOutput = document.createElement("output"); |
| happySelect.name = "output"; |
| form.appendChild(happyOutput); |
| shouldBe("happyOutput.validationMessage", "''"); |
| |
| // Object elements can't be validated |
| var happyObject = document.createElement("object"); |
| happySelect.name = "object"; |
| form.appendChild(happyObject); |
| shouldBe("happyObject.validationMessage", "''"); |
| |
| // Keygen controls can't be validated |
| var happyKeygen = document.createElement("keygen"); |
| happySelect.name = "keygen"; |
| form.appendChild(happyKeygen); |
| shouldBe("happyKeygen.validationMessage", "''"); |
| |
| form.remove(); |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |