2010-11-24 02:50:19 +03:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=605124
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 605124</title>
|
2019-04-16 06:53:28 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2010-11-24 02:50:19 +03:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=605124">Mozilla Bug 605124</a>
|
|
|
|
<p id="display"></p>
|
2010-11-24 02:50:53 +03:00
|
|
|
<div id="content">
|
2010-11-24 02:50:19 +03:00
|
|
|
<form>
|
|
|
|
<textarea required></textarea>
|
|
|
|
<input required>
|
2010-11-24 13:09:17 +03:00
|
|
|
<select required></select>
|
2010-11-24 02:50:19 +03:00
|
|
|
<button type='submit'></button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<form>
|
|
|
|
<tr>
|
|
|
|
<textarea required></textarea>
|
|
|
|
<input required>
|
2010-11-24 13:09:17 +03:00
|
|
|
<select required></select>
|
2010-11-24 02:50:19 +03:00
|
|
|
<button type='submit'></button>
|
|
|
|
</tr>
|
|
|
|
</form>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 605124 **/
|
|
|
|
|
|
|
|
function checkPseudoClass(aElement, aExpected)
|
|
|
|
{
|
2014-08-12 16:30:59 +04:00
|
|
|
is(aElement.matches(":-moz-ui-invalid"), aExpected,
|
|
|
|
"matches(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
|
2010-11-24 02:50:19 +03:00
|
|
|
}
|
|
|
|
|
2013-09-04 20:02:34 +04:00
|
|
|
var os = SpecialPowers.Cc['@mozilla.org/observer-service;1']
|
|
|
|
.getService(SpecialPowers.Ci.nsIObserverService);
|
2010-11-24 02:50:19 +03:00
|
|
|
var observers = os.enumerateObservers("invalidformsubmit");
|
|
|
|
|
|
|
|
if (observers.hasMoreElements()) {
|
|
|
|
var content = document.getElementById('content');
|
|
|
|
var textarea = document.getElementsByTagName('textarea')[0];
|
|
|
|
var input = document.getElementsByTagName('input')[0];
|
2010-11-24 13:09:17 +03:00
|
|
|
var select = document.getElementsByTagName('select')[0];
|
2010-11-24 02:50:19 +03:00
|
|
|
var button = document.getElementsByTagName('button')[0];
|
|
|
|
var form = document.forms[0];
|
|
|
|
|
|
|
|
checkPseudoClass(textarea, false);
|
|
|
|
checkPseudoClass(input, false);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, false);
|
2010-11-24 02:50:19 +03:00
|
|
|
|
|
|
|
// Try to submit.
|
|
|
|
button.click();
|
|
|
|
checkPseudoClass(textarea, true);
|
|
|
|
checkPseudoClass(input, true);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, true);
|
2010-11-24 02:50:19 +03:00
|
|
|
|
|
|
|
// No longer in the form.
|
|
|
|
content.appendChild(textarea);
|
|
|
|
content.appendChild(input);
|
2010-11-24 13:09:17 +03:00
|
|
|
content.appendChild(select);
|
2010-11-24 02:50:19 +03:00
|
|
|
checkPseudoClass(textarea, false);
|
|
|
|
checkPseudoClass(input, false);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, false);
|
2010-11-24 02:50:19 +03:00
|
|
|
|
|
|
|
// Back in the form.
|
|
|
|
form.appendChild(textarea);
|
|
|
|
form.appendChild(input);
|
2010-11-24 13:09:17 +03:00
|
|
|
form.appendChild(select);
|
2010-11-24 02:50:19 +03:00
|
|
|
checkPseudoClass(textarea, true);
|
|
|
|
checkPseudoClass(input, true);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, true);
|
2010-11-24 02:50:19 +03:00
|
|
|
|
|
|
|
/* Case when elements get orphaned. */
|
|
|
|
var textarea = document.getElementsByTagName('textarea')[1];
|
|
|
|
var input = document.getElementsByTagName('input')[1];
|
2010-11-24 13:09:17 +03:00
|
|
|
var select = document.getElementsByTagName('select')[1];
|
2010-11-24 02:50:19 +03:00
|
|
|
var button = document.getElementsByTagName('button')[1];
|
|
|
|
var form = document.forms[1];
|
|
|
|
|
|
|
|
// Try to submit.
|
|
|
|
button.click();
|
|
|
|
checkPseudoClass(textarea, true);
|
|
|
|
checkPseudoClass(input, true);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, true);
|
2010-11-24 02:50:19 +03:00
|
|
|
|
|
|
|
// Remove the form.
|
|
|
|
document.getElementsByTagName('table')[0].removeChild(form);
|
|
|
|
checkPseudoClass(textarea, false);
|
|
|
|
checkPseudoClass(input, false);
|
2010-11-24 13:09:17 +03:00
|
|
|
checkPseudoClass(select, false);
|
2012-08-13 14:14:34 +04:00
|
|
|
} else {
|
|
|
|
todo(false, "No 'invalidformsubmit' observers. Skip test.");
|
2010-11-24 02:50:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|