Files
firefox/dom/html/test/forms/test_input_url.html
T
Brian Grinstead e0242e7bbb Bug 1544322 - Part 2.2 - Remove the [type] attribute for one-liner <script> tags loading files in /tests/SimpleTest/ in dom/ r=bzbarsky
This is split from the previous changeset since if we include dom/ the file size is too
large for phabricator to handle.

This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 2` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27457
2019-04-16 03:53:28 +00:00

90 lines
2.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Tests for &lt;input type='url'&gt; validity</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<input type='url' id='i' oninvalid='invalidEventHandler(event);'>
</div>
<pre id="test">
<script type="application/javascript">
/** Tests for <input type='url'> validity **/
// More checks are done in test_bug551670.html.
var gInvalid = false;
function invalidEventHandler(e)
{
is(e.type, "invalid", "Invalid event type should be invalid");
gInvalid = true;
}
function checkValidURL(element)
{
gInvalid = false;
ok(!element.validity.typeMismatch,
"Element should not suffer from type mismatch");
ok(element.validity.valid, "Element should be valid");
ok(element.checkValidity(), "Element should be valid");
ok(!gInvalid, "The invalid event should not have been thrown");
is(element.validationMessage, '',
"Validation message should be the empty string");
ok(element.matches(":valid"), ":valid pseudo-class should apply");
}
function checkInvalidURL(element)
{
gInvalid = false;
ok(element.validity.typeMismatch,
"Element should suffer from type mismatch");
ok(!element.validity.valid, "Element should not be valid");
ok(!element.checkValidity(), "Element should not be valid");
ok(gInvalid, "The invalid event should have been thrown");
is(element.validationMessage, "Please enter a URL.",
"Validation message should be related to invalid URL");
ok(element.matches(":invalid"),
":invalid pseudo-class should apply");
}
var url = document.getElementById('i');
var values = [
// [ value, validity ]
// The empty string should be considered as valid.
[ "", true ],
[ "foo", false ],
[ "http://mozilla.com/", true ],
[ "http://mozilla.com", true ],
[ "http://mozil\nla\r.com/", true ],
[ " http://mozilla.com/ ", true ],
[ "\r http://mozilla.com/ \n", true ],
[ "file:///usr/bin/tulip", true ],
[ "../../bar.html", false ],
[ "http://mozillá.org", true ],
[ "https://mózillä.org", true ],
[ "http://mózillä.órg", true ],
[ "ht://mózillä.órg", true ],
[ "httŭ://mózillä.órg", false ],
];
values.forEach(function([value, valid]) {
url.value = value;
if (valid) {
checkValidURL(url);
} else {
checkInvalidURL(url);
}
});
</script>
</pre>
</body>
</html>