зеркало из https://github.com/mozilla/gecko-dev.git
Bug 670883 - Add UTF-8 tests for <input type=url>. r=sicking
This commit is contained in:
Родитель
ae2ac3419e
Коммит
99a6d0d0fc
|
@ -43,17 +43,18 @@ function handleRequest(request, response)
|
|||
let [name, value] = s.split(': ');
|
||||
headers[name] = utf8decode(value);
|
||||
});
|
||||
let body = s.substring(headerEnd + 4, s.length - 2);
|
||||
if (!headers["Content-Type"] || headers["Content-Type"] == "text/plain") {
|
||||
|
||||
let body = s.substring(headerEnd + 4, s.length - 2);
|
||||
if (!headers["Content-Type"] || headers["Content-Type"] == "text/plain") {
|
||||
// We're assuming UTF8 for now
|
||||
body = utf8decode(body);
|
||||
}
|
||||
result.push({ headers: headers, body: body});
|
||||
body = utf8decode(body);
|
||||
}
|
||||
result.push({ headers: headers, body: body});
|
||||
});
|
||||
}
|
||||
if (contentTypeParams[''] == "text/plain" &&
|
||||
request.queryString == "plain") {
|
||||
result = requestBody;
|
||||
result = utf8decode(requestBody);
|
||||
}
|
||||
if (contentTypeParams[''] == "application/x-www-form-urlencoded" &&
|
||||
request.queryString == "url") {
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=344615
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 344615</title>
|
||||
<title>Tests for <input type='url'> validity</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
input { background-color: rgb(0,0,0) !important; }
|
||||
input:valid { background-color: rgb(0,255,0) !important; }
|
||||
input:invalid { background-color: rgb(255,0,0) !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=344615">Mozilla Bug 344615</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<input type='url' id='i' oninvalid='invalidEventHandler(event);'>
|
||||
|
@ -22,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=344615
|
|||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 344615 **/
|
||||
/** Tests for <input type='url'> validity **/
|
||||
|
||||
// More checks are done in test_bug551670.html.
|
||||
|
||||
|
@ -44,8 +35,7 @@ function checkValidURL(element)
|
|||
ok(!gInvalid, "The invalid event should not have been thrown");
|
||||
is(element.validationMessage, '',
|
||||
"Validation message should be the empty string");
|
||||
is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
|
||||
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
|
||||
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply");
|
||||
}
|
||||
|
||||
function checkInvalidURL(element)
|
||||
|
@ -58,39 +48,40 @@ function checkInvalidURL(element)
|
|||
ok(gInvalid, "The invalid event should have been thrown");
|
||||
is(element.validationMessage, "Please enter a URL.",
|
||||
"Validation message should be related to invalid URL");
|
||||
is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
|
||||
"rgb(255, 0, 0)", ":invalid pseudo-class should apply");
|
||||
ok(element.mozMatchesSelector(":invalid"),
|
||||
":invalid pseudo-class should apply");
|
||||
}
|
||||
|
||||
var url = document.getElementById('i');
|
||||
is(url.type, 'url', "url state should be recognized");
|
||||
|
||||
// The empty string should not be considered as invalid.
|
||||
url.value = '';
|
||||
checkValidURL(url);
|
||||
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 ],
|
||||
];
|
||||
|
||||
// We are only testing obviously (in)valid URI's because the function used
|
||||
// to check if an URI is valid is not specific to this functionality.
|
||||
url.value = 'foo';
|
||||
checkInvalidURL(url);
|
||||
values.forEach(function([value, valid]) {
|
||||
url.value = value;
|
||||
|
||||
url.value = 'http://mozilla.com/';
|
||||
checkValidURL(url);
|
||||
|
||||
url.value = 'http://mozil\nla\r.com/';
|
||||
checkValidURL(url);
|
||||
|
||||
url.value = ' http://mozilla.com/ ';
|
||||
checkValidURL(url);
|
||||
|
||||
url.value = '\r http://mozilla.com/ \n';
|
||||
checkValidURL(url);
|
||||
|
||||
url.value = 'file:///usr/bin/tulip';
|
||||
checkValidURL(url);
|
||||
|
||||
url.value = '../../bar.html';
|
||||
checkInvalidURL(url);
|
||||
if (valid) {
|
||||
checkValidURL(url);
|
||||
} else {
|
||||
checkInvalidURL(url);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -7,6 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=523771
|
|||
<title>Test for Bug 523771</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=523771">Mozilla Bug 523771</a>
|
||||
|
@ -226,6 +227,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=523771
|
|||
<td><button type=foobar name="n18_7_ _ _ _ _""
|
||||
value="v18_7_ _ _ _ _""></button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type='url'></td>
|
||||
<td><input type=url name="n19_1" value="http://v19_1.org"></td>
|
||||
<td><input type=url name="n19_2" value=""></td>
|
||||
<td><input type=url name="n19_3"></td>
|
||||
<td><input type=url name="" value="http://v19_4.org"></td>
|
||||
<td><input type=url value="http://v19_5.org"></td>
|
||||
<td><input type=url ></td>
|
||||
<td><input type=url name="n19_7_ _ _ __""
|
||||
value="http://v19_7_ _ _ __"">
|
||||
<!-- Put UTF-8 value in the "strange" column. -->
|
||||
<input type=url name="n19_8" value="http://mózillä.órg"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
@ -452,6 +466,12 @@ var expectedSub = [
|
|||
{ name: "n13_2", value: "" },
|
||||
{ name: "n13_3", value: "" },
|
||||
{ name: "n13_7_\r\n_\r\n_\r\n_ _\"", value: "v13_7____ _\"" },
|
||||
// <input type='url'>
|
||||
{ name: "n19_1", value: "http://v19_1.org" },
|
||||
{ name: "n19_2", value: "" },
|
||||
{ name: "n19_3", value: "" },
|
||||
{ name: "n19_7_\r\n_\r\n_\r\n__\"", value: "http://v19_7_____\"" },
|
||||
{ name: "n19_8", value: "http://m\xf3zill\xe4.\xf3rg" },
|
||||
// Default button
|
||||
// Submit button
|
||||
// Button button
|
||||
|
@ -585,9 +605,14 @@ function checkMPSubmission(sub, expected, test) {
|
|||
}
|
||||
}
|
||||
|
||||
function utf8encode(s) {
|
||||
return unescape(encodeURIComponent(s));
|
||||
}
|
||||
|
||||
function checkURLSubmission(sub, expected) {
|
||||
function urlEscape(s) {
|
||||
return escape(s).replace("%20", "+", "g");
|
||||
return escape(utf8encode(s)).replace("%20", "+", "g")
|
||||
.replace("/", "%2F", "g");
|
||||
}
|
||||
|
||||
subItems = sub.split("&");
|
||||
|
@ -656,9 +681,10 @@ function runTest() {
|
|||
|
||||
// multipart/form-data
|
||||
|
||||
// Make normal submission
|
||||
var iframe = $("target_iframe");
|
||||
iframe.onload = function() { gen.next(); };
|
||||
|
||||
// Make normal submission
|
||||
form.submit();
|
||||
yield; // Wait for iframe to load as a result of the submission
|
||||
var submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
|
||||
|
|
Загрузка…
Ссылка в новой задаче