Backed out changeset 1a06654dd1ba (bug 1513152) for test-android-em failure at dom/security/test/csp/test_punycode_host_src.html on a CLOSED TREE

This commit is contained in:
Daniel Varga 2018-12-12 03:29:20 +02:00
Родитель bb57f44268
Коммит 9be61b1c47
6 изменённых файлов: 8 добавлений и 46 удалений

Просмотреть файл

@ -1,8 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.importGlobalProperties(["TextEncoder"]);
function gzipCompressString(string, obs) {
let scs = Cc["@mozilla.org/streamConverters;1"]
@ -73,19 +71,7 @@ function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, status, "DA DA DA");
response.setHeader("Content-Type", "text/plain", false);
setCacheHeaders();
function convertToUtf8(str) {
return String.fromCharCode(...new TextEncoder().encode(str));
}
// This script must be evaluated as UTF-8 for this to write out the
// bytes of the string in UTF-8. If it's evaluated as Latin-1, the
// written bytes will be the result of UTF-8-encoding this string
// *twice*.
let data = "Братан, ты вообще качаешься?";
let stringOfUtf8Bytes = convertToUtf8(data);
response.write(stringOfUtf8Bytes);
response.write("Братан, ты вообще качаешься?");
response.finish();
break;
}

Просмотреть файл

@ -1,8 +1,6 @@
// custom *.sjs for Bug 1224225
// Punycode in CSP host sources
Cu.importGlobalProperties(["TextEncoder"]);
const HTML_PART1 =
"<!DOCTYPE HTML>" +
"<html><head><meta charset=\"utf-8\">" +
@ -11,12 +9,7 @@ const HTML_PART1 =
"<body>" +
"<script id='script' src='";
function convertToUtf8(str)
{
return String.fromCharCode(...new TextEncoder().encode(str));
}
const TESTCASE1 = "http://sub2." + convertToUtf8("ä") + "lt.example.org/";
const TESTCASE1 = "http://sub2.ält.example.org/";
const TESTCASE2 = "http://sub2.xn--lt-uia.example.org/"
const HTML_PART2 = "tests/dom/security/test/csp/file_punycode_host_src.js'></script>" +

Просмотреть файл

@ -1,9 +1,6 @@
// SJS file for getAllResponseRequests vs getResponseRequest
function handleRequest(request, response)
{
// Header strings are interpreted by truncating the characters in them to
// bytes, so U+2026 HORIZONTAL ELLIPSIS here must be encoded manually: using
// "…" as the string would write a \x26 byte.
response.setHeader("X-Custom-Header-Bytes", "\xE2\x80\xA6", false);
response.setHeader("X-Custom-Header-Bytes", "…", false);
response.write("42");
}

Просмотреть файл

@ -20,8 +20,7 @@ let xhr = new XMLHttpRequest();
xhr.open('GET', 'file_XHR_header.sjs', true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
ok(xhr.getResponseHeader('X-Custom-Header-Bytes') == "\xE2\x80\xA6",
"getResponseHeader returns a string of the header's raw bytes");
ok(xhr.getResponseHeader('X-Custom-Header-Bytes') == "\xE2\x80\xA6", 'getResponseHeader byte-inflates the output');
SimpleTest.finish();
}
}

Просмотреть файл

@ -2529,7 +2529,7 @@ ServerHandler.prototype =
// separate these two lines!
var line = new Error().lineNumber;
let uri = Services.io.newFileURI(file);
Services.scriptloader.loadSubScript(uri.spec, s, "UTF-8");
Services.scriptloader.loadSubScript(uri.spec, s);
} catch (e) {
dumpn("*** syntax error in SJS at " + file.path + ": " + e);
throw HTTP_500;

Просмотреть файл

@ -4,8 +4,6 @@
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.importGlobalProperties(["TextEncoder"]);
/**
* Provide search suggestions in the OpenSearch JSON format.
*/
@ -14,21 +12,10 @@ function handleRequest(request, response) {
// Get the query parameters from the query string.
let query = parseQueryString(request.queryString);
function convertToUtf8(str) {
return String.fromCharCode(...new TextEncoder().encode(str));
}
function writeSuggestions(query, completions = []) {
let result = [query, completions];
let jsonString = JSON.stringify([query, completions]);
// This script must be evaluated as UTF-8 for this to write out the bytes of
// the string in UTF-8. If it's evaluated as Latin-1, the written bytes
// will be the result of UTF-8-encoding the result-string *twice*, which
// will break the "I ❤️" case further down.
let stringOfUtf8Bytes = convertToUtf8(jsonString);
response.write(stringOfUtf8Bytes);
response.write(JSON.stringify(result));
return result;
}
response.setStatusLine(request.httpVersion, 200, "OK");
@ -86,7 +73,7 @@ function parseQueryString(queryString) {
let query = {};
queryString.split('&').forEach(function (val) {
let [name, value] = val.split('=');
query[name] = decodeURIComponent(value).replace(/[+]/g, " ");
query[name] = unescape(value).replace(/[+]/g, " ");
});
return query;
}