Bug 866623 - Firefox spoils cyrilic text in the Web Developer Console, r=rcampbell

This commit is contained in:
Victor Porof 2013-05-10 12:01:07 +03:00
parent 91640e2399
commit cbaea197e0
6 changed files with 85 additions and 1 deletions

View File

@ -1252,7 +1252,7 @@ create({ constructor: NetworkDetailsView, proto: MenuContainer.prototype }, {
$("#response-content-textarea-box").hidden = false;
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
aEditor.setMode(SourceEditor.MODES.TEXT);
aEditor.setText(aString);
aEditor.setText(NetworkHelper.convertToUnicode(aString, "UTF-8"));
// Maybe set a more appropriate mode in the Source Editor if possible.
for (let key in CONTENT_MIME_TYPE_MAPPINGS) {

View File

@ -21,6 +21,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_net_simple-request-data.js \
browser_net_simple-request-details.js \
browser_net_content-type.js \
browser_net_cyrillic.js \
browser_net_status-codes.js \
browser_net_post-data.js \
browser_net_jsonp.js \
@ -34,6 +35,7 @@ MOCHITEST_BROWSER_PAGES = \
html_simple-test-page.html \
html_navigate-test-page.html \
html_content-type-test-page.html \
html_cyrillic-test-page.html \
html_status-codes-test-page.html \
html_post-data-test-page.html \
html_jsonp-test-page.html \

View File

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if cyrillic text is rendered correctly in the source editor.
*/
function test() {
initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => {
info("Starting test... ");
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
let { RequestsMenu } = NetMonitorView;
RequestsMenu.lazyUpdate = false;
waitForNetworkEvents(aMonitor, 1).then(() => {
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
"GET", CONTENT_TYPE_SJS + "?fmt=txt", {
status: 200,
statusText: "DA DA DA"
});
EventUtils.sendMouseEvent({ type: "mousedown" },
document.getElementById("details-pane-toggle"));
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll("#details-pane tab")[3]);
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
is(aEditor.getText().indexOf("\u044F"), 26, // я
"The text shown in the source editor is incorrect.");
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
"The mode active in the source editor is incorrect.");
teardown(aMonitor).then(finish);
});
});
aDebuggee.performRequests();
});
}

View File

@ -15,6 +15,7 @@ const EXAMPLE_URL = "http://example.com/browser/browser/devtools/netmonitor/test
const SIMPLE_URL = EXAMPLE_URL + "html_simple-test-page.html";
const NAVIGATE_URL = EXAMPLE_URL + "html_navigate-test-page.html";
const CONTENT_TYPE_URL = EXAMPLE_URL + "html_content-type-test-page.html";
const CYRILLIC_URL = EXAMPLE_URL + "html_cyrillic-test-page.html";
const STATUS_CODES_URL = EXAMPLE_URL + "html_status-codes-test-page.html";
const POST_DATA_URL = EXAMPLE_URL + "html_post-data-test-page.html";
const JSONP_URL = EXAMPLE_URL + "html_jsonp-test-page.html";

View File

@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Network Monitor test page</title>
</head>
<body>
<p>Cyrillic type test</p>
<script type="text/javascript">
function get(aAddress, aCallback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", aAddress, true);
xhr.onreadystatechange = function() {
if (this.readyState == this.DONE) {
aCallback();
}
};
xhr.send(null);
}
function performRequests() {
get("sjs_content-type-test-server.sjs?fmt=txt", function() {
// Done.
});
}
</script>
</body>
</html>

View File

@ -11,6 +11,13 @@ function handleRequest(request, response) {
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => {
switch (format) {
case "txt": {
response.setStatusLine(request.httpVersion, 200, "DA DA DA");
response.setHeader("Content-Type", "text/plain", false);
response.write("Братан, ты вообще качаешься?");
response.finish();
break;
}
case "xml": {
response.setStatusLine(request.httpVersion, 200, "OK");
response.setHeader("Content-Type", "text/xml; charset=utf-8", false);